1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.proxy.invoker;
19
20 import org.apache.commons.proxy.Invoker;
21 import org.apache.commons.proxy.exception.InvokerException;
22 import org.apache.xmlrpc.XmlRpcException;
23 import org.apache.xmlrpc.XmlRpcHandler;
24
25 import java.lang.reflect.Method;
26 import java.util.Vector;
27
28
29
30
31
32
33
34
35
36
37
38
39
40 public class XmlRpcInvoker implements Invoker
41 {
42 private final XmlRpcHandler handler;
43 private final String handlerName;
44
45 public XmlRpcInvoker( XmlRpcHandler handler, String handlerName )
46 {
47 this.handler = handler;
48 this.handlerName = handlerName;
49 }
50
51 public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
52 {
53 final Object returnValue = handler.execute( handlerName + "." + method.getName(), toArgumentVector( args ) );
54 if( returnValue instanceof XmlRpcException )
55 {
56 throw new InvokerException( "Unable to execute XML-RPC call.", ( XmlRpcException )returnValue );
57
58 }
59 return returnValue;
60 }
61
62 private Vector toArgumentVector( Object[] args )
63 {
64 final Vector v = new Vector();
65 for( int i = 0; i < args.length; i++ )
66 {
67 Object arg = args[i];
68 v.addElement( arg );
69 }
70 return v;
71 }
72 }