ProxyInvocationPump.java
biz/hammurapi/util/ProxyInvocationPump.java
Violations
Inspector |
Message |
Severity |
Location |
Java Inspector 048 |
Copyrights information should be present in each file. |
1 |
|
Java Inspector 089 |
Type is not documented |
2 |
34:1
|
Java Inspector 089 |
Undocumented constructor |
2 |
38:9
|
Java Inspector 089 |
Undocumented method |
2 |
43:9
|
Java Inspector 089 |
Undocumented method |
2 |
47:9
|
Java Inspector 089 |
Undocumented method |
2 |
49:25
|
Java Inspector 040 |
Parameter name proxy clashes with field name in ProxyInvocationPump |
3 |
47:30
|
Java Inspector 051 |
It is good practice to call in any case super() in a constructor. |
3 |
38:9
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24package biz.hammurapi.util;
25
26import java.lang.reflect.InvocationHandler;
27import java.lang.reflect.Method;
28import java.lang.reflect.Proxy;
29
30
31
32
33
34public class ProxyInvocationPump extends InvocationPump implements InvocationHandler {
35 private Object proxy;
36 private final Object obj;
37
38 public ProxyInvocationPump(Object obj) {
39 this.obj=obj;
40 proxy=Proxy.newProxyInstance(obj.getClass().getClassLoader(), obj.getClass().getInterfaces(), this);
41 }
42
43 public Object getProxy() {
44 return proxy;
45 }
46
47 public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
48 Command command=new Command() {
49 protected Object execute() throws Throwable {
50 return method.invoke(obj, args);
51 }
52 };
53
54 return command.post();
55 }
56}
57