KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > perf > test1 > InterceptorTest


1 package test.perf.test1;
2
3 import java.lang.reflect.InvocationHandler JavaDoc;
4 import java.lang.reflect.Method JavaDoc;
5
6 import test.perf.*;
7
8 import alt.jiapi.*;
9 import alt.jiapi.reflect.*;
10 import alt.jiapi.util.*;
11 import alt.jiapi.interceptor.*;
12
13 /**
14  * Class tc1.
15  *
16  * @author Mika Riekkinen
17  */

18 public class InterceptorTest extends AbstractTest implements InvocationHandler JavaDoc{
19     private InstrumentationContext ctx;
20     Object JavaDoc foo;
21
22     public void init() {
23         try {
24             ctx = new InstrumentationContext();
25             InstrumentationDescriptor id = new InstrumentationDescriptor();
26             id.addInclusionRule("test.perf.*");
27             ctx.addInstrumentationDescriptor(id);
28             
29             InvocationInterceptor ii =
30                 new InvocationInterceptor(id, "test.perf.Foo*",this);
31         }
32         catch(Exception JavaDoc e) {
33             System.out.println("ERROR: " + e);
34         }
35     }
36
37     public void test(int lCount) throws Exception JavaDoc {
38         Bootstrapper.launch("test.perf.Foo", null, ctx,
39                             InstrumentingClassLoader.createClassLoader(ctx));
40     }
41
42     public Object JavaDoc invoke(Object JavaDoc o, Method JavaDoc m, Object JavaDoc[] args) throws Exception JavaDoc {
43         return m.invoke(o, args);
44     }
45 }
46
Popular Tags