1 package org.apache.maven.archiva.web.xmlrpc.server;
\r
3 import java.util.Map;
\r
4 import java.util.HashMap;
\r
7 * Licensed to the Apache Software Foundation (ASF) under one
\r
8 * or more contributor license agreements. See the NOTICE file
\r
9 * distributed with this work for additional information
\r
10 * regarding copyright ownership. The ASF licenses this file
\r
11 * to you under the Apache License, Version 2.0 (the
\r
12 * "License"); you may not use this file except in compliance
\r
13 * with the License. You may obtain a copy of the License at
\r
15 * http://www.apache.org/licenses/LICENSE-2.0
\r
17 * Unless required by applicable law or agreed to in writing,
\r
18 * software distributed under the License is distributed on an
\r
19 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
\r
20 * KIND, either express or implied. See the License for the
\r
21 * specific language governing permissions and limitations
\r
22 * under the License.
\r
25 import java.util.List;
\r
26 import org.apache.xmlrpc.XmlRpcException;
\r
27 import org.apache.xmlrpc.XmlRpcRequest;
\r
28 import org.apache.xmlrpc.server.RequestProcessorFactoryFactory;
\r
30 public class ArchivaRequestProcessorFactoryFactory implements RequestProcessorFactoryFactory
\r
32 private final Map<Class, ArchivaRequestProcessorFactory> services;
\r
34 public ArchivaRequestProcessorFactoryFactory(List serviceList)
\r
36 services = new HashMap<Class, ArchivaRequestProcessorFactory>();
\r
37 for (Object service : serviceList)
\r
39 services.put(service.getClass(), new ArchivaRequestProcessorFactory(service.getClass(), service));
\r
43 public RequestProcessorFactory getRequestProcessorFactory(Class pClass)
\r
44 throws XmlRpcException
\r
46 ArchivaRequestProcessorFactory processorFactory = services.get(pClass);
\r
47 if (processorFactory == null)
\r
49 throw new XmlRpcException("Could not find service object instance for type " + pClass.getName());
\r
51 return processorFactory;
\r
54 private class ArchivaRequestProcessorFactory implements RequestProcessorFactory
\r
56 private final Class pType;
\r
58 private final Object serviceObject;
\r
60 public ArchivaRequestProcessorFactory(Class pType, Object serviceObject)
\r
63 this.serviceObject = serviceObject;
\r
66 public Object getRequestProcessor(XmlRpcRequest request)
\r
67 throws XmlRpcException
\r
69 return serviceObject;
\r