1 4 package com.tc.aspectwerkz.transform.inlining.deployer; 5 6 7 import com.tc.aspectwerkz.exception.WrappedRuntimeException; 8 import com.tc.aspectwerkz.util.ContextClassLoader; 9 10 15 public class RedefinerFactory { 16 private static final String HOTSWAP_REDEFINER_CLASS_NAME = 17 "com.tc.aspectwerkz.extension.hotswap.HotSwapRedefiner"; 18 19 private static final String JVMTI_REDEFINER_CLASS_NAME = 20 "com.tc.aspectwerkz.hook.JVMTIRedefiner"; 21 22 28 public static Redefiner newRedefiner(final Type type) { 29 if (type.equals(Type.HOTSWAP)) { 30 try { 31 Class redefinerClass = ContextClassLoader.forName(JVMTI_REDEFINER_CLASS_NAME); 32 return (Redefiner) redefinerClass.newInstance(); 33 } catch (Throwable t) { 34 try { 35 Class redefinerClass = ContextClassLoader.forName(HOTSWAP_REDEFINER_CLASS_NAME); 36 return (Redefiner) redefinerClass.newInstance(); 37 } catch (ClassNotFoundException e) { 38 throw new WrappedRuntimeException( 40 "redefiner class [HotSwapRedefiner] could not be found on classpath, make sure you have the aspectwerkz extensions jar file in your classpath", 41 e 42 ); 43 } catch (Exception e) { 44 throw new WrappedRuntimeException("redefiner class [HotSwapRedefiner] could not be instantiated", e); 46 } 47 } 48 49 } else if (type.equals(Type.JVMTI)) { 50 throw new UnsupportedOperationException ("JVMTI is not supported yet"); 51 } else { 52 throw new UnsupportedOperationException ("unknown redefiner type: " + type.toString()); 53 } 54 } 55 56 61 public static class Type { 62 public static final Type HOTSWAP = new Type("HOTSWAP"); 63 public static final Type JVMTI = new Type("JVMTI"); 64 65 private final String m_name; 66 67 private Type(String name) { 68 m_name = name; 69 } 70 71 public String toString() { 72 return m_name; 73 } 74 } 75 } 76 | Popular Tags |