1 package samples.example1; 2 3 import alt.jiapi.InstrumentationContext; 4 import alt.jiapi.InstrumentationDescriptor; 5 import alt.jiapi.event.MethodEvent; 6 import alt.jiapi.event.MethodEventProducer; 7 import alt.jiapi.event.MethodListener; 8 import alt.jiapi.util.Bootstrapper; 9 10 public class Example1 implements MethodListener { 11 public static void main(String args[]) throws Exception { 12 new Example1(); 13 } 14 15 public Example1() throws Exception { 16 InstrumentationContext ctx = new InstrumentationContext(); 18 InstrumentationDescriptor id = new InstrumentationDescriptor(); 19 id.addInclusionRule("test.*"); 20 ctx.addInstrumentationDescriptor(id); 21 22 MethodEventProducer eventProducer = new MethodEventProducer(id); 24 eventProducer.addMethodListener(this); 25 26 Bootstrapper.launch("test.Foo", null, ctx, 28 getClass().getClassLoader()); 29 } 30 31 public void methodEntered(MethodEvent event) { 32 System.out.println("Method " + event.getClassName() + "." + 33 event.getMethodName() + " entered."); 34 } 35 36 public void methodExited(MethodEvent event) { 37 System.out.println("Method " + event.getClassName() + "." + 38 event.getMethodName() + " exited."); 39 } 40 } 41 | Popular Tags |