/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.aop.hook;

/**
 * Comment
 *
 * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
 * @version $Revision: 1.1.8.2 $
 */
public class JDK14TransformerManager
{
   public static JDK14Transformer transformer;

   public static byte[] transform(ClassLoader loader, String className, byte[] classBytes)
   {
      if (transformer == null) return null;
      if (isNonAdvisableClassName(className)) return null;

      return transformer.transform(loader, className, classBytes);
   }

   public static boolean isNonAdvisableClassName(String classname)
   {
      return (classname.startsWith("org.jboss.aop") ||
      classname.endsWith("$aop") ||
      classname.startsWith("javassist") ||
      classname.startsWith("org.jboss.util.") ||
      classname.startsWith("gnu.trove.") ||
      classname.startsWith("EDU.oswego.cs.dl.util.concurrent.") ||
      // System classes
      classname.startsWith("org.apache.crimson") ||
      classname.startsWith("org.apache.xalan") ||
      classname.startsWith("org.apache.xml") ||
      classname.startsWith("org.apache.xpath") ||
      classname.startsWith("org.ietf.") ||
      classname.startsWith("org.omg.") ||
      classname.startsWith("org.w3c.") ||
      classname.startsWith("org.xml.sax.") ||
      classname.startsWith("sunw.") ||
      classname.startsWith("sun.") ||
      classname.startsWith("java.") ||
      classname.startsWith("javax.") ||
      classname.startsWith("com.sun.")
      );
   }
}
