1 16 17 18 package org.apache.xmlrpc; 19 20 import java.util.Vector ; 21 22 31 public class SystemHandler 32 implements ContextXmlRpcHandler 33 { 34 private DefaultHandlerMapping systemMapping = null; 35 36 41 public SystemHandler() 42 { 43 this.systemMapping = new DefaultHandlerMapping(); 44 } 45 46 54 public SystemHandler(XmlRpcHandlerMapping handlerMapping) 55 { 56 this(); 57 if (handlerMapping != null) 58 { 59 addDefaultSystemHandlers(); 60 } 61 } 62 63 73 protected SystemHandler(XmlRpcServer server) 74 { 75 this(server.getHandlerMapping()); 76 } 77 78 86 public void addDefaultSystemHandlers() 87 { 88 addSystemHandler("multicall", new MultiCall()); 89 } 90 91 94 public void addSystemHandler(String handlerName, ContextXmlRpcHandler handler) 95 { 96 systemMapping.addHandler(handlerName, handler); 97 } 98 99 102 public void removeSystemHandler(String handlerName) 103 { 104 systemMapping.removeHandler(handlerName); 105 } 106 107 111 public Object execute(String method, Vector params, XmlRpcContext context) 112 throws Exception 113 { 114 Object handler = null; 115 String systemMethod = null; 116 int dot = method.lastIndexOf('.'); 117 if (dot > -1) 118 { 119 systemMethod = method.substring(dot + 1); 122 123 handler = systemMapping.getHandler(systemMethod + "."); 125 if (handler != null) 126 { 127 return ((ContextXmlRpcHandler) handler).execute(systemMethod, params, context); 128 } 129 } 130 131 throw new NoSuchMethodException ("No method '" + method + "' registered."); 132 } 133 } 134 | Popular Tags |