00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the 00007 * "License"); you may not use this file except in compliance 00008 * with the License. You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, 00013 * software distributed under the License is distributed on an 00014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 00015 * KIND, either express or implied. See the License for the 00016 * specific language governing permissions and limitations 00017 * under the License. 00018 */ 00019 package org.apache.xmlrpc.server; 00020 00021 import org.apache.xmlrpc.XmlRpcException; 00022 import org.apache.xmlrpc.XmlRpcRequest; 00023 import org.apache.xmlrpc.metadata.Util; 00024 00025 00065 public interface RequestProcessorFactoryFactory { 00071 public interface RequestProcessorFactory { 00078 public Object getRequestProcessor(XmlRpcRequest pRequest) throws XmlRpcException; 00079 } 00080 00085 public RequestProcessorFactory getRequestProcessorFactory(Class pClass) throws XmlRpcException; 00086 00092 public static class RequestSpecificProcessorFactoryFactory 00093 implements RequestProcessorFactoryFactory { 00110 protected Object getRequestProcessor(Class pClass, XmlRpcRequest pRequest) throws XmlRpcException { 00111 return Util.newInstance(pClass); 00112 } 00113 public RequestProcessorFactory getRequestProcessorFactory(final Class pClass) throws XmlRpcException { 00114 return new RequestProcessorFactory(){ 00115 public Object getRequestProcessor(XmlRpcRequest pRequest) throws XmlRpcException { 00116 return RequestSpecificProcessorFactoryFactory.this.getRequestProcessor(pClass, pRequest); 00117 } 00118 }; 00119 } 00120 } 00121 00127 public static class StatelessProcessorFactoryFactory 00128 implements RequestProcessorFactoryFactory { 00145 protected Object getRequestProcessor(Class pClass) throws XmlRpcException { 00146 return Util.newInstance(pClass); 00147 } 00148 public RequestProcessorFactory getRequestProcessorFactory(Class pClass) 00149 throws XmlRpcException { 00150 final Object processor = getRequestProcessor(pClass); 00151 return new RequestProcessorFactory(){ 00152 public Object getRequestProcessor(XmlRpcRequest pRequest) throws XmlRpcException { 00153 return processor; 00154 } 00155 }; 00156 } 00157 } 00158 }