package test;
import alt.jiapi.event.MethodEventProducer;
import alt.jiapi.event.MethodListener;
import alt.jiapi.event.MethodEvent;
import alt.jiapi.*;
/**
* This class is mainly used to test Jiapi event model.
* In addition to that, it servers as an example to using
* Jiapi event model.
*/
public class EventTest extends InstrumentorTest implements MethodListener {
public static void main(String [] args) throws Exception {
EventTest et = new EventTest();
et.run(args);
}
public EventTest() throws JiapiException {
InstrumentationDescriptor id = new InstrumentationDescriptor();
ctx.addInstrumentationDescriptor(id);
addInclusionRules(id, getInclusionRules());
addExclusionRules(id, getExclusionRules());
MethodEventProducer mep =
new MethodEventProducer(id, System.getProperty("resolution", "*"));
// System.out.println("MEP: " + mep.getClass().getClassLoader());
// System.out.println("ET: " + getClass().getClassLoader());
mep.addMethodListener(this);
}
// --- Interface MethodListener ---
public void methodEntered (MethodEvent event) {
System.out.println("Method entered : " + event);
}
public void methodExited (MethodEvent event) {
System.out.println("Method exited : " + event);
}
}