1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.rice.ksb.messaging; |
17 |
|
|
18 |
|
import java.lang.reflect.InvocationHandler; |
19 |
|
import java.lang.reflect.InvocationTargetException; |
20 |
|
import java.lang.reflect.Method; |
21 |
|
import java.lang.reflect.Proxy; |
22 |
|
|
23 |
|
import javax.xml.namespace.QName; |
24 |
|
|
25 |
|
import org.apache.commons.lang.exception.ExceptionUtils; |
26 |
|
import org.apache.log4j.Logger; |
27 |
|
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
@author |
35 |
|
|
36 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 5 |
Complexity Density: 0.56 |
|
37 |
|
public class KSBClientProxy implements InvocationHandler { |
38 |
|
|
39 |
|
private static final Logger LOG = Logger.getLogger(KSBClientProxy.class); |
40 |
|
|
41 |
|
QName serviceName; |
42 |
|
Object service; |
43 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
44 |
0
|
@SuppressWarnings("unchecked")... |
45 |
|
public static <T> T newInstance(String serviceQName, Class<T> interfaceClass) throws InstantiationException, IllegalAccessException { |
46 |
0
|
return (T)Proxy.newProxyInstance(interfaceClass.getClassLoader(), new Class[] { interfaceClass }, new KSBClientProxy(serviceQName)); |
47 |
|
} |
48 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
49 |
0
|
public KSBClientProxy(String serviceQName){... |
50 |
0
|
this.serviceName = QName.valueOf(serviceQName); |
51 |
|
} |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
53 |
0
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {... |
54 |
0
|
if (this.service == null){ |
55 |
0
|
LOG.info("Getting service using GRL for: " + serviceName); |
56 |
0
|
service = GlobalResourceLoader.getService(serviceName); |
57 |
0
|
LOG.info("Obtained service using GRL for: " + serviceName); |
58 |
|
} |
59 |
|
|
60 |
0
|
try { |
61 |
0
|
return method.invoke(service, args); |
62 |
|
} catch (InvocationTargetException e) { |
63 |
0
|
throw ExceptionUtils.getRootCause(e); |
64 |
|
} |
65 |
|
|
66 |
|
} |
67 |
|
|
68 |
|
} |