1 22 package org.jboss.aop.standalone; 23 24 import org.jboss.aop.AspectManager; 25 26 import java.lang.instrument.ClassFileTransformer ; 27 import java.lang.instrument.IllegalClassFormatException ; 28 import java.security.ProtectionDomain ; 29 30 36 public class AOPTransformer implements ClassFileTransformer 37 { 38 public boolean isNonAdvisableClassName(String classname) 39 { 40 return (classname.startsWith("org.jboss.aop") || 41 classname.endsWith("$aop") || 42 classname.startsWith("javassist") || 43 classname.startsWith("org.jboss.util.") || 44 classname.startsWith("gnu.trove.") || 45 classname.startsWith("EDU.oswego.cs.dl.util.concurrent.") || 46 classname.startsWith("org.apache.crimson") || 48 classname.startsWith("org.apache.xalan") || 49 classname.startsWith("org.apache.xml") || 50 classname.startsWith("org.apache.xpath") || 51 classname.startsWith("org.ietf.") || 52 classname.startsWith("org.omg.") || 53 classname.startsWith("org.w3c.") || 54 classname.startsWith("org.xml.sax.") || 55 classname.startsWith("sunw.") || 56 classname.startsWith("sun.") || 57 classname.startsWith("java.") || 58 classname.startsWith("javax.") || 59 classname.startsWith("com.sun.") 60 ); 61 } 62 63 public byte[] transform(ClassLoader loader, String className, Class <?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException 64 { 65 className = className.replace('/', '.'); 66 try 68 { 69 if (classBeingRedefined != null || isNonAdvisableClassName(className)) 70 { 71 return null; 73 } 74 return aspectTransform(className, loader, classBeingRedefined, protectionDomain, classfileBuffer); 76 } 77 finally 78 { 79 } 81 } 82 83 private byte[] aspectTransform(String className, ClassLoader loader, Class <?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) 84 { 85 try 86 { 87 return AspectManager.instance(loader).transform(loader, className, classBeingRedefined, protectionDomain, classfileBuffer); 89 } 90 catch (Exception e) 91 { 92 throw new RuntimeException (e); 93 } 94 } 95 } 96 | Popular Tags |