|
1 |
| package net.sf.crispy.impl; |
|
2 |
| |
|
3 |
| import java.lang.reflect.Method; |
|
4 |
| import java.rmi.Naming; |
|
5 |
| import java.util.Vector; |
|
6 |
| |
|
7 |
| import net.sf.crispy.ExceptionWrapper; |
|
8 |
| import net.sf.crispy.Executor; |
|
9 |
| import net.sf.crispy.impl.rmi.RmiInvocationHandler; |
|
10 |
| import net.sf.crispy.util.Invoker; |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| public class RmiExecutor extends Executor { |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| public final static String DEFAULT_URL_AND_PORT = "rmi://localhost:1098"; |
|
27 |
| |
|
28 |
| public final static String LOOKUP_NAME = "RmiInvocationHandler"; |
|
29 |
| |
|
30 |
| private RmiInvocationHandler rmiInvocationHandler = null; |
|
31 |
| |
|
32 |
96
| public String getDefaultUrlAndPort() { return DEFAULT_URL_AND_PORT; }
|
|
33 |
| |
|
34 |
58
| public boolean withConverter() { return true; }
|
|
35 |
| |
|
36 |
58
| public Object execute(Class pvProxyClass, Object pvProxy, Method pvMethod, Object[] pvArgs) throws Exception {
|
|
37 |
58
| if (rmiInvocationHandler == null) {
|
|
38 |
37
| String lvLookupStr = getUrlAndPort() + "/" + LOOKUP_NAME;
|
|
39 |
37
| rmiInvocationHandler = (RmiInvocationHandler) Naming.lookup(lvLookupStr);
|
|
40 |
| } |
|
41 |
58
| Vector lvParams = Invoker.array2Vector(pvArgs);
|
|
42 |
58
| Object lvReturn = rmiInvocationHandler.invoke(pvProxyClass.getName(), pvMethod.getName(), lvParams);
|
|
43 |
| |
|
44 |
58
| lvReturn = ExceptionWrapper.isResultExceptionThanThrowIt(lvReturn);
|
|
45 |
| |
|
46 |
56
| return lvReturn;
|
|
47 |
| } |
|
48 |
| |
|
49 |
| } |