[jboss-cvs] JBossAS SVN: r78662 - in projects/aop/trunk/aop/src/main/org/jboss/aop: advice and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 18 01:09:08 EDT 2008


Author: flavia.rainone at jboss.com
Date: 2008-09-18 01:09:08 -0400 (Thu, 18 Sep 2008)
New Revision: 78662

Modified:
   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/Domain.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java
Log:
[JBAOP-629] Moved lockread from fine-grained points to coarse-grained points (AspectManager).

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java	2008-09-18 04:10:00 UTC (rev 78661)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java	2008-09-18 05:09:08 UTC (rev 78662)
@@ -1010,7 +1010,7 @@
     * @return
     * @throws Exception
     */
-   public synchronized byte[] translate(String className, ClassLoader loader, byte[] classfileBuffer) throws Exception
+   public byte[] translate(String className, ClassLoader loader, byte[] classfileBuffer) throws Exception
    {
       try
       {
@@ -1018,6 +1018,10 @@
          {
             return null;
          }
+         this.bindingCollection.lockRead();
+         try
+         {
+            synchronized(this){
          if (weavingStrategy == null)
          {
             if (TransformerCommon.isCompileTime() || classicOrder)
@@ -1036,6 +1040,11 @@
          }
 
          return weavingStrategy.translate(this, className, loader, classfileBuffer);
+         }}
+         finally
+         {
+            this.bindingCollection.unlockRead(false);
+         }
       }
       catch (Exception e)
       {

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java	2008-09-18 04:10:00 UTC (rev 78661)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java	2008-09-18 05:09:08 UTC (rev 78662)
@@ -620,59 +620,51 @@
    private void resolveBindings(AspectManager manager)
    {
       ClassifiedBindingAndPointcutCollection bindingCol = manager.getBindingCollection();
-      bindingCol.lockRead(true);
-      try
+      for (AdviceBinding binding: bindingCol.getFieldReadBindings())
       {
-         for (AdviceBinding binding: bindingCol.getFieldReadBindings())
+         if (AspectManager.verbose && logger.isDebugEnabled())
          {
-            if (AspectManager.verbose && logger.isDebugEnabled())
-            {
-               logger.debug("iterate binding " + binding.getName() + " " +
-                     binding.getPointcut().getExpr());
-            }
-            resolveFieldPointcut(fieldReadInfos, fieldReadInterceptors, binding, false);
+            logger.debug("iterate binding " + binding.getName() + " " +
+                  binding.getPointcut().getExpr());
          }
-         for (AdviceBinding binding: bindingCol.getFieldWriteBindings())
+         resolveFieldPointcut(fieldReadInfos, fieldReadInterceptors, binding, false);
+      }
+      for (AdviceBinding binding: bindingCol.getFieldWriteBindings())
+      {
+         if (AspectManager.verbose && logger.isDebugEnabled())
          {
-            if (AspectManager.verbose && logger.isDebugEnabled())
-            {
-               logger.debug("iterate binding " + binding.getName() + " " +
-                     binding.getPointcut().getExpr());
-            }
-            resolveFieldPointcut(fieldWriteInfos, fieldWriteInterceptors, binding, true);
+            logger.debug("iterate binding " + binding.getName() + " " +
+                  binding.getPointcut().getExpr());
          }
-         for (AdviceBinding binding: bindingCol.getConstructionBindings())
+         resolveFieldPointcut(fieldWriteInfos, fieldWriteInterceptors, binding, true);
+      }
+      for (AdviceBinding binding: bindingCol.getConstructionBindings())
+      {
+         if (AspectManager.verbose && logger.isDebugEnabled())
          {
-            if (AspectManager.verbose && logger.isDebugEnabled())
-            {
-               logger.debug("iterate binding " + binding.getName() + " " +
-                     binding.getPointcut().getExpr());
-            }
-            resolveConstructionPointcut(binding);
+            logger.debug("iterate binding " + binding.getName() + " " +
+                  binding.getPointcut().getExpr());
          }
-         for (AdviceBinding binding: bindingCol.getConstructorExecutionBindings())
+         resolveConstructionPointcut(binding);
+      }
+      for (AdviceBinding binding: bindingCol.getConstructorExecutionBindings())
+      {
+         if (AspectManager.verbose && logger.isDebugEnabled())
          {
-            if (AspectManager.verbose && logger.isDebugEnabled())
-            {
-               logger.debug("iterate binding " + binding.getName() + " " +
-                     binding.getPointcut().getExpr());
-            }
-            resolveConstructorPointcut(binding);
+            logger.debug("iterate binding " + binding.getName() + " " +
+                  binding.getPointcut().getExpr());
          }
-         for (AdviceBinding binding: bindingCol.getMethodExecutionBindings())
+         resolveConstructorPointcut(binding);
+      }
+      for (AdviceBinding binding: bindingCol.getMethodExecutionBindings())
+      {
+         if (AspectManager.verbose && logger.isDebugEnabled())
          {
-            if (AspectManager.verbose && logger.isDebugEnabled())
-            {
-               logger.debug("iterate binding " + binding.getName() + " " +
-                     binding.getPointcut().getExpr());
-            }
-            resolveMethodPointcut(binding);
+            logger.debug("iterate binding " + binding.getName() + " " +
+                  binding.getPointcut().getExpr());
          }
+         resolveMethodPointcut(binding);
       }
-      finally
-      {
-         bindingCol.unlockRead(true);
-      }
    }
    
    protected void updateInterceptorChains() throws Exception

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java	2008-09-18 04:10:00 UTC (rev 78661)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java	2008-09-18 05:09:08 UTC (rev 78662)
@@ -1029,440 +1029,263 @@
 
    private class DomainClassifiedBindingAndPointcutCollection extends ClassifiedBindingAndPointcutCollection
    {
-      
+
       @Override
       public LinkedHashMap<String, AdviceBinding> getBindings()
       {
-         lockRead(true);
-         try
+         LinkedHashMap<String, AdviceBinding> result = super.getBindingsInternal();
+         LinkedHashMap<String, AdviceBinding> parentResult = 
+            inheritsBindings ? parent.getBindingCollection().getBindingsInternal() :
+               UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+         LinkedHashMap<String, AdviceBinding> overall = unifyMaps(result, parentResult, parentFirst);
+         if (overall == result || overall == parentResult)
          {
-            LinkedHashMap<String, AdviceBinding> result = super.getBindingsInternal();
-            LinkedHashMap<String, AdviceBinding> parentResult = 
-               inheritsBindings ?
-                  parent.getBindingCollection().getBindingsInternal() : UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-            LinkedHashMap<String, AdviceBinding> overall = unifyMaps(result, parentResult, parentFirst);
-            if (overall == result || overall == parentResult)
-            {
-               return new LinkedHashMap<String, AdviceBinding>(overall);
-            }
-            return overall;
+            return new LinkedHashMap<String, AdviceBinding>(overall);
          }
-         finally
-         {
-            unlockRead(true);
-         }
-
+         return overall;
       }  
 
       @Override
       public LinkedHashMap<String, Pointcut> getPointcuts()
       {
-         lockRead(true);
-         try
-         {
-            LinkedHashMap<String, Pointcut> result = super.getPointcutsInternal();
-            LinkedHashMap<String, Pointcut> parentResult = 
+         LinkedHashMap<String, Pointcut> result = super.getPointcutsInternal();
+         LinkedHashMap<String, Pointcut> parentResult = 
                inheritsBindings ? 
                      parent.getBindingCollection().getPointcutsInternal() : UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-            LinkedHashMap<String, Pointcut> overall = unifyMaps(result, parentResult, parentFirst);
-            if (overall == result || overall == parentResult)
-            {
-               return new LinkedHashMap<String, Pointcut>(overall);
-            }
-            return overall;
-         }
-         finally
+         LinkedHashMap<String, Pointcut> overall = unifyMaps(result, parentResult, parentFirst);
+         if (overall == result || overall == parentResult)
          {
-            unlockRead(true);
+            return new LinkedHashMap<String, Pointcut>(overall);
          }
+         return overall;
       }
 
       @Override
       public LinkedHashMap<String, PointcutInfo> getPointcutInfos()
       {
-         lockRead(true);
-         try
+         LinkedHashMap<String, PointcutInfo> result = super.getPointcutInfosInternal();
+         LinkedHashMap<String, PointcutInfo> parentResult = 
+            inheritsBindings ?
+                  parent.getBindingCollection().getPointcutInfosInternal() : UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+         LinkedHashMap<String, PointcutInfo> overall = unifyMaps(result, parentResult, parentFirst);
+         if (overall == result || overall == parentResult)
          {
-            LinkedHashMap<String, PointcutInfo> result = super.getPointcutInfosInternal();
-            LinkedHashMap<String, PointcutInfo> parentResult = 
-               inheritsBindings ?
-                     parent.getBindingCollection().getPointcutInfosInternal() : UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-            LinkedHashMap<String, PointcutInfo> overall = unifyMaps(result, parentResult, parentFirst);
-            if (overall == result || overall == parentResult)
-            {
-               return new LinkedHashMap<String, PointcutInfo>(overall);
-            }
-            return overall;
+            return new LinkedHashMap<String, PointcutInfo>(overall);
          }
-         finally
-         {
-            unlockRead(true);
-         }
+         return overall;
       }
 
 
       @Override
       public Collection<AdviceBinding> getFieldReadBindings()
       {
-         lockRead(true);
-         try
-         {
-            Collection<AdviceBinding> result = super.getFieldReadBindings();
-            Collection<AdviceBinding> parentResult = 
+         Collection<AdviceBinding> result = super.getFieldReadBindings();
+         Collection<AdviceBinding> parentResult = 
                inheritsBindings ?
                      parent.getBindingCollection().getFieldReadBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-            return unifyCollections(result, parentResult, parentFirst);
-         }
-         finally
-         {
-            unlockRead(true);
-         }
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       @Override
       public Collection<AdviceBinding> getFieldWriteBindings()
       {
-         lockRead(true);
-         try
-         {
-            Collection<AdviceBinding> result = super.getFieldWriteBindings();
-            Collection<AdviceBinding> parentResult = 
-               inheritsBindings ?
-                  parent.getBindingCollection().getFieldWriteBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-            return unifyCollections(result, parentResult, parentFirst);
-         }
-         finally
-         {
-            unlockRead(true);
-         }
+         Collection<AdviceBinding> result = super.getFieldWriteBindings();
+         Collection<AdviceBinding> parentResult = 
+            inheritsBindings ? parent.getBindingCollection().getFieldWriteBindings():
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       @Override
       public Collection<AdviceBinding> getConstructionBindings()
       {
-         lockRead(true);
-         try
-         {
-            Collection<AdviceBinding> result = super.getConstructionBindings();
-            Collection<AdviceBinding> parentResult = 
-               inheritsBindings ?
-                     parent.getBindingCollection().getConstructionBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-            return unifyCollections(result, parentResult, parentFirst);
-         }
-         finally
-         {
-            unlockRead(true);
-         }
+         Collection<AdviceBinding> result = super.getConstructionBindings();
+         Collection<AdviceBinding> parentResult = 
+            inheritsBindings ? parent.getBindingCollection().getConstructionBindings() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       @Override
       public Collection<AdviceBinding> getConstructorExecutionBindings()
       {
-         lockRead(true);
-         try
-         {
-            Collection<AdviceBinding> result = super.getConstructorExecutionBindings();
+         Collection<AdviceBinding> result = super.getConstructorExecutionBindings();
             Collection<AdviceBinding> parentResult = 
                inheritsBindings ?
                      parent.getBindingCollection().getConstructorExecutionBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
             return unifyCollections(result, parentResult, parentFirst);
-         }
-         finally
-         {
-            unlockRead(true);
-         }
       }
       
       @Override
       public Collection<AdviceBinding> getMethodExecutionBindings()
       {
-         lockRead(true);
-         try
-         {
-            Collection<AdviceBinding> result = super.getMethodExecutionBindings();
-            Collection<AdviceBinding> parentResult = 
-               inheritsBindings ?
-                     parent.getBindingCollection().getMethodExecutionBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-            return unifyCollections(result, parentResult, parentFirst);
-         }
-         finally
-         { 
-            unlockRead(true);
-         }
+         Collection<AdviceBinding> result = super.getMethodExecutionBindings();
+         Collection<AdviceBinding> parentResult = 
+            inheritsBindings ?
+            parent.getBindingCollection().getMethodExecutionBindings() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       @Override
       public Collection<AdviceBinding> getConstructorCallBindings()
       {
-         lockRead(true);
-         try
-         {
-            Collection<AdviceBinding> result = super.getConstructorCallBindings();
-            Collection<AdviceBinding> parentResult = 
-               inheritsBindings ?
-                     parent.getBindingCollection().getConstructorCallBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-            return unifyCollections(result, parentResult, parentFirst);
-         }
-         finally
-         {
-            unlockRead(true);
-         }
+         Collection<AdviceBinding> result = super.getConstructorCallBindings();
+         Collection<AdviceBinding> parentResult = 
+            inheritsBindings ?
+            parent.getBindingCollection().getConstructorCallBindings() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       @Override
       public Collection<AdviceBinding> getMethodCallBindings()
       {
-         lockRead(true);
-         try
-         {
-            Collection<AdviceBinding> result = super.getMethodCallBindings();
-            Collection<AdviceBinding> parentResult = 
-               inheritsBindings ? 
-                     parent.getBindingCollection().getMethodCallBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-            return unifyCollections(result, parentResult, parentFirst);
-         }
-         finally
-         {
-            unlockRead(true);
-         }
+         Collection<AdviceBinding> result = super.getMethodCallBindings();
+         Collection<AdviceBinding> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getMethodCallBindings() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
 
       public Collection<Pointcut> getFieldReadPointcuts()
       {
-            lockRead(true);
-            try
-            {
-               Collection<Pointcut> result = super.getFieldReadPointcuts();
-               Collection<Pointcut> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getFieldReadPointcuts() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<Pointcut> result = super.getFieldReadPointcuts();
+         Collection<Pointcut> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getFieldReadPointcuts() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       public Collection<Pointcut> getFieldWritePointcuts()
       {
-            lockRead(true);
-            try
-            {
-               Collection<Pointcut> result = super.getFieldWritePointcuts();
-               Collection<Pointcut> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getFieldWritePointcuts() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<Pointcut> result = super.getFieldWritePointcuts();
+         Collection<Pointcut> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getFieldWritePointcuts() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       public Collection<Pointcut> getConstructionPointcuts()
       {
-            lockRead(true);
-            try
-            {
-               Collection<Pointcut> result = super.getConstructionPointcuts();
-               Collection<Pointcut> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getConstructionPointcuts() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<Pointcut> result = super.getConstructionPointcuts();
+         Collection<Pointcut> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getConstructionPointcuts() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       public Collection<Pointcut> getConstructorExecutionPointcuts()
       {
-            lockRead(true);
-            try
-            {
-               Collection<Pointcut> result = super.getConstructorExecutionPointcuts();
-               Collection<Pointcut> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getConstructorExecutionPointcuts() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<Pointcut> result = super.getConstructorExecutionPointcuts();
+         Collection<Pointcut> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getConstructorExecutionPointcuts() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       public Collection<Pointcut> getMethodExecutionPointcuts()
       {
-            lockRead(true);
-            try
-            {
-               Collection<Pointcut> result = super.getMethodExecutionPointcuts();
-               Collection<Pointcut> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getMethodExecutionPointcuts() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<Pointcut> result = super.getMethodExecutionPointcuts();
+         Collection<Pointcut> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getMethodExecutionPointcuts() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       public Collection<Pointcut> getConstructorCallPointcuts()
       {
-            lockRead(true);
-            try
-            {
-               Collection<Pointcut> result = super.getConstructorCallPointcuts();
-               Collection<Pointcut> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getConstructorCallPointcuts() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<Pointcut> result = super.getConstructorCallPointcuts();
+         Collection<Pointcut> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getConstructorCallPointcuts() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       public Collection<Pointcut> getMethodCallPointcuts()
       {
-            lockRead(true);
-            try
-            {
-               Collection<Pointcut> result = super.getMethodCallPointcuts();
-               Collection<Pointcut> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getMethodCallPointcuts() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<Pointcut> result = super.getMethodCallPointcuts();
+         Collection<Pointcut> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getMethodCallPointcuts() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       public Collection<PointcutInfo> getFieldReadPointcutInfos()
       {
-            lockRead(true);
-            try
-            {
-               Collection<PointcutInfo> result = super.getFieldReadPointcutInfos();
-               Collection<PointcutInfo> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getFieldReadPointcutInfos() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<PointcutInfo> result = super.getFieldReadPointcutInfos();
+         Collection<PointcutInfo> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getFieldReadPointcutInfos() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       public Collection<PointcutInfo> getFieldWritePointcutInfos()
       {
-            lockRead(true);
-            try
-            {
-               Collection<PointcutInfo> result = super.getFieldWritePointcutInfos();
-               Collection<PointcutInfo> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getFieldWritePointcutInfos() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<PointcutInfo> result = super.getFieldWritePointcutInfos();
+         Collection<PointcutInfo> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getFieldWritePointcutInfos() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       public Collection<PointcutInfo> getConstructionPointcutInfos()
       {
-            lockRead(true);
-            try
-            {
-               Collection<PointcutInfo> result = super.getConstructionPointcutInfos();
-               Collection<PointcutInfo> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getConstructionPointcutInfos() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<PointcutInfo> result = super.getConstructionPointcutInfos();
+         Collection<PointcutInfo> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getConstructionPointcutInfos() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       public Collection<PointcutInfo> getConstructorExecutionPointcutInfos()
       {
-            lockRead(true);
-            try
-            {
-               Collection<PointcutInfo> result = super.getConstructorExecutionPointcutInfos();
-               Collection<PointcutInfo> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getConstructorExecutionPointcutInfos() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<PointcutInfo> result = super.getConstructorExecutionPointcutInfos();
+         Collection<PointcutInfo> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getConstructorExecutionPointcutInfos() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       public Collection<PointcutInfo> getMethodExecutionPointcutInfos()
       {
-            lockRead(true);
-            try
-            {
-               Collection<PointcutInfo> result = super.getMethodExecutionPointcutInfos();
-               Collection<PointcutInfo> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getMethodExecutionPointcutInfos() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<PointcutInfo> result = super.getMethodExecutionPointcutInfos();
+         Collection<PointcutInfo> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getMethodExecutionPointcutInfos() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       public Collection<PointcutInfo> getConstructorCallPointcutInfos()
       {
-            lockRead(true);
-            try
-            {
-               Collection<PointcutInfo> result = super.getConstructorCallPointcutInfos();
-               Collection<PointcutInfo> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getConstructorCallPointcutInfos() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<PointcutInfo> result = super.getConstructorCallPointcutInfos();
+         Collection<PointcutInfo> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getConstructorCallPointcutInfos() :
+            UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
       
       public Collection<PointcutInfo> getMethodCallPointcutInfos()
       {
-            lockRead(true);
-            try
-            {
-               Collection<PointcutInfo> result = super.getMethodCallPointcutInfos();
-               Collection<PointcutInfo> parentResult = 
-                  inheritsBindings ?
-                        parent.getBindingCollection().getMethodCallPointcutInfos() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-               return unifyCollections(result, parentResult, parentFirst);
-            }
-            finally
-            { 
-               unlockRead(true);
-            }
+         Collection<PointcutInfo> result = super.getMethodCallPointcutInfos();
+         Collection<PointcutInfo> parentResult =
+            inheritsBindings ?
+            parent.getBindingCollection().getMethodCallPointcutInfos() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+         return unifyCollections(result, parentResult, parentFirst);
       }
 
       @Override

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java	2008-09-18 04:10:00 UTC (rev 78661)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java	2008-09-18 05:09:08 UTC (rev 78662)
@@ -145,15 +145,7 @@
     */
    public Collection<AdviceBinding> getFieldReadBindings()
    {
-      lockRead();
-      try
-      {
-         return this.fieldReadBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.fieldReadBindings;
    }
    
    /**
@@ -166,15 +158,7 @@
     */
    public Collection<AdviceBinding> getFieldWriteBindings()
    {
-      lockRead();
-      try
-      {
-         return this.fieldWriteBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.fieldWriteBindings;
    }
    
    /**
@@ -187,15 +171,7 @@
     */
    public Collection<AdviceBinding> getConstructionBindings()
    {
-      lockRead();
-      try
-      {
-         return this.constructionBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.constructionBindings;
    }
    
    /**
@@ -208,15 +184,7 @@
     */
    public Collection<AdviceBinding> getConstructorExecutionBindings()
    {
-      lockRead();
-      try
-      {
-         return this.constructorExecutionBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.constructorExecutionBindings;
    }
    
    /**
@@ -229,15 +197,7 @@
     */
    public Collection<AdviceBinding> getMethodExecutionBindings()
    {
-      lockRead();
-      try
-      {
-         return this.methodExecutionBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.methodExecutionBindings;
    }
    
    /**
@@ -251,15 +211,7 @@
     */
    public Collection<AdviceBinding> getConstructorCallBindings()
    {
-      lockRead();
-      try
-      {
-         return this.constructorCallBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.constructorCallBindings;
    }
    
    /**
@@ -272,15 +224,7 @@
     */
    public Collection<AdviceBinding> getMethodCallBindings()
    {
-      lockRead();
-      try
-      {
-         return this.methodCallBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.methodCallBindings;
    }
 
    /**
@@ -293,15 +237,7 @@
     */
    public Collection<Pointcut> getFieldReadPointcuts()
    {
-      lockRead();
-      try
-      {
-         return this.fieldReadPointcuts;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.fieldReadPointcuts;
    }
    
    /**
@@ -314,15 +250,7 @@
     */
    public Collection<Pointcut> getFieldWritePointcuts()
    {
-      lockRead();
-      try
-      {
-         return this.fieldWritePointcuts;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.fieldWritePointcuts;
    }
    
    /**
@@ -335,15 +263,7 @@
     */
    public Collection<Pointcut> getConstructionPointcuts()
    {
-      lockRead();
-      try
-      {
-         return this.constructionPointcuts;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.constructionPointcuts;
    }
    
    /**
@@ -356,15 +276,7 @@
     */
    public Collection<Pointcut> getConstructorExecutionPointcuts()
    {
-      lockRead();
-      try
-      {
-         return this.constructorExecutionPointcuts;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.constructorExecutionPointcuts;
    }
    
    /**
@@ -377,15 +289,7 @@
     */
    public Collection<Pointcut> getMethodExecutionPointcuts()
    {
-      lockRead();
-      try
-      {
-         return this.methodExecutionPointcuts;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.methodExecutionPointcuts;
    }
    
    /**
@@ -399,15 +303,7 @@
     */
    public Collection<Pointcut> getConstructorCallPointcuts()
    {
-      lockRead();
-      try
-      {
-         return this.constructorCallPointcuts;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.constructorCallPointcuts;
    }
    
    /**
@@ -420,15 +316,7 @@
     */
    public Collection<Pointcut> getMethodCallPointcuts()
    {
-      lockRead();
-      try
-      {
-         return this.methodCallPointcuts;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.methodCallPointcuts;
    }
    
    /**
@@ -441,15 +329,7 @@
     */
    public Collection<PointcutInfo> getFieldReadPointcutInfos()
    {
-      lockRead();
-      try
-      {
-         return this.fieldReadPointcutInfos;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.fieldReadPointcutInfos;
    }
    
    /**
@@ -462,15 +342,7 @@
     */
    public Collection<PointcutInfo> getFieldWritePointcutInfos()
    {
-      lockRead();
-      try
-      {
-         return this.fieldWritePointcutInfos;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.fieldWritePointcutInfos;
    }
    
    /**
@@ -483,15 +355,7 @@
     */
    public Collection<PointcutInfo> getConstructionPointcutInfos()
    {
-      lockRead();
-      try
-      {
-         return this.constructionPointcutInfos;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.constructionPointcutInfos;
    }
    
    /**
@@ -504,15 +368,7 @@
     */
    public Collection<PointcutInfo> getConstructorExecutionPointcutInfos()
    {
-      lockRead();
-      try
-      {
-         return this.constructorExecutionPointcutInfos;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.constructorExecutionPointcutInfos;
    }
    
    /**
@@ -525,15 +381,7 @@
     */
    public Collection<PointcutInfo> getMethodExecutionPointcutInfos()
    {
-      lockRead();
-      try
-      {
-         return this.methodExecutionPointcutInfos;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.methodExecutionPointcutInfos;
    }
    
    /**
@@ -547,15 +395,7 @@
     */
    public Collection<PointcutInfo> getConstructorCallPointcutInfos()
    {
-      lockRead();
-      try
-      {
-         return this.constructorCallPointcutInfos;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.constructorCallPointcutInfos;
    }
    
    /**
@@ -568,15 +408,7 @@
     */
    public Collection<PointcutInfo> getMethodCallPointcutInfos()
    {
-      lockRead();
-      try
-      {
-         return this.methodCallPointcutInfos;
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.methodCallPointcutInfos;
    }
 
    /**
@@ -584,15 +416,7 @@
     */
    public boolean isEmpty()
    {
-      lockRead();
-      try
-      {
-         return this.bindings.isEmpty();
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return this.bindings.isEmpty();
    }
    
    /**
@@ -601,15 +425,7 @@
     */
    public LinkedHashMap<String, AdviceBinding> getBindings()
    {
-      lockRead();
-      try
-      {
-         return new UnmodifiableLinkedHashMap<String, AdviceBinding>(bindings);
-      }
-      finally
-      { 
-         unlockRead();
-      }
+      return new UnmodifiableLinkedHashMap<String, AdviceBinding>(bindings);
    }
    
    /**
@@ -619,15 +435,7 @@
    @Deprecated
    public LinkedHashMap<String, AdviceBinding> getBindingsInternal()
    {
-      lockRead();
-      try
-      {
-         return new UnmodifiableLinkedHashMap<String, AdviceBinding>(bindings);
-      }
-      finally
-      { 
-         unlockRead();
-      }
+      return new UnmodifiableLinkedHashMap<String, AdviceBinding>(bindings);
    }
    
    /**
@@ -636,15 +444,7 @@
     */
    public LinkedHashMap<String, Pointcut> getPointcuts()
    {
-      lockRead();
-      try
-      {
-         return pointcuts;
-      }
-      finally
-      { 
-         unlockRead();
-      }
+      return pointcuts;
    }
    
    /**
@@ -654,15 +454,7 @@
    @Deprecated
    public LinkedHashMap<String, Pointcut> getPointcutsInternal()
    {
-      lockRead();
-      try
-      {
-         return pointcuts;
-      }
-      finally
-      { 
-         unlockRead();
-      }
+      return pointcuts;
    }
    
    /**
@@ -671,15 +463,7 @@
     */
    public LinkedHashMap<String, PointcutInfo> getPointcutInfos()
    {
-      lockRead();
-      try
-      {
-         return new UnmodifiableLinkedHashMap<String, PointcutInfo>(pointcutInfos);
-      }
-      finally
-      { 
-         unlockRead();
-      }
+      return new UnmodifiableLinkedHashMap<String, PointcutInfo>(pointcutInfos);
    }
    
    /**
@@ -689,15 +473,7 @@
    @Deprecated
    public LinkedHashMap<String, PointcutInfo> getPointcutInfosInternal()
    {
-      lockRead();
-      try
-      {
-         return pointcutInfos;
-      }
-      finally
-      { 
-         unlockRead();
-      }
+      return pointcutInfos;
    }
    
    /**
@@ -705,23 +481,15 @@
     */
    public void add(AdviceBinding binding, AspectManager manager)
    {
-      lockWrite();
-      try
-      {
-         addBinding(binding);
-         addGet(binding);
-         addSet(binding);
-         addConstruction(binding);
-         addConstructorExecution(binding);
-         addMethodExecution(binding);
-         addConstructorCall(binding);
-         addMethodCall(binding);
-         updatePointcutStats(binding.getPointcut(), manager);
-      }
-      finally
-      {
-         unlockWrite();
-      }
+      addBinding(binding);
+      addGet(binding);
+      addSet(binding);
+      addConstruction(binding);
+      addConstructorExecution(binding);
+      addMethodExecution(binding);
+      addConstructorCall(binding);
+      addMethodCall(binding);
+      updatePointcutStats(binding.getPointcut(), manager);
    }
 
    /**
@@ -729,18 +497,10 @@
     */
    public void add(Pointcut pointcut, AspectManager manager)
    {
-      lockWrite();
-      try
-      {
-         removePointcut(pointcut.getName());
-         addPointcut(pointcut);
+      removePointcut(pointcut.getName());
+      addPointcut(pointcut);
 
-         updatePointcutStats(pointcut, manager);
-      }
-      finally
-      {
-         unlockWrite();
-      }
+      updatePointcutStats(pointcut, manager);
    }
    
    /**
@@ -752,44 +512,28 @@
     */
    public AdviceBinding removeBinding(String name)
    {
-      lockWrite();
-      try
+      AdviceBinding binding = bindings.remove(name);
+      if (binding != null)
       {
-         AdviceBinding binding = bindings.remove(name);
-         if (binding != null)
-         {
-            this.fieldReadBindings.remove(binding);
-            this.fieldWriteBindings.remove(binding);
-            this.constructionBindings.remove(binding);
-            this.constructorExecutionBindings.remove(binding);
-            this.methodExecutionBindings.remove(binding);
-            this.constructorCallBindings.remove(binding);
-            this.methodCallBindings.remove(binding);
-         }
-         return binding;
+         this.fieldReadBindings.remove(binding);
+         this.fieldWriteBindings.remove(binding);
+         this.constructionBindings.remove(binding);
+         this.constructorExecutionBindings.remove(binding);
+         this.methodExecutionBindings.remove(binding);
+         this.constructorCallBindings.remove(binding);
+         this.methodCallBindings.remove(binding);
       }
-      finally
-      {
-         unlockWrite();
-      }
+      return binding;
    }
-   
+      
    /**
     * Removes the pointcut and pointcutInfo named {@code name}
     * @param name the name of the pointcut to be removed
     */
    public void removePointcut(String name)
    {
-      lockWrite();
-      try
-      {
-         pointcuts.remove(name);
-         pointcutInfos.remove(name);
-      }
-      finally
-      {
-         unlockWrite();
-      }
+      pointcuts.remove(name);
+      pointcutInfos.remove(name);
    }
    
    /**
@@ -799,15 +543,7 @@
     */
    public Pointcut getPointcut(String name)
    {
-      lockRead();
-      try
-      {
-         return pointcuts.get(name);
-      }
-      finally
-      {
-         unlockRead();
-      }
+      return pointcuts.get(name);
    }
    
    /**
@@ -818,26 +554,18 @@
     */
    public ArrayList<AdviceBinding> removeBindings(ArrayList<String> names)
    {
-      lockWrite();
-      try
+      ArrayList<AdviceBinding> removedBindings = new ArrayList<AdviceBinding>();
+      for (String name: names)
       {
-         ArrayList<AdviceBinding> removedBindings = new ArrayList<AdviceBinding>();
-         for (String name: names)
+         AdviceBinding binding = this.removeBinding(name);
+         if (binding == null)
          {
-            AdviceBinding binding = this.removeBinding(name);
-            if (binding == null)
-            {
-               logger.debug("ClassifiedBindingCollection.removeBindings() no binding found with name " + name);
-               continue;
-            }
-            removedBindings.add(binding);
+            logger.debug("ClassifiedBindingCollection.removeBindings() no binding found with name " + name);
+            continue;
          }
-         return removedBindings;
+         removedBindings.add(binding);
       }
-      finally
-      {
-         unlockWrite();
-      }
+      return removedBindings;
    }
 
    public boolean isExecution()




More information about the jboss-cvs-commits mailing list