KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > EventTest


1 package test;
2
3 import alt.jiapi.event.MethodEventProducer;
4 import alt.jiapi.event.MethodListener;
5 import alt.jiapi.event.MethodEvent;
6 import alt.jiapi.*;
7
8 /**
9  * This class is mainly used to test Jiapi event model.
10  * In addition to that, it servers as an example to using
11  * Jiapi event model.
12  */

13 public class EventTest extends InstrumentorTest implements MethodListener {
14     public static void main(String JavaDoc [] args) throws Exception JavaDoc {
15         EventTest et = new EventTest();
16         et.run(args);
17     }
18
19     public EventTest() throws JiapiException {
20         InstrumentationDescriptor id = new InstrumentationDescriptor();
21         ctx.addInstrumentationDescriptor(id);
22
23         addInclusionRules(id, getInclusionRules());
24         addExclusionRules(id, getExclusionRules());
25
26         MethodEventProducer mep =
27             new MethodEventProducer(id, System.getProperty("resolution", "*"));
28
29 // System.out.println("MEP: " + mep.getClass().getClassLoader());
30
// System.out.println("ET: " + getClass().getClassLoader());
31

32         mep.addMethodListener(this);
33     }
34
35     // --- Interface MethodListener ---
36
public void methodEntered (MethodEvent event) {
37         System.out.println("Method entered : " + event);
38     }
39
40     public void methodExited (MethodEvent event) {
41         System.out.println("Method exited : " + event);
42     }
43 }
44
Popular Tags