0 Replies Latest reply on May 3, 2005 5:48 PM by icecrash

    how i can use metaobject for intercept method invocation?

    icecrash

      i have a test class named prova;
      i want run class prova and intercept methos invocation,field reading,writing,and object instantiation.
      I write this the follow code:

      try{
       javassit.reflect.Loader cl = new javassit.reflect.Loader();
       cl.makeReflective("prova","VerboseMO","javassist.reflect.ClassMetaobject");
      cl.run("prova",args);
       }
      cath(Throeable e){}
      


      and the class VerboseMO:

      class VerboseMO extends Metaobject
      {
       public VerboseMO(Object base,Object args[])
       {
       super(base,args);
       System.out.println("Reflective Output: New instance of:"+base.getClass().getName()+"created");
       }
      
       public Object trapFieldRead(String name)
       {
      
       }
      
       public Object trapMethodcall(int id, Object[] args)
       {
      
       }
      
      }
      
      


      this code work ,but do not know how i can intercept method call and feild call:read or write.

      Can anyone help me?