Package samples.example1

Source Code of samples.example1.Example1

package samples.example1;

import alt.jiapi.InstrumentationContext;
import alt.jiapi.InstrumentationDescriptor;
import alt.jiapi.event.MethodEvent;
import alt.jiapi.event.MethodEventProducer;
import alt.jiapi.event.MethodListener;
import alt.jiapi.util.Bootstrapper;

public class Example1 implements MethodListener {
    public static void main(String args[]) throws Exception {
        new Example1();
    }
   
    public Example1() throws Exception {
        // Configure:
        InstrumentationContext ctx = new InstrumentationContext();
        InstrumentationDescriptor id = new InstrumentationDescriptor();
        id.addInclusionRule("test.*");
        ctx.addInstrumentationDescriptor(id);
       
        // Use event API:
        MethodEventProducer eventProducer = new MethodEventProducer(id);
        eventProducer.addMethodListener(this);
       
        // Launch:
        Bootstrapper.launch("test.Foo", null, ctx,
                            getClass().getClassLoader());
    }
      
    public void methodEntered(MethodEvent event) {
        System.out.println("Method " + event.getClassName() + "." +
                           event.getMethodName() + " entered.");
    }
      
    public void methodExited(MethodEvent event) {
        System.out.println("Method " + event.getClassName() + "." +
                           event.getMethodName() + " exited.");
    }
}
TOP

Related Classes of samples.example1.Example1

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.