[jboss-cvs] JBossAS SVN: r66479 - in projects/aop/trunk/aop/src/main/org/jboss/aop: annotation and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 26 05:41:18 EDT 2007


Author: kabir.khan at jboss.com
Date: 2007-10-26 05:41:18 -0400 (Fri, 26 Oct 2007)
New Revision: 66479

Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/GeneratedClassAdvisor.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/annotation/AnnotationRepository.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/metadata/MethodMetaData.java
Log:
More concurrency fixes

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java	2007-10-26 09:40:44 UTC (rev 66478)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java	2007-10-26 09:41:18 UTC (rev 66479)
@@ -127,8 +127,8 @@
    protected ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
 
    protected HashSet adviceBindings = new HashSet();
-   protected ArrayList interfaceIntroductions = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-   protected ArrayList classMetaDataBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+   protected volatile ArrayList interfaceIntroductions = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+   protected volatile ArrayList classMetaDataBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
    protected SimpleMetaData defaultMetaData = new SimpleMetaData();
    protected MethodMetaData methodMetaData = new MethodMetaData();
    protected FieldMetaData fieldMetaData = new FieldMetaData();
@@ -142,11 +142,11 @@
    protected String name;
    protected ConcurrentHashMap aspects = new ConcurrentHashMap();
    protected HashMap adviceInterceptors = new HashMap();
-   protected CopyOnWriteArraySet perInstanceAspectDefinitions = UnmodifiableEmptyCollections.EMPTY_COPYONWRITE_ARRAYSET;
-   protected ConcurrentHashMap perInstanceJoinpointAspectDefinitions = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   protected volatile CopyOnWriteArraySet perInstanceAspectDefinitions = UnmodifiableEmptyCollections.EMPTY_COPYONWRITE_ARRAYSET;
+   protected volatile ConcurrentHashMap perInstanceJoinpointAspectDefinitions = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
 
    static Class cl = java.lang.String.class;
-   protected TLongObjectHashMap advisedMethods = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
+   protected volatile TLongObjectHashMap advisedMethods = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
    // The method signatures are sorted at transformation and load time to
    // make sure the tables line up.
    //Common sense suggests that this should be lazily initialised for generated advisors, profiling shows that is a major performance hit...

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java	2007-10-26 09:40:44 UTC (rev 66478)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java	2007-10-26 09:41:18 UTC (rev 66479)
@@ -114,49 +114,49 @@
    protected final WeakHashMap advisors = new WeakHashMap();
    
    /** A map of domains by class, maintaned by the top level AspectManager */
-   protected WeakHashMap subDomainsPerClass = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
+   protected volatile WeakHashMap subDomainsPerClass = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
    
    /** A map of domains by name */
-   protected WeakValueHashMap subDomainsByName = UnmodifiableEmptyCollections.EMPTY_WEAK_VALUE_HASHMAP;
+   protected volatile WeakValueHashMap subDomainsByName = UnmodifiableEmptyCollections.EMPTY_WEAK_VALUE_HASHMAP;
 
    /** Each domain may have sub domains interested in changes happening in this manager/domain */
-   protected WeakHashMap subscribedSubDomains = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
+   protected volatile WeakHashMap subscribedSubDomains = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
 
    /** A queue for adding new subscribed subdomains to */
-   protected WeakHashMap subscribedSubDomainsQueue = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
+   protected volatile WeakHashMap subscribedSubDomainsQueue = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
    protected int subscribedDomainQueueRef;
 
-   protected LinkedHashMap interfaceIntroductions = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected LinkedHashMap arrayReplacements = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected LinkedHashMap arrayBindings = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected LinkedHashMap annotationIntroductions =UnmodifiableEmptyCollections. EMPTY_LINKED_HASHMAP;
-   protected LinkedHashMap annotationOverrides = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected LinkedHashMap bindings = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected LinkedHashMap typedefs = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected HashMap interceptorFactories = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
-   protected HashMap classMetaDataLoaders = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
-   protected HashMap interceptorStacks = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
-   protected HashMap declares = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
-   protected ConcurrentHashMap cflowStacks = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
-   protected ConcurrentHashMap dynamicCFlows = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
-   protected ConcurrentHashMap aspectDefinitions = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
-   protected ConcurrentHashMap perVMAspects = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   protected volatile LinkedHashMap interfaceIntroductions = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap arrayReplacements = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap arrayBindings = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap annotationIntroductions =UnmodifiableEmptyCollections. EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap annotationOverrides = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap bindings = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap typedefs = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile HashMap interceptorFactories = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+   protected volatile HashMap classMetaDataLoaders = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+   protected volatile HashMap interceptorStacks = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+   protected volatile HashMap declares = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+   protected volatile ConcurrentHashMap cflowStacks = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   protected volatile ConcurrentHashMap dynamicCFlows = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   protected volatile ConcurrentHashMap aspectDefinitions = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   protected volatile ConcurrentHashMap perVMAspects = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
 
    /** class name prefixes to explicitly exclude unless contained in include. Maintained by top-level AspectManager */
