|
1 |
| package net.sf.crispy.server; |
|
2 |
| |
|
3 |
| import java.lang.reflect.Method; |
|
4 |
| |
|
5 |
| import net.sf.crispy.ExceptionWrapper; |
|
6 |
| import net.sf.crispy.InterceptorHandler; |
|
7 |
| import net.sf.crispy.proxy.DynamicJdkProxy; |
|
8 |
| import net.sf.crispy.proxy.DynamicProxy; |
|
9 |
| import net.sf.crispy.proxy.InvocationHandler; |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| public class ServiceEndpointImpl implements ServiceEndpoint { |
|
20 |
| |
|
21 |
| private InterceptorHandlerCreator interceptorHandlerCreator = null; |
|
22 |
| |
|
23 |
9
| public void setInterceptorHandlerCreator(InterceptorHandlerCreator pvCreator) {
|
|
24 |
9
| interceptorHandlerCreator = pvCreator;
|
|
25 |
| } |
|
26 |
| |
|
27 |
286
| public InterceptorHandlerCreator getInterceptorHandlerCreator() {
|
|
28 |
286
| return interceptorHandlerCreator;
|
|
29 |
| } |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
262
| public final InterceptorHandler createNewInterceptorHandlerInstance() {
|
|
37 |
262
| if (this.getInterceptorHandlerCreator() != null) {
|
|
38 |
15
| return getInterceptorHandlerCreator().createNewInterceptorHandlerInstance();
|
|
39 |
| } else { |
|
40 |
247
| return new InterceptorHandler();
|
|
41 |
| } |
|
42 |
| } |
|
43 |
| |
|
44 |
259
| public final Object doInvoke(Object pvServiceImpl, Method pvMethod, Object[] pvArgs, InterceptorHandler pvInterceptorHandler) {
|
|
45 |
259
| Object lvResult = null;
|
|
46 |
| |
|
47 |
259
| InterceptorHandler lvInterceptorHandler = pvInterceptorHandler;
|
|
48 |
259
| if (lvInterceptorHandler == null) {
|
|
49 |
4
| lvInterceptorHandler = createNewInterceptorHandlerInstance();
|
|
50 |
| } |
|
51 |
| |
|
52 |
259
| DynamicProxy dynamicProxy = new DynamicJdkProxy();
|
|
53 |
259
| dynamicProxy.setProxyClass(pvServiceImpl.getClass());
|
|
54 |
259
| dynamicProxy.setProxyObject(pvServiceImpl);
|
|
55 |
| |
|
56 |
259
| try {
|
|
57 |
259
| lvResult = InvocationHandler.doInvoke(dynamicProxy, null, pvMethod, pvArgs, lvInterceptorHandler);
|
|
58 |
| } catch (Exception e) { |
|
59 |
12
| lvResult = ExceptionWrapper.isThrowableThanHandleThrowable(e);
|
|
60 |
| } |
|
61 |
259
| return lvResult;
|
|
62 |
| } |
|
63 |
| |
|
64 |
| } |