1 21 package oracle.toplink.essentials.internal.ejb.cmp3; 23 24 import java.lang.instrument.*; 25 import java.lang.reflect.Field ; 26 import java.lang.reflect.Method ; 27 28 29 39 public class JavaSECMPInitializerAgent { 40 public static void premain(String agentArgs, Instrumentation instr) throws Exception { 41 if ((agentArgs != null) && agentArgs.equals("main")) { 45 initializeFromMain(instr); 46 } else { 47 initializeFromAgent(instr); 48 } 49 } 50 51 public static void initializeFromAgent(Instrumentation instr) throws Exception { 52 Class cls = Class.forName("oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer"); 53 Method method = cls.getDeclaredMethod("initializeFromAgent", new Class [] { Instrumentation.class }); 54 method.invoke(null, new Object [] { instr }); 55 } 56 57 public static void initializeFromMain(Instrumentation instr) throws Exception { 58 Class cls = Class.forName("oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer"); 59 Field field = cls.getField("globalInstrumentation"); 60 field.set(null, instr); 61 } 62 } 63 | Popular Tags |