1 package org.apache.maven.archiva.web.xmlrpc.server;
\r
4 * Licensed to the Apache Software Foundation (ASF) under one
\r
5 * or more contributor license agreements. See the NOTICE file
\r
6 * distributed with this work for additional information
\r
7 * regarding copyright ownership. The ASF licenses this file
\r
8 * to you under the Apache License, Version 2.0 (the
\r
9 * "License"); you may not use this file except in compliance
\r
10 * with the License. You may obtain a copy of the License at
\r
12 * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * Unless required by applicable law or agreed to in writing,
\r
15 * software distributed under the License is distributed on an
\r
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
\r
17 * KIND, either express or implied. See the License for the
\r
18 * specific language governing permissions and limitations
\r
19 * under the License.
\r
22 import java.util.Map;
\r
23 import java.util.HashMap;
\r
24 import java.util.List;
\r
25 import org.apache.xmlrpc.XmlRpcException;
\r
26 import org.apache.xmlrpc.XmlRpcRequest;
\r
27 import org.apache.xmlrpc.server.RequestProcessorFactoryFactory;
\r
29 public class ArchivaRequestProcessorFactoryFactory implements RequestProcessorFactoryFactory
\r
31 private final Map<Class, ArchivaRequestProcessorFactory> services;
\r
33 public ArchivaRequestProcessorFactoryFactory(List serviceList)
\r
35 services = new HashMap<Class, ArchivaRequestProcessorFactory>();
\r
36 for (Object service : serviceList)
\r
38 services.put(service.getClass(), new ArchivaRequestProcessorFactory(service.getClass(), service));
\r
42 public RequestProcessorFactory getRequestProcessorFactory(Class pClass)
\r
43 throws XmlRpcException
\r
45 ArchivaRequestProcessorFactory processorFactory = services.get(pClass);
\r
46 if (processorFactory == null)
\r
48 throw new XmlRpcException("Could not find service object instance for type " + pClass.getName());
\r
50 return processorFactory;
\r
53 private class ArchivaRequestProcessorFactory implements RequestProcessorFactory
\r
55 private final Class pType;
\r
57 private final Object serviceObject;
\r
59 public ArchivaRequestProcessorFactory(Class pType, Object serviceObject)
\r
62 this.serviceObject = serviceObject;
\r
65 public Object getRequestProcessor(XmlRpcRequest request)
\r
66 throws XmlRpcException
\r
68 return serviceObject;
\r