1 8 package org.codehaus.aspectwerkz.transform.inlining.deployer; 9 10 import org.codehaus.aspectwerkz.util.ContextClassLoader; 11 import org.codehaus.aspectwerkz.exception.WrappedRuntimeException; 12 13 18 public class RedefinerFactory { 19 private static final String HOTSWAP_REDEFINER_CLASS_NAME = 20 "org.codehaus.aspectwerkz.extension.hotswap.HotSwapRedefiner"; 21 22 private static final String JVMTI_REDEFINER_CLASS_NAME = 23 "org.codehaus.aspectwerkz.hook.JVMTIRedefiner"; 24 25 32 public static Redefiner newRedefiner(final Type type) { 33 if (type.equals(Type.HOTSWAP)) { 34 try { 35 Class redefinerClass = ContextClassLoader.forName(JVMTI_REDEFINER_CLASS_NAME); 36 return (Redefiner) redefinerClass.newInstance(); 37 } catch (Throwable t) { 38 try { 39 Class redefinerClass = ContextClassLoader.forName(HOTSWAP_REDEFINER_CLASS_NAME); 40 return (Redefiner) redefinerClass.newInstance(); 41 } catch (ClassNotFoundException e) { 42 throw new WrappedRuntimeException( 44 "redefiner class [HotSwapRedefiner] could not be found on classpath, make sure you have the aspectwerkz extensions jar file in your classpath", 45 e 46 ); 47 } catch (Exception e) { 48 throw new WrappedRuntimeException("redefiner class [HotSwapRedefiner] could not be instantiated", e); 50 } 51 } 52 53 } else if (type.equals(Type.JVMTI)) { 54 throw new UnsupportedOperationException ("JVMTI is not supported yet"); 55 } else { 56 throw new UnsupportedOperationException ("unknown redefiner type: " + type.toString()); 57 } 58 } 59 60 65 public static class Type { 66 public static final Type HOTSWAP = new Type("HOTSWAP"); 67 public static final Type JVMTI = new Type("JVMTI"); 68 69 private final String m_name; 70 71 private Type(String name) { 72 m_name = name; 73 } 74 75 public String toString() { 76 return m_name; 77 } 78 } 79 } 80 | Popular Tags |