1 16 17 18 package org.apache.xmlrpc; 19 20 import java.util.Hashtable ; 21 import java.util.Vector ; 22 23 33 public class MultiCall 34 implements ContextXmlRpcHandler 35 { 36 public Object execute(String method, Vector params, XmlRpcContext context) 37 throws Exception 38 { 39 if ("multicall".equals(method)) 40 { 41 return multicall(params, context); 42 } 43 44 throw new NoSuchMethodException ("No method '" + method + "' in " + this.getClass().getName()); 45 } 46 47 public Vector multicall(Vector requests, XmlRpcContext context) 48 { 49 requests=(Vector )requests.elementAt(0); 51 Vector response = new Vector (); 52 XmlRpcServerRequest request; 53 for (int i = 0; i < requests.size(); i++) 54 { 55 try 56 { 57 Hashtable call = (Hashtable ) requests.elementAt(i); 58 request = new XmlRpcRequest((String ) call.get("methodName"), 59 (Vector ) call.get("params")); 60 Object handler = context.getHandlerMapping().getHandler(request.getMethodName()); 61 Vector v = new Vector (); 62 v.addElement(XmlRpcWorker.invokeHandler(handler, request, context)); 63 response.addElement(v); 64 } 65 catch (Exception x) 66 { 67 String message = x.toString(); 68 int code = (x instanceof XmlRpcException ? 69 ((XmlRpcException) x).code : 0); 70 Hashtable h = new Hashtable (); 71 h.put("faultString", message); 72 h.put("faultCode", new Integer (code)); 73 response.addElement(h); 74 } 75 } 76 return response; 77 } 78 } 79 | Popular Tags |