KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > MCITest


1 package test;
2
3 import alt.jiapi.InstrumentationDescriptor;
4 import alt.jiapi.Instrumentor;
5 import alt.jiapi.InstrumentorChain;
6 import alt.jiapi.JiapiException;
7 import alt.jiapi.instrumentor.*;
8
9 /**
10  * Class description. MCITest
11  * @author Mika Riekkinen
12  */

13 public class MCITest extends InstrumentorTest {
14     public static void main(String JavaDoc [] args) throws Exception JavaDoc {
15         MCITest mci = new MCITest();
16         mci.run(args);
17     }
18
19     public MCITest() throws JiapiException {
20         InstrumentorChain chain = new InstrumentorChain();
21
22         Instrumentor dispatcher = new MethodDispatcherInstrumentor();
23         Instrumentor si = new GrepInstrumentor(new MethodCallStrategy());
24         TailInstrumentor after = new TailInstrumentor();
25         MethodCallInstrumentor mci = new MethodCallInstrumentor(this);
26
27         chain.add(dispatcher);
28         chain.add(si); // Split (method call)
29
chain.add(after); // BEFORE, AFTER or AROUND
30
chain.add(mci); // make a method call
31

32         InstrumentationDescriptor id = new InstrumentationDescriptor();
33         addInclusionRules(id, getInclusionRules());
34         addExclusionRules(id, getExclusionRules());
35         id.addChain(chain);
36
37         ctx.addInstrumentationDescriptor(id);
38     }
39
40     // Overriding hookMethod(String, String)
41
public void hookMethod(Object JavaDoc _this, String JavaDoc m) {
42         System.out.println("Just called " + m);
43     }
44 }
45
Popular Tags