1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.ksb.messaging.bam; |
18 | |
|
19 | |
import java.lang.reflect.Method; |
20 | |
import java.lang.reflect.Proxy; |
21 | |
|
22 | |
import org.kuali.rice.core.proxy.BaseTargetedInvocationHandler; |
23 | |
import org.kuali.rice.core.resourceloader.ContextClassLoaderProxy; |
24 | |
import org.kuali.rice.core.util.ExceptionUtils; |
25 | |
import org.kuali.rice.ksb.messaging.ServiceInfo; |
26 | |
import org.kuali.rice.ksb.messaging.bam.service.BAMService; |
27 | |
import org.kuali.rice.ksb.service.KSBServiceLocator; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public class BAMServerProxy extends BaseTargetedInvocationHandler { |
40 | |
|
41 | |
private ServiceInfo entry; |
42 | |
|
43 | |
private BAMServerProxy(Object target, ServiceInfo entry) { |
44 | 0 | super(target); |
45 | 0 | this.entry = entry; |
46 | 0 | } |
47 | |
|
48 | |
public static Object wrap(Object target, ServiceInfo entry) { |
49 | 0 | return Proxy.newProxyInstance(target.getClass().getClassLoader(), ContextClassLoaderProxy.getInterfacesToProxyIncludeSpring(target), new BAMServerProxy(target, entry)); |
50 | |
} |
51 | |
|
52 | |
|
53 | |
protected Object invokeInternal(Object proxiedObject, Method method, Object[] arguments) throws Throwable { |
54 | 0 | BAMTargetEntry bamTargetEntry = KSBServiceLocator.getBAMService().recordServerInvocation(getTarget(), this.entry, method, arguments); |
55 | |
try { |
56 | 0 | return method.invoke(getTarget(), arguments); |
57 | 0 | } catch (Throwable throwable) { |
58 | 0 | throwable = ExceptionUtils.unwrapActualCause(throwable); |
59 | 0 | KSBServiceLocator.getBAMService().recordServerInvocationError(throwable, bamTargetEntry); |
60 | 0 | throw throwable; |
61 | |
} |
62 | |
} |
63 | |
} |