Package org.jboss.aop.classpool

Examples of org.jboss.aop.classpool.AOPClassPool


   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,
            true /*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())*/ true, callingClass, className,
View Full Code Here

      }

      private void replaceReferences(final CtClass clazz) throws Exception
      {
         CodeConverter conv = new CodeConverter();
         AOPClassPool pool = AOPClassPool
               .createAOPClassPool(clazz.getClassPool(), AOPClassPoolRepository.getInstance());
         Collection<String> refs = AccessController.doPrivileged(new PrivilegedAction<Collection<String>>() {

            public Collection<String> run()
            {
               return clazz.getRefClasses();
            }});
        
         for (String ref : refs)
         {
            if (ref.startsWith(PACKAGE_REPLACEMENT_CHILD) || ref.startsWith(PACKAGE_REPLACEMENT_PARENT))
            {
               if (ref.endsWith("Caller"))
               {
                  continue;
               }
               CtClass ctRef = pool.get(ref);
               CtField[] fields = ctRef.getDeclaredFields();
               for (CtField fld : fields)
               {
                  conv.replaceFieldRead(fld, ctRef, getFieldReadWrapperName(fld.getName()));
                  conv.replaceFieldWrite(fld, ctRef, getFieldWriteWrapperName(fld.getName()));
View Full Code Here

   {
      for (Iterator iterator = methodInfos.iterator(); iterator.hasNext();)
      {
         org.jboss.aop.MethodInfo methodInfo = (org.jboss.aop.MethodInfo) iterator.next();
         Method method = methodInfo.getMethod();
         AOPClassPool classPool = (AOPClassPool) clazz.getClassPool();
         Class[] parameterTypes = method.getParameterTypes();
         CtClass[] javassistParameterTypes = new CtClass[parameterTypes.length];
         for (int i = 0; i < parameterTypes.length; i++)
         {
            classPool.getLocally(parameterTypes[i].getName());
         }
         if (method.getName().indexOf("access$") >= 0)
         {
            continue;
         }
View Full Code Here

   {
      for (Iterator iterator = methodInfos.iterator(); iterator.hasNext();)
      {
         org.jboss.aop.MethodInfo methodInfo = (org.jboss.aop.MethodInfo) iterator.next();
         Method method = methodInfo.getMethod();
         AOPClassPool classPool = (AOPClassPool) clazz.getClassPool();
         Class[] parameterTypes = method.getParameterTypes();
         CtClass[] javassistParameterTypes = new CtClass[parameterTypes.length];
         for (int i = 0; i < parameterTypes.length; i++)
         {
            classPool.getLocally(parameterTypes[i].getName());
         }
         CtMethod javassistWMethod = clazz.getDeclaredMethod(method.getName(), javassistParameterTypes);
         if (wrapper.isNotPrepared(javassistWMethod, WrapperTransformer.SINGLE_TRANSFORMATION_INDEX))
         {
            continue;
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

   {
      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

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.