|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| package net.sf.crispy.impl; |
|
6 |
| |
|
7 |
| import java.util.Properties; |
|
8 |
| |
|
9 |
| import net.sf.crispy.InvocationException; |
|
10 |
| import net.sf.crispy.impl.local.MiniLocalObjectServer; |
|
11 |
| import net.sf.crispy.proxy.StaticProxy; |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| public class StaticLocalObjectProxy extends StaticProxy { |
|
20 |
| |
|
21 |
38
| public StaticLocalObjectProxy () {}
|
|
22 |
32
| public StaticLocalObjectProxy (Properties pvProperties) { super (pvProperties); }
|
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
28
| public String getDefaultUrlAndPort() {
|
|
30 |
28
| return null;
|
|
31 |
| } |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
73
| public Object newInstance (Class pvClass) {
|
|
37 |
73
| setProxyClass (pvClass);
|
|
38 |
73
| setProxyObject(getProxyByInterface(pvClass));
|
|
39 |
69
| return getProxyObject();
|
|
40 |
| } |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
73
| private Object getProxyByInterface(Class pvInterface) throws InvocationException {
|
|
47 |
73
| if (pvInterface == null) {
|
|
48 |
0
| throw new IllegalArgumentException("Das Interface fuer die Erzeugung des Proxy-Objektes darf nicht null sein.");
|
|
49 |
| } |
|
50 |
| |
|
51 |
| |
|
52 |
73
| try {
|
|
53 |
73
| Object o = MiniLocalObjectServer.getServiceByInterface(pvInterface);
|
|
54 |
8
| if (o != null) { return o; }
|
|
55 |
| } catch (InvocationException e) { |
|
56 |
| if (log.isDebugEnabled()) { log.debug(e); } |
|
57 |
| } |
|
58 |
| |
|
59 |
| |
|
60 |
65
| String lvClassName = getProperties().getProperty(pvInterface.getName());
|
|
61 |
65
| if (lvClassName == null) {
|
|
62 |
4
| throw new InvocationException("It is not possible to create a proxy object for the interface -" + pvInterface.getName());
|
|
63 |
| } |
|
64 |
61
| try {
|
|
65 |
61
| return Class.forName(lvClassName).newInstance();
|
|
66 |
| } catch (Exception e) { |
|
67 |
0
| throw new InvocationException("For the Interface: " + pvInterface + " can no class: "
|
|
68 |
| + lvClassName + " create!", e); |
|
69 |
| } |
|
70 |
| } |
|
71 |
| |
|
72 |
| } |