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.metadata; 00020 00021 import org.apache.xmlrpc.XmlRpcException; 00022 import org.apache.xmlrpc.XmlRpcRequest; 00023 import org.apache.xmlrpc.server.PropertyHandlerMapping; 00024 import org.apache.xmlrpc.server.RequestProcessorFactoryFactory; 00025 00026 00032 public class XmlRpcSystemImpl { 00033 private XmlRpcListableHandlerMapping mapping; 00034 00038 public XmlRpcSystemImpl(XmlRpcListableHandlerMapping pMapping) { 00039 mapping = pMapping; 00040 } 00041 00045 public String[][] methodSignature(String methodName) throws XmlRpcException { 00046 return mapping.getMethodSignature(methodName); 00047 } 00048 00052 public String methodHelp(String methodName) throws XmlRpcException { 00053 return mapping.getMethodHelp(methodName); 00054 } 00055 00059 public String[] listMethods() throws XmlRpcException { 00060 return mapping.getListMethods(); 00061 } 00062 00067 public static void addSystemHandler(final PropertyHandlerMapping pMapping) 00068 throws XmlRpcException { 00069 final RequestProcessorFactoryFactory factory = pMapping.getRequestProcessorFactoryFactory(); 00070 final XmlRpcSystemImpl systemHandler = new XmlRpcSystemImpl(pMapping); 00071 pMapping.setRequestProcessorFactoryFactory(new RequestProcessorFactoryFactory(){ 00072 public RequestProcessorFactory getRequestProcessorFactory(Class pClass) 00073 throws XmlRpcException { 00074 if (XmlRpcSystemImpl.class.equals(pClass)) { 00075 return new RequestProcessorFactory(){ 00076 public Object getRequestProcessor(XmlRpcRequest request) 00077 throws XmlRpcException { 00078 return systemHandler; 00079 } 00080 }; 00081 } else { 00082 return factory.getRequestProcessorFactory(pClass); 00083 } 00084 } 00085 }); 00086 pMapping.addHandler("system", XmlRpcSystemImpl.class); 00087 } 00088 }