-   protected ArrayList exclude = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+   protected volatile ArrayList exclude = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
 
    /** class name prefixes to explicitly include, this overrides whatever was set in exclude. Maintained by top-level AspectManager */
-   protected ArrayList include = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+   protected volatile ArrayList include = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
 
    /** A set of wildcard enabled classnames that will be ignored no matter if they have been included. Maintained by top-level AspectManager */
-   protected ArrayList ignore = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+   protected volatile ArrayList ignore = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
 
    /** ClassExpressions built from ignore. Maintained by top-level AspectManager */
    protected ClassExpression[] ignoreExpressions = new ClassExpression[0];
 
-   protected LinkedHashMap pointcuts = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap pointcuts = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
    // contains pointcuts-binding association info
-   protected LinkedHashMap pointcutInfos = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap pointcutInfos = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
    // these fields represent whether there are certain pointcut types.
    // for performance reasons the transformers and binders can make a lot of us of this.
    protected boolean execution = false;
@@ -168,9 +168,9 @@
    protected boolean withincode = false;
    public static boolean classicOrder = false;
 
-   protected LinkedHashMap classMetaData = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected HashMap containers = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
-   protected LinkedHashMap precedenceDefs = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap classMetaData = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile HashMap containers = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+   protected volatile LinkedHashMap precedenceDefs = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
    protected PrecedenceDefEntry[] sortedPrecedenceDefEntries;
    protected WeavingStrategy weavingStrategy;
 

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java	2007-10-26 09:40:44 UTC (rev 66478)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java	2007-10-26 09:41:18 UTC (rev 66479)
@@ -1991,9 +1991,9 @@
    
    private class MethodByMethodData
    {
-      private TLongObjectHashMap methodCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
-      private HashMap backrefMethodCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
-      private TLongObjectHashMap methodCalledByMethodInterceptors = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
+      private volatile TLongObjectHashMap methodCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
+      private volatile HashMap backrefMethodCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+      private volatile TLongObjectHashMap methodCalledByMethodInterceptors = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
 
       public TLongObjectHashMap getMethodCalledByMethodInterceptors()
       {
@@ -2248,9 +2248,9 @@
    private class ConByMethodData
    {
       // constructor caller pointcut support for methods calling constructors only
-      private TLongObjectHashMap conCalledByMethodBindings = new TLongObjectHashMap();
-      private HashMap backrefConCalledByMethodBindings = new HashMap();
-      private TLongObjectHashMap conCalledByMethodInterceptors = new TLongObjectHashMap();
+      private volatile TLongObjectHashMap conCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
+      private volatile HashMap backrefConCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+      private volatile TLongObjectHashMap conCalledByMethodInterceptors = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
       
       public TLongObjectHashMap getConCalledByMethodInterceptors()
       {

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/GeneratedClassAdvisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/GeneratedClassAdvisor.java	2007-10-26 09:40:44 UTC (rev 66478)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/GeneratedClassAdvisor.java	2007-10-26 09:41:18 UTC (rev 66479)
@@ -1277,7 +1277,11 @@
          {
             generator = new MethodJoinPointGenerator(GeneratedClassAdvisor.this, info);
             initJoinPointGeneratorsMap();
-            joinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
+            MethodJoinPointGenerator existing = (MethodJoinPointGenerator)joinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
+            if (existing != null)
+            {
+               generator = existing;
+            }
          }
          return generator;
       }
@@ -1291,7 +1295,11 @@
             {
                generator = new FieldJoinPointGenerator(GeneratedClassAdvisor.this, info);
                initFieldReadJoinPointGeneratorsMap();
-               fieldReadJoinPoinGenerators.putIfAbsent(info.getJoinpoint(), generator);
+               FieldJoinPointGenerator existing = (FieldJoinPointGenerator)fieldReadJoinPoinGenerators.putIfAbsent(info.getJoinpoint(), generator);
+               if (existing != null)
+               {
+                  generator = existing;
+               }
             }
             return generator;
          }
@@ -1302,7 +1310,11 @@
             {
                generator = new FieldJoinPointGenerator(GeneratedClassAdvisor.this, info);
                initJoinPointGeneratorsMap();
-               joinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
+               FieldJoinPointGenerator existing = (FieldJoinPointGenerator)joinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
+               if (existing != null)
+               {
+                  generator = existing;
+               }
             }
             return generator;
          }
@@ -1316,7 +1328,11 @@
          {
             generator = new ConstructorJoinPointGenerator(GeneratedClassAdvisor.this, info);
             initConstructionJoinPointGeneratorsMap();
-            constructionJoinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
+            ConstructorJoinPointGenerator existing = (ConstructorJoinPointGenerator)constructionJoinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
+            if (existing != null)
+            {
+               generator = existing;
+            }
          }
          return generator;
       }
