|
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.burlap.client.BurlapProxyFactory; |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| public class StaticBurlapProxy extends StaticProxy { |
|
19 |
| |
|
20 |
| public final static String DEFAULT_URL_AND_PORT = "http://localhost:8091/crispy/burlap"; |
|
21 |
| |
|
22 |
| private BurlapProxyFactory factory = new BurlapProxyFactory(); |
|
23 |
| |
|
24 |
48
| public StaticBurlapProxy() {
|
|
25 |
48
| factory.setOverloadEnabled(true);
|
|
26 |
| } |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
99
| public String getDefaultUrlAndPort() {
|
|
34 |
99
| return DEFAULT_URL_AND_PORT;
|
|
35 |
| } |
|
36 |
| |
|
37 |
49
| public InvocationStrategy getDefaultInvocationStrategy(Properties pvProperties) {
|
|
38 |
49
| String lvInterfaceName = (String) pvProperties.get(PROPERTY_CURRENT_INTERFACE_CLASS);
|
|
39 |
49
| return new NameInvocationStrategy(lvInterfaceName);
|
|
40 |
| } |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
50
| public Object newInstance(Class pvProxyClass) {
|
|
46 |
50
| String lvUrlAndPort = getUrlAndPort() + "/" + getInvocationStrategy();
|
|
47 |
| if (log.isDebugEnabled()) { log.debug("Burlap Url and Port: " + lvUrlAndPort); } |
|
48 |
| |
|
49 |
50
| try {
|
|
50 |
50
| Object lvProxyObject = null;
|
|
51 |
50
| synchronized (factory) {
|
|
52 |
50
| lvProxyObject = factory.create(pvProxyClass, lvUrlAndPort);
|
|
53 |
| } |
|
54 |
| |
|
55 |
49
| setProxyObject(lvProxyObject);
|
|
56 |
49
| setProxyClass(pvProxyClass);
|
|
57 |
| } catch (Exception e) { |
|
58 |
1
| throw new InvocationException("Error in newInstance in StaticBurlapProxy: " + e, e);
|
|
59 |
| } |
|
60 |
| if (log.isDebugEnabled()) { log.debug("Burlap Object created: " + getProxyObject()); } |
|
61 |
49
| return getProxyObject();
|
|
62 |
| } |
|
63 |
| } |