[jboss-cvs] JBossAS SVN: r71771 - projects/aop/trunk/aop/src/main/org/jboss/aop/instrument.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 7 13:03:19 EDT 2008


Author: flavia.rainone at jboss.com
Date: 2008-04-07 13:03:19 -0400 (Mon, 07 Apr 2008)
New Revision: 71771

Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java
Log:
[JBAOP-550] This caches the class names taking into account the class loaders as well.
If this fix solves the issue, we will need to replace references to class loaders by weak references.

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java	2008-04-07 16:21:18 UTC (rev 71770)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java	2008-04-07 17:03:19 UTC (rev 71771)
@@ -31,6 +31,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import javassist.CannotCompileException;
@@ -132,8 +133,8 @@
     * A cache of the generated joinpoint classes indexed by the interceptor chains for the info to 
     * avoid having to generate a new class on every single rebind
     */
-   private HashMap<String, GeneratedClassInfo> generatedJoinPointClassCache =
-      new HashMap<String, GeneratedClassInfo>();
+   private HashMap<String, Map<ClassLoader, GeneratedClassInfo>> generatedJoinPointClassCache =
+      new HashMap<String, Map<ClassLoader, GeneratedClassInfo>>();
    
    /**
     * Constructor.
@@ -270,13 +271,24 @@
 
          //Attempt to get the cached information so we don't have to recreate the class every time we rebind the joinpoint
          String infoAdviceString = info.getAdviceString();
-         GeneratedClassInfo generatedClass = generatedJoinPointClassCache.get(infoAdviceString);
+         GeneratedClassInfo generatedClass = null;
          Class<?> clazz = null;
-         if (generatedClass != null)
+         Map<ClassLoader, GeneratedClassInfo> generatedClasses = generatedJoinPointClassCache.get(infoAdviceString);
+         
+         if (generatedClasses != null)
          {
-            clazz = classloader.loadClass(generatedClass.getGenerated().getName());
+            generatedClass = generatedClasses.get(classloader);
+            if (generatedClass != null)
+            {
+               clazz = classloader.loadClass(generatedClass.getGenerated().getName());
+            }
          }
-         
+         else
+         {
+            generatedClasses = new HashMap<ClassLoader, GeneratedClassInfo>();
+            generatedJoinPointClassCache.put(infoAdviceString, generatedClasses);
+         }
+            
          if (clazz == null)
          {
             //We need to do all the work again
@@ -286,7 +298,7 @@
             
             ProtectionDomain pd = advisorClass.getProtectionDomain();
             clazz = toClass(pool, generatedClass.getGenerated(), pd);
-            generatedJoinPointClassCache.put(infoAdviceString, generatedClass);
+            generatedClasses.put(classloader, generatedClass);
          }
          Object obj = instantiateClass(clazz, generatedClass.getAroundSetups(), info);
          




More information about the jboss-cvs-commits mailing list