1
2
3
4
5
6
7
8 package it.imolinfo.jbi4ejb.runtime.ejbproxy;
9
10 import it.imolinfo.jbi4ejb.Logger;
11 import it.imolinfo.jbi4ejb.LoggerFactory;
12 import it.imolinfo.jbi4ejb.exception.EJBInvokeException;
13
14 import java.lang.reflect.InvocationTargetException;
15 import java.lang.reflect.Method;
16
17 import org.omg.CORBA.ORB;
18
19
20
21
22
23
24 public class StatelessEJBProxy {
25
26
27 private static final Logger LOG
28 = LoggerFactory.getLogger(StatelessEJBProxy.class);
29
30
31 @SuppressWarnings("unused")
32 private String remoteInterfaceClassName = null;
33
34
35 private Object remoteBean = null;
36
37
38 private ClassLoader ejbInvokeClassLoader = null;
39
40
41 private ORB orb = null;
42
43
44 @SuppressWarnings("unchecked")
45 private Class myRemoteInterface = null;
46
47
48
49
50 @SuppressWarnings("unused")
51 private StatelessEJBProxy() {}
52
53
54
55
56
57
58
59
60
61
62
63
64
65 public StatelessEJBProxy(String remoteInterfaceClassName, Object remoteBean, ClassLoader ejbInvokeClassLoader, ORB orb) {
66 this.remoteInterfaceClassName = remoteInterfaceClassName;
67 this.remoteBean = remoteBean;
68 this.ejbInvokeClassLoader = ejbInvokeClassLoader;
69 this.orb = orb;
70 }
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 @SuppressWarnings("unchecked")
93 public Object invokeMethod(String methodName, Object[] params) throws EJBInvokeException, IllegalAccessException, InvocationTargetException {
94 if (LOG.isDebugEnabled()) {
95 StringBuffer paramsString = new StringBuffer();
96 for (int i = 0; i < params.length; i++) {
97 paramsString.append("[" + params[i] + "]");
98 }
99 String msg = "EJB Invocation: interface:[" + remoteInterfaceClassName + "], method:[" + methodName + "]"
100 +"params:" + paramsString ;
101 LOG.debug(msg);
102 }
103 return EJBProxyUtils.invokeMethod(remoteBean, methodName, params, ejbInvokeClassLoader, orb);
104 }
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 @SuppressWarnings("unchecked")
125 public Object invokeMethod(Method method, Object[] params) throws EJBInvokeException, IllegalAccessException, InvocationTargetException {
126
127 if (LOG.isDebugEnabled()) {
128 StringBuffer paramsString = new StringBuffer();
129 for (int i = 0; i < params.length; i++) {
130 paramsString.append("[" + params[i] + "]");
131 }
132 String msg = "EJB Invocation: interface:[" + remoteInterfaceClassName + "], method:[" + method.getName() + "]"
133 +"params:" + paramsString ;
134 LOG.debug(msg);
135 }
136 return EJBProxyUtils.invokeMethod(remoteBean, method, params, ejbInvokeClassLoader, orb);
137 }
138
139
140
141
142
143
144 public ORB getOrb() {
145 return orb;
146 }
147
148
149
150
151
152
153
154
155
156 @SuppressWarnings("unchecked")
157 public void setRemoteInterfaceClass(Class myRemoteInterFace) {
158 this.myRemoteInterface = myRemoteInterFace;
159 }
160
161
162
163
164
165
166
167
168 @SuppressWarnings("unchecked")
169 public Class getRemoteInterfaceClass() {
170 return myRemoteInterface;
171 }
172
173
174
175
176
177
178 public String getRemoteInterfaceClassName() {
179 return remoteInterfaceClassName;
180 }
181
182
183
184
185
186
187 public ClassLoader getEjbInvokeClassLoader() {
188 return ejbInvokeClassLoader;
189 }
190
191
192 }