/Users/lyon/j4p/src/javassist/sample/reflect/VerboseMetaobj.java

1    package javassist.sample.reflect; 
2     
3    import javassist.*; 
4    import javassist.reflect.*; 
5     
6    public class VerboseMetaobj extends Metaobject { 
7        public VerboseMetaobj(Object self, Object[] args) { 
8            super(self, args); 
9            System.out.println("** constructed: " + 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   } 
29