|
1 |
| package net.sf.crispy.impl; |
|
2 |
| |
|
3 |
| import java.util.Properties; |
|
4 |
| |
|
5 |
| import net.sf.crispy.InvocationException; |
|
6 |
| import net.sf.crispy.InvocationStrategy; |
|
7 |
| import net.sf.crispy.proxy.StaticProxy; |
|
8 |
| import net.sf.crispy.strategy.NameInvocationStrategy; |
|
9 |
| |
|
10 |
| import com.caucho.hessian.client.HessianProxyFactory; |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| public class StaticHessianProxy extends StaticProxy { |
|
19 |
| |
|
20 |
| public final static String DEFAULT_URL_AND_PORT = "http://localhost:8091/crispy/hessian"; |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
73
| public String getDefaultUrlAndPort() {
|
|
28 |
73
| return DEFAULT_URL_AND_PORT;
|
|
29 |
| } |
|
30 |
| |
|
31 |
36
| public InvocationStrategy getDefaultInvocationStrategy(Properties pvProperties) {
|
|
32 |
36
| String lvInterfaceName = (String) pvProperties.get(PROPERTY_CURRENT_INTERFACE_CLASS);
|
|
33 |
36
| return new NameInvocationStrategy(lvInterfaceName);
|
|
34 |
| } |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
37
| public Object newInstance(Class pvProxyClass) {
|
|
40 |
37
| String lvUrlAndPort = getUrlAndPort() + "/" + getInvocationStrategy();
|
|
41 |
| if (log.isDebugEnabled()) { log.debug("Hessian Url and Port: " + lvUrlAndPort); } |
|
42 |
37
| HessianProxyFactory factory = new HessianProxyFactory();
|
|
43 |
37
| factory.setOverloadEnabled(true);
|
|
44 |
37
| try {
|
|
45 |
37
| Object lvProxyObject = factory.create(pvProxyClass, lvUrlAndPort);
|
|
46 |
36
| setProxyObject(lvProxyObject);
|
|
47 |
36
| setProxyClass(lvProxyObject.getClass());
|
|
48 |
| } catch (Exception e) { |
|
49 |
1
| throw new InvocationException("Error in newInstance in StaticHessianProxy: " + e, e);
|
|
50 |
| } |
|
51 |
| if (log.isDebugEnabled()) { log.debug("Hessian Object created: " + getProxyObject()); } |
|
52 |
36
| return getProxyObject();
|
|
53 |
| } |
|
54 |
| } |