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.XmlRpcConfig; 00022 import org.apache.xmlrpc.XmlRpcException; 00023 import org.apache.xmlrpc.XmlRpcRequest; 00024 import org.apache.xmlrpc.common.TypeConverterFactory; 00025 import org.apache.xmlrpc.common.TypeConverterFactoryImpl; 00026 import org.apache.xmlrpc.common.XmlRpcController; 00027 import org.apache.xmlrpc.common.XmlRpcRequestProcessor; 00028 import org.apache.xmlrpc.common.XmlRpcWorker; 00029 import org.apache.xmlrpc.common.XmlRpcWorkerFactory; 00030 00031 00038 public class XmlRpcServer extends XmlRpcController 00039 implements XmlRpcRequestProcessor { 00040 private XmlRpcHandlerMapping handlerMapping; 00041 private TypeConverterFactory typeConverterFactory = new TypeConverterFactoryImpl(); 00042 private XmlRpcServerConfig config = new XmlRpcServerConfigImpl(); 00043 00044 protected XmlRpcWorkerFactory getDefaultXmlRpcWorkerFactory() { 00045 return new XmlRpcServerWorkerFactory(this); 00046 } 00047 00050 public void setTypeConverterFactory(TypeConverterFactory pFactory) { 00051 typeConverterFactory = pFactory; 00052 } 00053 public TypeConverterFactory getTypeConverterFactory() { 00054 return typeConverterFactory; 00055 } 00056 00060 public void setConfig(XmlRpcServerConfig pConfig) { config = pConfig; } 00061 public XmlRpcConfig getConfig() { return config; } 00062 00066 public void setHandlerMapping(XmlRpcHandlerMapping pMapping) { 00067 handlerMapping = pMapping; 00068 } 00069 00073 public XmlRpcHandlerMapping getHandlerMapping() { 00074 return handlerMapping; 00075 } 00076 00082 public Object execute(XmlRpcRequest pRequest) throws XmlRpcException { 00083 final XmlRpcWorkerFactory factory = getWorkerFactory(); 00084 final XmlRpcWorker worker = factory.getWorker(); 00085 try { 00086 return worker.execute(pRequest); 00087 } finally { 00088 factory.releaseWorker(worker); 00089 } 00090 } 00091 }