01: package sample.reflect;
02:
03: import javassist.tools.reflect.*;
04:
05: public class VerboseMetaobj extends Metaobject {
06: public VerboseMetaobj(Object self, Object[] args) {
07: super (self, args);
08: System.out.println("** constructed: "
09: + self.getClass().getName());
10: }
11:
12: public Object trapFieldRead(String name) {
13: System.out.println("** field read: " + name);
14: return super .trapFieldRead(name);
15: }
16:
17: public void trapFieldWrite(String name, Object value) {
18: System.out.println("** field write: " + name);
19: super .trapFieldWrite(name, value);
20: }
21:
22: public Object trapMethodcall(int identifier, Object[] args)
23: throws Throwable {
24: System.out.println("** trap: " + getMethodName(identifier)
25: + "() in " + getClassMetaobject().getName());
26: return super.trapMethodcall(identifier, args);
27: }
28: }
|