1 8 package org.codehaus.aspectwerkz.extension.jrockit; 9 10 import org.codehaus.aspectwerkz.hook.ClassPreProcessor; 11 import org.codehaus.aspectwerkz.hook.impl.ClassPreProcessorHelper; 12 import com.bea.jvm.JVMFactory; 13 import com.jrockit.management.rmp.RmpSocketListener; 14 15 33 public class JRockitPreProcessor implements com.bea.jvm.ClassPreProcessor { 34 35 38 private static ClassPreProcessor s_preProcessor; 39 40 private static boolean START_RMP_SERVER = false; 41 42 static { 43 String clpp = System.getProperty( 44 "aspectwerkz.classloader.preprocessor", 45 "org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor" 46 ); 47 START_RMP_SERVER = System.getProperties().containsKey("management"); 48 try { 49 s_preProcessor = ClassPreProcessorHelper.getClassPreProcessor(); 55 } catch (Exception e) { 58 throw new ExceptionInInitializerError ("could not initialize jrockit preprocessor due to: " + e.toString()); 59 } 60 } 61 62 65 public JRockitPreProcessor() { 66 if (START_RMP_SERVER) { 67 RmpSocketListener management = new RmpSocketListener(); 69 } 70 JVMFactory.getJVM().getClassLibrary().setClassPreProcessor(this); 71 } 72 73 81 public byte[] preProcess(ClassLoader caller, String name, byte[] bytecode) { 82 if (caller == null || caller.getParent() == null) { 83 return bytecode; 84 } else { 85 return s_preProcessor.preProcess(name, bytecode, caller); 86 } 87 } 88 89 92 public static void main(String args[]) throws Throwable { 93 JRockitPreProcessor pp = new JRockitPreProcessor(); Class loadedCP = Class.forName("java.math.BigDecimal"); 96 while (true) { 97 System.out.print("."); 98 104 Thread.sleep(500); 105 } 106 } 107 } | Popular Tags |