KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > FieldEventTest


1 package test;
2
3 import alt.jiapi.event.FieldEventProducer;
4 import alt.jiapi.event.FieldListener;
5 import alt.jiapi.event.FieldEvent;
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 FieldEventTest extends InstrumentorTest implements FieldListener {
14     public static void main(String JavaDoc [] args) throws Exception JavaDoc {
15         FieldEventTest ft = new FieldEventTest();
16         ft.run(args);
17     }
18
19     public FieldEventTest() throws JiapiException {
20         InstrumentationDescriptor id = new InstrumentationDescriptor();
21         ctx.addInstrumentationDescriptor(id);
22
23         addInclusionRules(id, getInclusionRules());
24         addExclusionRules(id, getExclusionRules());
25
26         FieldEventProducer fep =
27             new FieldEventProducer(id, System.getProperty("resolution", "*"));
28
29         fep.addFieldListener(this);
30     }
31
32     // --- Interface FieldListener ---
33
public void fieldGet(FieldEvent event) {
34         System.out.println("Field get : " + event);
35     }
36
37     public void fieldSet(FieldEvent event) {
38         System.out.println("Field set : " + event);
39     }
40
41     public void fieldChanging(FieldEvent event) {
42         System.out.println("Field changing : " + event);
43     }
44
45
46     // Default test case name
47
public String JavaDoc defaultClassName() {
48         return "test.GetSet";
49     }
50 }
51
Popular Tags