@@ -1328,7 +1344,11 @@
          {
             generator = new ConstructionJoinPointGenerator(GeneratedClassAdvisor.this, info);
             initJoinPointGeneratorsMap();
-            joinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
+            ConstructionJoinPointGenerator existing = (ConstructionJoinPointGenerator)joinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
+            if (existing != null)
+            {
+               generator = existing;
+            }
          }
          return generator;
       }
@@ -1342,16 +1362,22 @@
          {
             map = new ConcurrentHashMap();
             initJoinPointGeneratorsMap();
-            joinPointGenerators.putIfAbsent(info.getJoinpoint(), map);
-            map = (ConcurrentHashMap)joinPointGenerators.get(info.getJoinpoint());
+            ConcurrentHashMap existing = (ConcurrentHashMap)joinPointGenerators.putIfAbsent(info.getJoinpoint(), map);
+            if (existing != null)
+            {
+               map = existing;
+            }
          }
 
          MethodByMethodJoinPointGenerator generator = (MethodByMethodJoinPointGenerator)map.get(info.getCalledClass());
          if (generator == null)
          {
             generator = new MethodByMethodJoinPointGenerator(GeneratedClassAdvisor.this, info);
-            map.putIfAbsent(info.getCalledClass(), generator);
-            generator = (MethodByMethodJoinPointGenerator)map.get(info.getCalledClass());
+            MethodByMethodJoinPointGenerator existing = (MethodByMethodJoinPointGenerator)map.putIfAbsent(info.getCalledClass(), generator);
+            if (existing != null)
+            {
+               generator = existing;
+            }
          }
          return generator;
       }
@@ -1363,7 +1389,11 @@
          {
             generator = new ConByMethodJoinPointGenerator(GeneratedClassAdvisor.this, info);
             initJoinPointGeneratorsMap();
-            joinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
+            ConByMethodJoinPointGenerator existing = (ConByMethodJoinPointGenerator)joinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
+            if (existing != null)
+            {
+               generator = existing;
+            }
          }
          return generator;
       }
@@ -1376,7 +1406,11 @@
          {
             generator = new ConByConJoinPointGenerator(GeneratedClassAdvisor.this, info);
             initJoinPointGeneratorsMap();
-            joinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
+            ConByConJoinPointGenerator existing = (ConByConJoinPointGenerator)joinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
+            if (existing != null)
+            {
+               generator = existing;
+            }
          }
          return generator;
       }
@@ -1390,16 +1424,22 @@
          {
             map = new ConcurrentHashMap();
             initJoinPointGeneratorsMap();
-            joinPointGenerators.putIfAbsent(info.getJoinpoint(), map);
-            map = (ConcurrentHashMap)joinPointGenerators.get(info.getJoinpoint());
+            ConcurrentHashMap exisiting = (ConcurrentHashMap)joinPointGenerators.putIfAbsent(info.getJoinpoint(), map);
+            if (exisiting != null)
+            {
+               map = exisiting;
+            }
          }
 
          MethodByConJoinPointGenerator generator = (MethodByConJoinPointGenerator)map.get(info.getCalledClass());
          if (generator == null)
          {
             generator = new MethodByConJoinPointGenerator(GeneratedClassAdvisor.this, info);
-            map.putIfAbsent(info.getCalledClass(), generator);
-            generator = (MethodByConJoinPointGenerator)map.get(info.getCalledClass());
+            MethodByConJoinPointGenerator existing = (MethodByConJoinPointGenerator)map.putIfAbsent(info.getCalledClass(), generator);
+            if (existing != null)
+            {
+               generator = existing;
+            }
          }
          return generator;
       }

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/annotation/AnnotationRepository.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/annotation/AnnotationRepository.java	2007-10-26 09:40:44 UTC (rev 66478)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/annotation/AnnotationRepository.java	2007-10-26 09:41:18 UTC (rev 66479)
@@ -50,9 +50,9 @@
    /** Read/Write lock to be used when lazy creating the collections */
    protected ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
 
-   Map annotations = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
-   Map classAnnotations = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
-   Map disabledAnnotations = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   volatile Map annotations = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   volatile Map classAnnotations = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   volatile Map disabledAnnotations = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
    
    public Map getAnnotations()
    {

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/metadata/MethodMetaData.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/metadata/MethodMetaData.java	2007-10-26 09:40:44 UTC (rev 66478)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/metadata/MethodMetaData.java	2007-10-26 09:41:18 UTC (rev 66479)
@@ -39,7 +39,7 @@
  */
 public class MethodMetaData implements MetaDataResolver
 {
-   Map methodMetaData = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   volatile Map methodMetaData = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
    HashMap inexactMatches;
 
    public boolean hasTag(String group)




More information about the jboss-cvs-commits mailing list