Package org.jboss.aop.classpool

Examples of org.jboss.aop.classpool.AOPClassPool


   protected static String createOptimizedInvocationClass(Instrumentor instrumentor,
         CtClass clazz, CtConstructor con, int index)
   throws NotFoundException, CannotCompileException
   {
      AOPClassPool pool = (AOPClassPool) instrumentor.getClassPool();
      CtClass conInvocation = pool.get("org.jboss.aop.joinpoint.ConstructorInvocation");

      ////////////////
      //Create the class
      String className = getOptimizedInvocationClassName(clazz, index);
      boolean makeInnerClass = true;//!Modifier.isPublic(con.getModifiers());
View Full Code Here


   {
      boolean converted = false;
      String ref = null;
      try
      {
         AOPClassPool pool = AOPClassPool.createAOPClassPool(clazz.getClassPool(), AOPClassPoolRepository.getInstance());

         //Class.getRefClasses() only gets classes explicitly referenced in the class. We need to check the super classes and do some extra handling
         for (ReferenceClassIterator it = new ReferenceClassIterator(clazz.getRefClasses()) ; it.hasNext() ; )
         {
            ref = it.next();
            if (!manager.getInterceptionMarkers(clazz.getClassPool().getClassLoader()).convertReference(ref)
                || manager.isNonAdvisableClassName(ref)
                || ref.startsWith("java.")
                || ref.startsWith("javax.")
                || ref.startsWith("["))
            {
               continue;
            }
            // Only need a temporary advisor for resolving metadata
            CtClass ctRef = null;
            ClassAdvisor advisor = null;
            if (ref.equals(clazz.getName()))
            {
               ctRef = clazz;
               advisor = clazzAdvisor;
            }
            else
            {
               try
               {
                  ctRef = pool.get(ref);
               }
               catch (NotFoundException e)
               {
                  if (AspectManager.suppressReferenceErrors)
                  {
View Full Code Here

         constructorExecutionTransformer.codeConverted();

         // registers the classes bytecodes to be hot swapped
         for (CtClass clazz : classes)
         {
            AOPClassPool classPool = (AOPClassPool) clazz.getClassPool();
            clazz.defrost();
            hotSwapper.registerChange(classPool.getClassLoader().loadClass(clazz.getName()),
                  clazz.toBytecode());
         }
         // performs the hot swap of registered classes
         hotSwapper.hotSwap();
      }
View Full Code Here

    * dynamicaly wrapped.
    */
   public void convertProcessedClasses(HotSwapper hotSwapper, CtClass clazz,
         Collection<CtField> fieldReads, Collection<CtField> fieldWrites, boolean constructor)
   {
      AOPClassPool classPool = (AOPClassPool) clazz.getClassPool();
      CodeConverter codeConverter = new CodeConverter();
      for (CtField field : fieldReads)
      {
         codeConverter.replaceFieldRead(field, clazz, FieldAccessTransformer.fieldRead(field.getName()));
      }
      for (CtField field : fieldWrites)
      {
         codeConverter.replaceFieldWrite(field, clazz, FieldAccessTransformer.fieldWrite(field.getName()));
      }
      if (constructor)
      {
         codeConverter.replaceNew(clazz, clazz, ConstructorExecutionTransformer.constructorFactory(clazz.getSimpleName()));
      }

      synchronized(processedClasses)
      {
      for (CtClass processedClass : processedClasses)
      {
         if (processedClass == clazz)
            continue;
         if (processedClass.getRefClasses() == null ||
                ! clazz.getRefClasses().contains(clazz.getName()))
          {
             continue;
          }
          try
          {
             processedClass.defrost();
             byte[] previousByteCode = processedClass.toBytecode();
             processedClass.defrost();
             processedClass.instrument(codeConverter);
             byte[] updatedByteCode = processedClass.toBytecode();
             if (!java.util.Arrays.equals(updatedByteCode, previousByteCode))
             {
               hotSwapper.registerChange(classPool.getClassLoader().loadClass(processedClass.getName()), updatedByteCode);
             }
             processedClass.defrost();
          }
          catch (Exception e)
          {
View Full Code Here

   private static String createOptimizedMethodCalledInvocationClass(
         Instrumentor instrumentor, String className, CtClass callingClass,
         CtMethod method, String invocationClassName, String callerDescription)
   throws NotFoundException, CannotCompileException
   {
      AOPClassPool pool = (AOPClassPool) instrumentor.getClassPool();
      CtClass methodInvocation = pool.get(invocationClassName);
  
      ////////////////
      //Create the class
      CtClass invocation = makeInvocationClass(pool,
            Modifier.isPrivate(method.getModifiers()), callingClass, className,
View Full Code Here

   private static String createOptimizedConCalledInvocationClass(
         Instrumentor instrumentor, String className, CtClass callingClass,
         CtConstructor con, String invocationClassName, String callerDescription)
   throws NotFoundException, CannotCompileException
   {
      AOPClassPool pool = (AOPClassPool) instrumentor.getClassPool();
      CtClass conInvocation = pool.get(invocationClassName);
  
      ////////////////
      //Create the class
      CtClass invocation = makeInvocationClass(pool,
            Modifier.isPrivate(con.getModifiers()), callingClass, className,
View Full Code Here

   {
      boolean converted = false;
      String ref = null;
      try
      {
         AOPClassPool pool = AOPClassPool.createAOPClassPool(clazz.getClassPool(), AOPClassPoolRepository.getInstance());

         //Class.getRefClasses() only gets classes explicitly referenced in the class. We need to check the super classes and do some extra handling
         for (ReferenceClassIterator it = new ReferenceClassIterator(clazz.getRefClasses()) ; it.hasNext() ; )
         {
            ref = it.next();
            if (!manager.getInterceptionMarkers().convertReference(ref)
                || manager.isNonAdvisableClassName(ref)
                || ref.startsWith("java.")
                || ref.startsWith("javax.")
                || ref.startsWith("["))
            {
               continue;
            }
            // Only need a temporary advisor for resolving metadata
            CtClass ctRef = null;
            try
            {
               ctRef = pool.get(ref);
            }
            catch (NotFoundException e)
            {
               if (AspectManager.suppressReferenceErrors)
               {
View Full Code Here

         // registers the classes bytecodes to be hot swapped
         for (Iterator iterator = classes.iterator(); iterator.hasNext(); )
         {
            CtClass clazz = (CtClass) iterator.next();
            AOPClassPool classPool = (AOPClassPool) clazz.getClassPool();
            clazz.defrost();
            hotSwapper.registerChange(classPool.getClassLoader().loadClass(clazz.getName()),
                  clazz.toBytecode());
         }
         // performs the hot swap of registered classes
         hotSwapper.hotSwap();
      }
View Full Code Here

    * dynamicaly wrapped.
    */
   public void convertProcessedClasses(HotSwapper hotSwapper, CtClass clazz,
         Collection fieldReads, Collection fieldWrites, boolean constructor)
   {
      AOPClassPool classPool = (AOPClassPool) clazz.getClassPool();
      CodeConverter codeConverter = new CodeConverter();
      for (Iterator iterator = fieldReads.iterator(); iterator.hasNext(); )
      {
         CtField field = (CtField) iterator.next();
         codeConverter.replaceFieldRead(field, clazz, fieldAccessTransformer.fieldRead(field.getName()));
      }
      for (Iterator iterator = fieldWrites.iterator(); iterator.hasNext(); )
      {
         CtField field = (CtField) iterator.next();
         codeConverter.replaceFieldWrite(field, clazz, fieldAccessTransformer.fieldWrite(field.getName()));
      }
      if (constructor)
      {
         codeConverter.replaceNew(clazz, clazz, ConstructorExecutionTransformer.constructorFactory(clazz.getSimpleName()));
      }

      synchronized(processedClasses)
      {
      for (Iterator iterator = processedClasses.iterator(); iterator.hasNext();)
      {
         CtClass processedClass = (CtClass) iterator.next();
         if (processedClass == clazz)
            continue;
         if (processedClass.getRefClasses() == null ||
                ! clazz.getRefClasses().contains(clazz.getName()))
          {
             continue;
          }
          try
          {
             processedClass.defrost();
             byte[] previousByteCode = processedClass.toBytecode();
             processedClass.defrost();
             processedClass.instrument(codeConverter);
             byte[] updatedByteCode = processedClass.toBytecode();
             if (!java.util.Arrays.equals(updatedByteCode, previousByteCode))
             {
               hotSwapper.registerChange(classPool.getClassLoader().loadClass(processedClass.getName()), updatedByteCode);
             }
             processedClass.defrost();
          }
          catch (Exception e)
          {
View Full Code Here

         if (manager.isNonAdvisableClassName(className))
         {
            return null;
         }

         AOPClassPool pool = (AOPClassPool) manager.registerClassLoader(loader);

         CtClass clazz = obtainCtClassInfo(pool, className, classfileBuffer);
        
         CtClass woven = instrumentClass(manager, pool, clazz, true);
         if (woven != null)
         {
            pool.lockInCache(woven);
            if (AspectManager.debugClasses)
            {
               SecurityActions.debugWriteFile(clazz);
            }
            byte[] rtn = woven.toBytecode();
            if (AspectManager.getPrune()) woven.prune();
            return rtn;
         }
         else
         {
            pool.soften(clazz);
         }
         return null;
      }
      catch (Exception ex)
      {
View Full Code Here

TOP

Related Classes of org.jboss.aop.classpool.AOPClassPool

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.