[jboss-cvs] JBossAS SVN: r78455 - 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 11 13:04:34 EDT 2008


Author: kabir.khan at jboss.com
Date: 2008-09-11 13:04:34 -0400 (Thu, 11 Sep 2008)
New Revision: 78455

Added:
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java
Removed:
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingCollection.java
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/ClassContainer.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/ClassicWeavingStrategy.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/SuperClassesFirstWeavingStrategy.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/WeavingStrategySupport.java
Log:
[JBAOP-638] Move pointcuts and pointcutInfos into ClassifiedBindingCollection, and rename to ClassifiedBindingAndPointcutCollection
For JBAOP-639 move AspectManager.transformationStarted into WeaverStrategySupport
For JBAOP-640 honour inheritsBindings in DomainClassifiedBindingCollection, and rename to DomainClassifiedBindingAndPointcutCollection 


Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java	2008-09-11 16:44:09 UTC (rev 78454)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java	2008-09-11 17:04:34 UTC (rev 78455)
@@ -50,7 +50,7 @@
 import org.jboss.aop.advice.AdviceBinding;
 import org.jboss.aop.advice.AspectDefinition;
 import org.jboss.aop.advice.CFlowInterceptor;
-import org.jboss.aop.advice.ClassifiedBindingCollection;
+import org.jboss.aop.advice.ClassifiedBindingAndPointcutCollection;
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.aop.advice.InterceptorFactory;
 import org.jboss.aop.advice.PrecedenceSorter;
@@ -1388,7 +1388,7 @@
    
    protected void updateFieldPointcutAfterRemove(FieldInfo[] fieldInfos, AdviceBinding binding, boolean write)
    {
-      ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+      ClassifiedBindingAndPointcutCollection bindingCol = manager.getBindingCollection();
       Collection<AdviceBinding> bindings = write? bindingCol.getFieldWriteBindings():
             bindingCol.getFieldReadBindings();
       for (int i = 0; i < fieldInfos.length; i++)
@@ -1422,7 +1422,7 @@
    
    protected void updateConstructorPointcutAfterRemove(AdviceBinding binding)
    {
-      ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+      ClassifiedBindingAndPointcutCollection bindingCol = manager.getBindingCollection();
       if(constructorInfos != null && constructorInfos.length > 0)
       {
          for (int i = 0; i < constructors.length; i++)
@@ -1451,7 +1451,7 @@
    
    protected void updateConstructionPointcutAfterRemove(AdviceBinding binding)
    {
-      ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+      ClassifiedBindingAndPointcutCollection bindingCol = manager.getBindingCollection();
       if (constructionInfos.length > 0)
       {
          for (int i = 0; i < constructionInfos.length ;i++)

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-11 16:44:09 UTC (rev 78454)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java	2008-09-11 17:04:34 UTC (rev 78455)
@@ -48,7 +48,7 @@
 import org.jboss.aop.advice.AdviceStack;
 import org.jboss.aop.advice.AspectDefinition;
 import org.jboss.aop.advice.AspectFactoryWithClassLoader;
-import org.jboss.aop.advice.ClassifiedBindingCollection;
+import org.jboss.aop.advice.ClassifiedBindingAndPointcutCollection;
 import org.jboss.aop.advice.DynamicCFlowDefinition;
 import org.jboss.aop.advice.InterceptorFactory;
 import org.jboss.aop.advice.PrecedenceDef;
@@ -135,7 +135,7 @@
    protected volatile LinkedHashMap<String, AnnotationIntroduction> annotationOverrides = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
    @Deprecated
    protected volatile LinkedHashMap<String, AdviceBinding> bindings = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected volatile ClassifiedBindingCollection bindingCollection = new ClassifiedBindingCollection();
+   protected final ClassifiedBindingAndPointcutCollection bindingCollection;
    protected volatile LinkedHashMap<String, Typedef> typedefs = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
    protected volatile HashMap<String, InterceptorFactory> interceptorFactories = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
    protected volatile HashMap<String,ClassMetaDataLoader> classMetaDataLoaders = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
@@ -162,9 +162,6 @@
    protected ClassExpression[] ignoreExpressions = new ClassExpression[0];
 
 
-   protected volatile LinkedHashMap<String, Pointcut> pointcuts = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   // contains pointcuts-binding association info
-   protected volatile LinkedHashMap<String, PointcutInfo> 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;
@@ -183,8 +180,6 @@
    protected WeavingStrategy weavingStrategy;
 
    protected DynamicAOPStrategy dynamicStrategy = new LoadInterceptedClassesStrategy();
-   // indicates that the transformation process has begun
-   protected boolean transformationStarted = false;
 
    /** The classloader scoping policy */
    // This shouldn't really be static (artifact of singleton and self-bootstrap design)
@@ -398,12 +393,12 @@
 
    public LinkedHashMap<String, Pointcut> getPointcuts()
    {
-      return pointcuts;
+      return bindingCollection.getPointcuts();
    }
 
    public LinkedHashMap<String, PointcutInfo> getPointcutInfos()
    {
-      return pointcutInfos;
+      return bindingCollection.getPointcutInfos();
    }
 
    public CFlowStack getCFlowStack(String name)
@@ -478,8 +473,20 @@
     */
    public AspectManager()
    {
+      bindingCollection = createBindingCollection();
    }
+   
    /**
+    * Creates the binding collection
+    * @return a {@link ClassifiedBindingAndPointcutCollection}
+    * @see Domain#ini 
+    */
+   protected ClassifiedBindingAndPointcutCollection createBindingCollection()
+   {
+      return new ClassifiedBindingAndPointcutCollection();
+   }
+   
+   /**
     * Every &lt;class-metadata&gt; tag corresponds to
     * a ClassMetaDataLoader.  The ClassMetaDataLoader knows how to take
     * arbitrary XML and apply it to SimpleMetaData.
@@ -552,7 +559,7 @@
     * 
     * @return the classified binding collection
     */
-   ClassifiedBindingCollection getBindingCollection()
+   ClassifiedBindingAndPointcutCollection getBindingCollection()
    {
       return bindingCollection;
    }
@@ -1265,10 +1272,7 @@
     */
    public Pointcut getPointcut(String name)
    {
-      synchronized (pointcuts)
-      {
-         return pointcuts.get(name);
-      }
+      return bindingCollection.getPointcut(name);
    }
 
    /**
@@ -1276,11 +1280,7 @@
     */
    public void removePointcut(String name)
    {
-      synchronized (pointcuts)
-      {
-         pointcuts.remove(name);
-         pointcutInfos.remove(name);
-      }
+      bindingCollection.removePointcut(name);
    }
 
    /**
@@ -1288,14 +1288,7 @@
     */
    public synchronized void addPointcut(Pointcut pointcut)
    {
-      removePointcut(pointcut.getName());
-      initPointcutsMap();
-      initPointcutInfosMap();
-      synchronized (pointcuts)
-      {
-         pointcuts.put(pointcut.getName(), pointcut);
-         pointcutInfos.put(pointcut.getName(), new PointcutInfo(pointcut, this.transformationStarted));
-      }
+      bindingCollection.add(pointcut);
       updatePointcutStats(pointcut);
    }
 
@@ -1306,51 +1299,57 @@
     */
    protected void updatePointcutStats(Pointcut pointcut)
    {
-      // the following is for performance reasons.
-      if (pointcut instanceof PointcutExpression)
+      synchronized(bindingCollection)
       {
-         PointcutExpression expr = (PointcutExpression) pointcut;
-         expr.setManager(this);
-         PointcutStats stats = expr.getStats();
-         updateStats(stats);
+         // the following is for performance reasons.
+         if (pointcut instanceof PointcutExpression)
+         {
+            PointcutExpression expr = (PointcutExpression) pointcut;
+            expr.setManager(this);
+            PointcutStats stats = expr.getStats();
+            updateStats(stats);
+         }
+         else
+         {
+            // can't be sure so set all
+            execution = true;
+            construction = true;
+            call = true;
+            within = true;
+            get = true;
+            set = true;
+            withincode = true;
+         }
       }
-      else
-      {
-         // can't be sure so set all
-         execution = true;
-         construction = true;
-         call = true;
-         within = true;
-         get = true;
-         set = true;
-         withincode = true;
-      }
    }
 
-   protected void updateStats(PointcutStats stats)
+   protected synchronized void updateStats(PointcutStats stats)
    {
-      if (stats != null)
+      synchronized(bindingCollection)
       {
-         construction |= stats.isConstruction();
-         execution |= stats.isExecution();
-         call |= stats.isCall();
-         within |= stats.isWithin();
-         get |= stats.isGet();
-         set |= stats.isSet();
-         withincode |= stats.isWithincode();
+         if (stats != null)
+         {
+            construction |= stats.isConstruction();
+            execution |= stats.isExecution();
+            call |= stats.isCall();
+            within |= stats.isWithin();
+            get |= stats.isGet();
+            set |= stats.isSet();
+            withincode |= stats.isWithincode();
+         }
+         else
+         {
+            if (verbose && logger.isDebugEnabled()) logger.debug("Setting all pointcut stats to true");
+            // can't be sure so set all
+            execution = true;
+            construction = true;
+            call = true;
+            within = true;
+            get = true;
+            set = true;
+            withincode = true;
+         }
       }
-      else
-      {
-         if (verbose && logger.isDebugEnabled()) logger.debug("Setting all pointcut stats to true");
-         // can't be sure so set all
-         execution = true;
-         construction = true;
-         call = true;
-         within = true;
-         get = true;
-         set = true;
-         withincode = true;
-      }
    }
 
    public boolean isExecution()
@@ -1411,7 +1410,7 @@
       bindingCollection.lockWrite();
       try
       {
-         removedBindings = this.bindingCollection.remove(binds);
+         removedBindings = this.bindingCollection.removeBindings(binds);
          for (AdviceBinding removedBinding: removedBindings)
          {
             ArrayList<Advisor> ads = removedBinding.getAdvisors();
@@ -1463,18 +1462,9 @@
       synchronized(this)
       {
          removedBinding = internalRemoveBinding(binding.getName());
-         affectedAdvisors = removedBinding == null ? null : new HashSet<Advisor>(removedBinding.getAdvisors());
-         initPointcutsMap();
-         initPointcutInfosMap();
-         synchronized (pointcuts)
-         {
-            Pointcut pointcut = binding.getPointcut();
-            pointcuts.put(pointcut.getName(), pointcut);
-            pointcutInfos.put(pointcut.getName(), new PointcutInfo(pointcut, binding, this.transformationStarted));
-            updatePointcutStats(pointcut);
-         }
-         
+         affectedAdvisors = removedBinding == null ? null : new HashSet<Advisor>(removedBinding.getAdvisors());         
          bindingCollection.add(binding);
+         updatePointcutStats(binding.getPointcut());
       }
       synchronized (advisors)
       {
@@ -2083,7 +2073,7 @@
    public void setDynamicAOPStrategy(DynamicAOPStrategy strategy)
    {
       // avoid users calling this method in run time
-      if (this.transformationStarted)
+      if (hasTransformationStarted())
       {
          throw new RuntimeException("Dynamic AOP Strategy Update not allowed in run time");
       }
@@ -2099,7 +2089,7 @@
       bindingCollection.lockWrite();
       try
       {
-         AdviceBinding binding = bindingCollection.remove(name);
+         AdviceBinding binding = bindingCollection.removeBinding(name);
          if (binding == null)
          {
             return null;
@@ -2224,8 +2214,11 @@
       lifecycleManager.removeLifecycleBinding(name);
    }
 
+   public static boolean hasTransformationStarted()
+   {
+      return WeavingStrategySupport.transformationStarted();
+   }
 
-
 //   public void dumpSubDomainsAndAdvisors(int indent)
 //   {
 //      indent(indent);
@@ -2509,35 +2502,6 @@
       }
    }
 
-   protected void initPointcutsMap()
-   {
-      if (pointcuts == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
-      {
-         synchronized(lazyCollectionLock)
-         {
-            if (pointcuts == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
-            {
-               pointcuts = new LinkedHashMap<String, Pointcut>();
-            }
-         }
-      }
-   }
-
-   protected void initPointcutInfosMap()
-   {
-      if (pointcutInfos == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
-      {
-         synchronized(lazyCollectionLock)
-         {
-            if (pointcutInfos == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
-            {
-               pointcutInfos = new LinkedHashMap<String, PointcutInfo>();
-            }
-         }
-      }
-   }
-
-
    protected void initClassMetaDataMap()
    {
       if (classMetaData == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)

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-11 16:44:09 UTC (rev 78454)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java	2008-09-11 17:04:34 UTC (rev 78455)
@@ -41,7 +41,7 @@
 
 import org.jboss.aop.advice.AdviceBinding;
 import org.jboss.aop.advice.AspectDefinition;
-import org.jboss.aop.advice.ClassifiedBindingCollection;
+import org.jboss.aop.advice.ClassifiedBindingAndPointcutCollection;
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.aop.instrument.ConstructorExecutionTransformer;
 import org.jboss.aop.instrument.FieldAccessTransformer;
@@ -619,7 +619,7 @@
    @SuppressWarnings("deprecation")
    private void resolveBindings(AspectManager manager)
    {
-      ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+      ClassifiedBindingAndPointcutCollection bindingCol = manager.getBindingCollection();
       bindingCol.lockRead(true);
       try
       {
@@ -1593,7 +1593,7 @@
          if (calledMethod == null) throw new RuntimeException("Unable to figure out calledmethod of a caller pointcut");
 
          boolean matched = false;
-         ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+         ClassifiedBindingAndPointcutCollection bindingCol = manager.getBindingCollection();
          for (AdviceBinding binding : bindingCol.getConstructorCallBindings())
          {
             if (binding.getPointcut().matchesCall(this, callingConstructor, called, calledMethod))
@@ -1655,7 +1655,7 @@
          if (calledCon == null) throw new RuntimeException("Unable to figure out calledcon of a caller pointcut");
 
          boolean matched = false;
-         ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+         ClassifiedBindingAndPointcutCollection bindingCol = manager.getBindingCollection();
          for (AdviceBinding binding : bindingCol.getConstructorCallBindings())
          {
             if (binding.getPointcut().matchesCall(this, callingConstructor, called, calledCon))
@@ -2740,7 +2740,7 @@
             if (calledCon == null) throw new RuntimeException("Unable to figure out calledcon of a constructor caller pointcut");
 
             boolean matched = false;
-            ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+            ClassifiedBindingAndPointcutCollection bindingCol = manager.getBindingCollection();
             for (AdviceBinding binding : bindingCol.getConstructorCallBindings())
             {
                if (binding.getPointcut().matchesCall(ClassAdvisor.this, callingMethod, called, calledCon))

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ClassContainer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ClassContainer.java	2008-09-11 16:44:09 UTC (rev 78454)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ClassContainer.java	2008-09-11 17:04:34 UTC (rev 78455)
@@ -31,7 +31,7 @@
 import java.util.Collections;
 
 import org.jboss.aop.advice.AdviceBinding;
-import org.jboss.aop.advice.ClassifiedBindingCollection;
+import org.jboss.aop.advice.ClassifiedBindingAndPointcutCollection;
 import org.jboss.aop.metadata.ClassMetaDataBinding;
 import org.jboss.aop.metadata.ClassMetaDataLoader;
 import org.jboss.aop.util.Advisable;
@@ -322,7 +322,7 @@
 
    private void makeInterceptorChains()
    {
-      ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+      ClassifiedBindingAndPointcutCollection bindingCol = manager.getBindingCollection();
       bindingCol.lockRead(true);
       try
       {

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ClassicWeavingStrategy.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ClassicWeavingStrategy.java	2008-09-11 16:44:09 UTC (rev 78454)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ClassicWeavingStrategy.java	2008-09-11 17:04:34 UTC (rev 78455)
@@ -52,7 +52,7 @@
           return null;
        }
        setReEntry();
-       manager.transformationStarted = true;
+       super.setTransformationStarted();
        try
        {
           if (manager.isNonAdvisableClassName(className))

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-11 16:44:09 UTC (rev 78454)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java	2008-09-11 17:04:34 UTC (rev 78455)
@@ -35,7 +35,7 @@
 import org.jboss.aop.advice.AdviceBinding;
 import org.jboss.aop.advice.AdviceStack;
 import org.jboss.aop.advice.AspectDefinition;
-import org.jboss.aop.advice.ClassifiedBindingCollection;
+import org.jboss.aop.advice.ClassifiedBindingAndPointcutCollection;
 import org.jboss.aop.advice.DynamicCFlowDefinition;
 import org.jboss.aop.advice.InterceptorFactory;
 import org.jboss.aop.advice.PrecedenceDef;
@@ -52,6 +52,8 @@
 import org.jboss.aop.pointcut.PointcutStats;
 import org.jboss.aop.pointcut.Typedef;
 import org.jboss.aop.pointcut.ast.ClassExpression;
+import org.jboss.aop.util.UnmodifiableEmptyCollections;
+import org.jboss.aop.util.UnmodifiableLinkedHashMap;
 
 /**
  * Comment
@@ -82,13 +84,22 @@
 
    public Domain(AspectManager manager, String name, boolean parentFirst)
    {
-      this.bindingCollection = new DomainClassifiedBindingCollection();
       this.parent = manager;
       this.parentFirst = parentFirst;
       this.name = name;
       manager.addSubDomainByName(this);
    }
 
+   /**
+    * Creates the binding collection to be used as the collection by this domain
+    * @return a {@link DomainClassifiedBindingAndPointcutCollection}
+    */
+   @Override
+   protected ClassifiedBindingAndPointcutCollection createBindingCollection()
+   {
+      return new DomainClassifiedBindingAndPointcutCollection();
+   }
+
    // FIXME: JBAOP-107 REMOVE THIS HACK
    public boolean isValid()
    {
@@ -194,6 +205,7 @@
    {
       super.removeBinding(name);
       hasOwnBindings = !bindingCollection.isEmpty();
+      hasOwnPointcuts = !bindingCollection.hasPointcuts();
    }
    
    @Override
@@ -201,29 +213,13 @@
    {
       super.removeBindings(binds);
       hasOwnBindings = !bindingCollection.isEmpty();
-      hasOwnPointcuts = !bindingCollection.isEmpty();
+      hasOwnPointcuts = !bindingCollection.hasPointcuts();
    }
    
    @Override
    public LinkedHashMap<String, Pointcut> getPointcuts()
    {
-      if (inheritsBindings)
-      {
-         if (!parentFirst)
-         {
-            // when child first, parent bindings go in first so that they can be overridden by child.
-            LinkedHashMap<String, Pointcut> map = new LinkedHashMap<String, Pointcut>(parent.getPointcuts());
-            map.putAll(this.pointcuts);
-            return map;
-         }
-         else
-         {
-            LinkedHashMap<String, Pointcut> map = new LinkedHashMap<String, Pointcut>(this.pointcuts);
-            map.putAll(parent.getPointcuts());
-            return map;
-         }
-      }
-      return super.getPointcuts();
+      return bindingCollection.getPointcuts(); 
    }
 
    public boolean hasOwnPointcuts()
@@ -242,29 +238,13 @@
    public void removePointcut(String name)
    {
       super.removePointcut(name);
-      hasOwnPointcuts = pointcuts.size() > 0;
+      hasOwnPointcuts = bindingCollection.hasPointcuts();
    }
 
    @Override
    public LinkedHashMap<String, PointcutInfo> getPointcutInfos()
    {
-      if (inheritsBindings)
-      {
-         if (!parentFirst)
-         {
-            // when child first, parent bindings go in first so that they can be overridden by child.
-            LinkedHashMap<String, PointcutInfo> map = new LinkedHashMap<String, PointcutInfo>(parent.getPointcutInfos());
-            map.putAll(this.pointcutInfos);
-            return map;
-         }
-         else
-         {
-            LinkedHashMap<String, PointcutInfo> map = new LinkedHashMap<String, PointcutInfo>(this.pointcutInfos);
-            map.putAll(parent.getPointcutInfos());
-            return map;
-         }
-      }
-      return super.getPointcutInfos();
+      return bindingCollection.getPointcutInfos();
    }
 
    @Override
@@ -1103,17 +1083,42 @@
       return parent.isSet();
    }
    
-   private class DomainClassifiedBindingCollection extends ClassifiedBindingCollection
+   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)
+            {
+               return new LinkedHashMap<String, AdviceBinding>(overall);
+            }
+            return overall;
+         }
+         finally
+         {
+            unlockRead(true);
+         }
+
+      }  
+      
+      @Override
       public Collection<AdviceBinding> getFieldReadBindings()
       {
          lockRead(true);
          try
          {
             Collection<AdviceBinding> result = super.getFieldReadBindings();
-            Collection<AdviceBinding> parentResult = parent.getBindingCollection().
-               getFieldReadBindings();
+            Collection<AdviceBinding> parentResult = 
+               inheritsBindings ?
+                     parent.getBindingCollection().getFieldReadBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
             return unifyCollections(result, parentResult, parentFirst);
          }
          finally
@@ -1129,8 +1134,9 @@
          try
          {
             Collection<AdviceBinding> result = super.getFieldWriteBindings();
-            Collection<AdviceBinding> parentResult = parent.getBindingCollection().
-               getFieldWriteBindings();
+            Collection<AdviceBinding> parentResult = 
+               inheritsBindings ?
+                  parent.getBindingCollection().getFieldWriteBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
             return unifyCollections(result, parentResult, parentFirst);
          }
          finally
@@ -1146,8 +1152,9 @@
          try
          {
             Collection<AdviceBinding> result = super.getConstructionBindings();
-            Collection<AdviceBinding> parentResult = parent.getBindingCollection().
-               getConstructionBindings();
+            Collection<AdviceBinding> parentResult = 
+               inheritsBindings ?
+                     parent.getBindingCollection().getConstructionBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
             return unifyCollections(result, parentResult, parentFirst);
          }
          finally
@@ -1163,8 +1170,9 @@
          try
          {
             Collection<AdviceBinding> result = super.getConstructorExecutionBindings();
-            Collection<AdviceBinding> parentResult = parent.getBindingCollection().
-               getConstructorExecutionBindings();
+            Collection<AdviceBinding> parentResult = 
+               inheritsBindings ?
+                     parent.getBindingCollection().getConstructorExecutionBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
             return unifyCollections(result, parentResult, parentFirst);
          }
          finally
@@ -1180,8 +1188,9 @@
          try
          {
             Collection<AdviceBinding> result = super.getMethodExecutionBindings();
-            Collection<AdviceBinding> parentResult = parent.getBindingCollection().
-               getMethodExecutionBindings();
+            Collection<AdviceBinding> parentResult = 
+               inheritsBindings ?
+                     parent.getBindingCollection().getMethodExecutionBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
             return unifyCollections(result, parentResult, parentFirst);
          }
          finally
@@ -1197,8 +1206,9 @@
          try
          {
             Collection<AdviceBinding> result = super.getConstructorCallBindings();
-            Collection<AdviceBinding> parentResult = parent.getBindingCollection().
-               getConstructorCallBindings();
+            Collection<AdviceBinding> parentResult = 
+               inheritsBindings ?
+                     parent.getBindingCollection().getConstructorCallBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
             return unifyCollections(result, parentResult, parentFirst);
          }
          finally
@@ -1214,8 +1224,9 @@
          try
          {
             Collection<AdviceBinding> result = super.getMethodCallBindings();
-            Collection<AdviceBinding> parentResult = parent.getBindingCollection().
-               getMethodCallBindings();
+            Collection<AdviceBinding> parentResult = 
+               inheritsBindings ? 
+                     parent.getBindingCollection().getMethodCallBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
             return unifyCollections(result, parentResult, parentFirst);
          }
          finally
@@ -1223,7 +1234,53 @@
             unlockRead(true);
          }
       }
-      
+
+      @Override
+      public LinkedHashMap<String, Pointcut> getPointcuts()
+      {
+         lockRead(true);
+         try
+         {
+            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
+         {
+            unlockRead(true);
+         }
+      }
+
+      @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)
+            {
+               return new LinkedHashMap<String, PointcutInfo>(overall);
+            }
+            return overall;
+         }
+         finally
+         {
+            unlockRead(true);
+         }
+      }
+
       private <T> Collection<T> unifyCollections(Collection<T> collection1,
             Collection<T> collection2, boolean prioritizeFirst)
       {
@@ -1249,6 +1306,31 @@
          return collection1;
       }
 
+      private <T, K> LinkedHashMap<T, K> unifyMaps(LinkedHashMap<T, K> map1,
+            LinkedHashMap<T, K> map2, boolean prioritizeFirst)
+      {
+         if (map1.isEmpty())
+         {
+            return new UnmodifiableLinkedHashMap<T, K>(map2);
+         }
+         if (map2.isEmpty())
+         {
+            return new UnmodifiableLinkedHashMap<T, K>(map1);
+         }
+         if (prioritizeFirst)
+         {
+            map1 = new LinkedHashMap<T, K>(map1);
+            map1.putAll(map2);
+         }
+         else
+         {
+            LinkedHashMap<T, K> temp = map1;
+            map1 = new LinkedHashMap<T, K>(map2);
+            map1.putAll(temp);
+         }
+         return map1;
+      }
+
       @Override
       public void lockRead(boolean lockParents)
       {

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java	2008-09-11 16:44:09 UTC (rev 78454)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java	2008-09-11 17:04:34 UTC (rev 78455)
@@ -42,7 +42,7 @@
 
 import org.jboss.aop.advice.AdviceBinding;
 import org.jboss.aop.advice.AspectDefinition;
-import org.jboss.aop.advice.ClassifiedBindingCollection;
+import org.jboss.aop.advice.ClassifiedBindingAndPointcutCollection;
 import org.jboss.aop.advice.InterceptorFactory;
 import org.jboss.aop.introduction.AnnotationIntroduction;
 import org.jboss.aop.microcontainer.lifecycle.LifecycleCallbackBinding;
@@ -92,7 +92,7 @@
    {
       if (!initialisedAspects)
       {
-         ClassifiedBindingCollection bindingCol = advisor.getManager().getBindingCollection();
+         ClassifiedBindingAndPointcutCollection bindingCol = advisor.getManager().getBindingCollection();
          bindingCol.lockRead(true);
          try
          {
@@ -175,25 +175,11 @@
       }
    }
    
-   @Deprecated
-   protected void bindMethodAdvices(Class<?> superClass, Map<String, AdviceBinding> bindings)
+   protected void bindMethodAdvices(Class<?> superClass, ClassifiedBindingAndPointcutCollection bindingCol)
    {
       createMethodMap(superClass); 
       if (methodMap != null)
       {
-         Object[] methods = methodMap.getValues();
-         for (int i = 0 ; i < methods.length ; i++)
-         {
-            bindMethodAdvice((Method)methods[i], bindings);
-         }
-      }
-   }
-   
-   protected void bindMethodAdvices(Class<?> superClass, ClassifiedBindingCollection bindingCol)
-   {
-      createMethodMap(superClass); 
-      if (methodMap != null)
-      {
          Collection<AdviceBinding> bindings = bindingCol.getMethodExecutionBindings();
          Object[] methods = methodMap.getValues();
          for (int i = 0 ; i < methods.length ; i++)
@@ -203,8 +189,7 @@
       }
    }
 
-   @Deprecated
-   protected void bindConstructorAdvices(Map<String, AdviceBinding> bindings)
+   void bindConstructorAdvices(ClassifiedBindingAndPointcutCollection bindingCol)
    {
       Constructor<?>[] cons = AccessController.doPrivileged(new PrivilegedAction<Constructor<?>[]>() 
       {
@@ -213,21 +198,6 @@
             return clazz.getDeclaredConstructors();
          }
       });
-      for (int i = 0; i < cons.length; i++)
-      {
-         bindConstructorAdvice(cons[i], bindings);
-      }
-   }
-   
-   void bindConstructorAdvices(ClassifiedBindingCollection bindingCol)
-   {
-      Constructor<?>[] cons = AccessController.doPrivileged(new PrivilegedAction<Constructor<?>[]>() 
-      {
-         public Constructor<?>[] run()
-         {
-            return clazz.getDeclaredConstructors();
-         }
-      });
       Collection<AdviceBinding> bindings = bindingCol.getConstructorExecutionBindings();
       for (int i = 0; i < cons.length; i++)
       {
@@ -235,8 +205,7 @@
       }
    }
 
-   @Deprecated
-   protected void bindFieldAdvices(Map<String, AdviceBinding> bindings)
+   protected void bindFieldAdvices(ClassifiedBindingAndPointcutCollection bindingCol)
    {
       Field[] fields = AccessController.doPrivileged(new PrivilegedAction<Field[]>() 
       {
@@ -245,22 +214,6 @@
             return clazz.getDeclaredFields();
          }
       });
-      for (int i = 0; i < fields.length; i++)
-      {
-         bindFieldGetAdvice(fields[i], bindings);
-         bindFieldSetAdvice(fields[i], bindings);
-      }
-   }
-   
-   protected void bindFieldAdvices(ClassifiedBindingCollection bindingCol)
-   {
-      Field[] fields = AccessController.doPrivileged(new PrivilegedAction<Field[]>() 
-      {
-         public Field[] run()
-         {
-            return clazz.getDeclaredFields();
-         }
-      });
       Collection<AdviceBinding> bindings = bindingCol.getFieldReadBindings();
       for (int i = 0; i < fields.length; i++)
       {

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/SuperClassesFirstWeavingStrategy.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/SuperClassesFirstWeavingStrategy.java	2008-09-11 16:44:09 UTC (rev 78454)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/SuperClassesFirstWeavingStrategy.java	2008-09-11 17:04:34 UTC (rev 78455)
@@ -54,7 +54,7 @@
          return null;
       }
       setReEntry();
-      manager.transformationStarted = true;
+      super.setTransformationStarted();
       try
       {
          if (manager.isNonAdvisableClassName(className))

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/WeavingStrategySupport.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/WeavingStrategySupport.java	2008-09-11 16:44:09 UTC (rev 78454)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/WeavingStrategySupport.java	2008-09-11 17:04:34 UTC (rev 78455)
@@ -24,10 +24,13 @@
 /**
  *
  * @author <a href="stalep at conduct.no">Stale W. Pedersen</a>
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
  * @version $Revision:
  */
 public abstract class WeavingStrategySupport implements WeavingStrategy
 {
+   // indicates that the transformation process has begun
+   private static boolean transformationStarted = false;
    
    private static ThreadLocal<Boolean> REENTRY = new ThreadLocal<Boolean>()
    {
@@ -62,4 +65,14 @@
    {
       REENTRY.set(Boolean.FALSE);
    }
+   
+   protected static boolean transformationStarted()
+   {
+      return transformationStarted;
+   }
+   
+   protected void setTransformationStarted()
+   {
+      transformationStarted = true;
+   }
 }

Copied: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java (from rev 78319, projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingCollection.java)
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java	2008-09-11 17:04:34 UTC (rev 78455)
@@ -0,0 +1,725 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.aop.advice;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.pointcut.Pointcut;
+import org.jboss.aop.pointcut.PointcutInfo;
+import org.jboss.aop.util.BindingClassifier;
+import org.jboss.aop.util.UnmodifiableEmptyCollections;
+import org.jboss.aop.util.UnmodifiableLinkedHashMap;
+import org.jboss.aop.util.logging.AOPLogger;
+
+/**
+ * Manages the binding, pointcut and pointcutInfo collections contained in a domain. All entries
+ * contained in this collection are indexed according to their classification.
+ * <p>
+ * <i>For internal use only.</i>
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @author  <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ */
+public class ClassifiedBindingAndPointcutCollection
+{
+   private static final AOPLogger logger = AOPLogger.getLogger(AspectManager.class);
+   
+   private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+  
+   //Collections of bindings
+   private volatile LinkedHashMap<String, AdviceBinding> bindings;
+   private volatile Collection<AdviceBinding> fieldReadBindings;
+   private volatile Collection<AdviceBinding> fieldWriteBindings;
+   private volatile Collection<AdviceBinding> constructionBindings;
+   private volatile Collection<AdviceBinding> constructorExecutionBindings;
+   private volatile Collection<AdviceBinding> methodExecutionBindings;
+   private volatile Collection<AdviceBinding> constructorCallBindings;
+   private volatile Collection<AdviceBinding> methodCallBindings;
+   
+   //Collections of pointcuts
+   private volatile LinkedHashMap<String, Pointcut> pointcuts;
+   
+   //Collections of pointcutInfos
+   private volatile LinkedHashMap<String, PointcutInfo> pointcutInfos;
+   
+   //Pointcut stats 
+   protected boolean execution = false;
+   protected boolean construction = false;
+   protected boolean call = false;
+   protected boolean within = false;
+   protected boolean get = false;
+   protected boolean set = false;
+   protected boolean withincode = false;
+   public static boolean classicOrder = false;
+
+   /**
+    * Constructor.<p>
+    */
+   @SuppressWarnings("all")
+   public ClassifiedBindingAndPointcutCollection()
+   {
+      bindings = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+      this.fieldReadBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+      this.fieldWriteBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+      this.constructionBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+      this.constructorExecutionBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+      this.methodExecutionBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+      this.constructorCallBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+      this.methodCallBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+      
+      pointcuts = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+      
+      pointcutInfos = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   }
+   
+   /**
+    * Check if there are any pointcuts stored at this level
+    */
+   public boolean hasPointcuts()
+   {
+      return pointcuts.size() > 0;
+   }
+   
+   /**
+    * Returns only the bindings whose pointcuts may match successfully field read
+    * joinpoints.<p>
+    * <b>Attention:</b> this collection is not supposed to be edited.
+    * 
+    * @return a collection containing exclusively the bindings that may match field
+    *         read pointcuts
+    */
+   public Collection<AdviceBinding> getFieldReadBindings()
+   {
+      lockRead();
+      try
+      {
+         return this.fieldReadBindings;
+      }
+      finally
+      {
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Returns only the bindings whose pointcuts may match successfully field write
+    * joinpoints.<p>
+    * <b>Attention:</b> this collection is not supposed to be edited.
+    * 
+    * @return a collection containing exclusively the bindings that may match field
+    *         write pointcuts
+    */
+   public Collection<AdviceBinding> getFieldWriteBindings()
+   {
+      lockRead();
+      try
+      {
+         return this.fieldWriteBindings;
+      }
+      finally
+      {
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Returns only the bindings whose pointcuts may match successfully construction
+    * joinpoints.<p>
+    * <b>Attention:</b> this collection is not supposed to be edited.
+    * 
+    * @return a collection containing exclusively the bindings that may match
+    *         construction pointcuts
+    */
+   public Collection<AdviceBinding> getConstructionBindings()
+   {
+      lockRead();
+      try
+      {
+         return this.constructionBindings;
+      }
+      finally
+      {
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Returns only the bindings whose pointcuts may match successfully constructor
+    * execution joinpoints.<p>
+    * <b>Attention:</b> this collection is not supposed to be edited.
+    * 
+    * @return a collection containing exclusively the bindings that may match
+    *         constructor execution pointcuts
+    */
+   public Collection<AdviceBinding> getConstructorExecutionBindings()
+   {
+      lockRead();
+      try
+      {
+         return this.constructorExecutionBindings;
+      }
+      finally
+      {
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Returns only the bindings whose pointcuts may match successfully method
+    * execution joinpoints.<p>
+    * <b>Attention:</b> this collection is not supposed to be edited.
+    * 
+    * @return a collection containing exclusively the bindings that may match
+    *         method execution pointcuts
+    */
+   public Collection<AdviceBinding> getMethodExecutionBindings()
+   {
+      lockRead();
+      try
+      {
+         return this.methodExecutionBindings;
+      }
+      finally
+      {
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Returns only the bindings whose pointcuts may match successfully constructor
+    * call joinpoints.
+    * <p>
+    * <b>Attention:</b> this collection is not supposed to be edited.
+    * 
+    * @return a collection containing exclusively the bindings that may match
+    *         constructor call pointcuts
+    */
+   public Collection<AdviceBinding> getConstructorCallBindings()
+   {
+      lockRead();
+      try
+      {
+         return this.constructorCallBindings;
+      }
+      finally
+      {
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Returns only the bindings whose pointcuts may match successfully method
+    * call joinpoints.<p>
+    * <b>Attention:</b> this collection is not supposed to be edited.
+    * 
+    * @return a collection containing exclusively the bindings that may match
+    *         method call pointcuts
+    */
+   public Collection<AdviceBinding> getMethodCallBindings()
+   {
+      lockRead();
+      try
+      {
+         return this.methodCallBindings;
+      }
+      finally
+      {
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Indicate whether this collection is empty.
+    */
+   public boolean isEmpty()
+   {
+      lockRead();
+      try
+      {
+         return this.bindings.isEmpty();
+      }
+      finally
+      {
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Returns the bindings map.
+    * @return an unmodifiable map containing all the bindings
+    */
+   public LinkedHashMap<String, AdviceBinding> getBindings()
+   {
+      lockRead();
+      try
+      {
+         return new UnmodifiableLinkedHashMap<String, AdviceBinding>(bindings);
+      }
+      finally
+      { 
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Returns the bindings map. This method is only for internal use, hence the @Deprecated
+    * @return a map containing all the bindings
+    */
+   @Deprecated
+   public LinkedHashMap<String, AdviceBinding> getBindingsInternal()
+   {
+      lockRead();
+      try
+      {
+         return new UnmodifiableLinkedHashMap<String, AdviceBinding>(bindings);
+      }
+      finally
+      { 
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Returns the pointcuts map.
+    * @return an unmodifiable map containing all the pointcuts
+    */
+   public LinkedHashMap<String, Pointcut> getPointcuts()
+   {
+      lockRead();
+      try
+      {
+         return pointcuts;
+      }
+      finally
+      { 
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Returns the pointcuts map. This method is only for internal use, hence the @Deprecated
+    * @return a map containing all the pointcuts
+    */
+   @Deprecated
+   public LinkedHashMap<String, Pointcut> getPointcutsInternal()
+   {
+      lockRead();
+      try
+      {
+         return pointcuts;
+      }
+      finally
+      { 
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Returns the pointcutInfos map.
+    * @return an unmodifiable map containing all the pointcutInfos
+    */
+   public LinkedHashMap<String, PointcutInfo> getPointcutInfos()
+   {
+      lockRead();
+      try
+      {
+         return new UnmodifiableLinkedHashMap<String, PointcutInfo>(pointcutInfos);
+      }
+      finally
+      { 
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Returns the pointcutInfos map. This method is only for internal use, hence the @Deprecated
+    * @return an unmodifiable map containing all the pointcutInfos
+    */
+   @Deprecated
+   public LinkedHashMap<String, PointcutInfo> getPointcutInfosInternal()
+   {
+      lockRead();
+      try
+      {
+         return pointcutInfos;
+      }
+      finally
+      { 
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Adds a binding to this collection.
+    */
+   public void add(AdviceBinding binding)
+   {
+      lockWrite();
+      try
+      {
+         addBinding(binding);
+         addGet(binding);
+         addSet(binding);
+         addConstruction(binding);
+         addConstructorExecution(binding);
+         addMethodExecution(binding);
+         addConstructorCall(binding);
+         addMethodCall(binding);
+      }
+      finally
+      {
+         unlockWrite();
+      }
+   }
+
+   /**
+    * Adds a pointcut to this collection
+    */
+   public void add(Pointcut pointcut)
+   {
+      lockWrite();
+      try
+      {
+         removePointcut(pointcut.getName());
+         addPointcut(pointcut);
+      }
+      finally
+      {
+         unlockWrite();
+      }
+   }
+   
+   /**
+    * Removes the binding named {@code name}.
+    * 
+    * @param name name of the binding to be removed.
+    * @return the removed binding. If {@code null}, indicates that there is no
+    *         binding with name equal to {@code name} in this collection.
+    */
+   public AdviceBinding removeBinding(String name)
+   {
+      lockWrite();
+      try
+      {
+         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;
+      }
+      finally
+      {
+         unlockWrite();
+      }
+   }
+   
+   /**
+    * 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();
+      }
+   }
+   
+   /**
+    * Gets the pointcut named {@code name}
+    * @param name the name of the pointcut to get
+    * @return the pointcut
+    */
+   public Pointcut getPointcut(String name)
+   {
+      lockRead();
+      try
+      {
+         return pointcuts.get(name);
+      }
+      finally
+      {
+         unlockRead();
+      }
+   }
+   
+   /**
+    * Removes all bindings whose names are contained in {@code names}.
+    * 
+    * @param names names of all bindings to be removed
+    * @return the collection of the removed bindings
+    */
+   public ArrayList<AdviceBinding> removeBindings(ArrayList<String> names)
+   {
+      lockWrite();
+      try
+      {
+         ArrayList<AdviceBinding> removedBindings = new ArrayList<AdviceBinding>();
+         for (String name: names)
+         {
+            AdviceBinding binding = this.removeBinding(name);
+            if (binding == null)
+            {
+               logger.debug("ClassifiedBindingCollection.removeBindings() no binding found with name " + name);
+               continue;
+            }
+            removedBindings.add(binding);
+         }
+         return removedBindings;
+      }
+      finally
+      {
+         unlockWrite();
+      }
+   }
+
+   public boolean isExecution()
+   {
+      return execution;
+   }
+
+   public boolean isConstruction()
+   {
+      return construction;
+   }
+
+   public boolean isCall()
+   {
+      return call;
+   }
+
+   public boolean isWithin()
+   {
+      return within;
+   }
+
+   public boolean isWithincode()
+   {
+      return withincode;
+   }
+
+   public boolean isGet()
+   {
+      return get;
+   }
+
+   public boolean isSet()
+   {
+      return set;
+   }
+
+   /**
+    * Read-lock just this collection
+    */
+   public final void lockRead()
+   {
+      lock.readLock().lock();
+   }
+   
+   /**
+    * Read-unlock just this collection
+    */
+   protected final void unlockRead()
+   {
+      lock.readLock().unlock();
+   }
+   
+   /**
+    * Write-lock just this collection
+    */
+   public final void lockWrite()
+   {
+      lock.writeLock().lock();
+   }
+   
+   /**
+    * Write-unlock this collection
+    */
+   public final void unlockWrite()
+   {
+      lock.writeLock().unlock();
+   }
+
+   /**
+    * Read-lock this collection
+    * @param if true, parent collections will be locked too
+    */
+   public void lockRead(boolean lockParents)
+   {
+      lockRead();
+   }
+   
+   /**
+    * Read-unlock this collection
+    * @param if true, parent collections will be unlocked too
+    */
+   public void unlockRead(boolean lockParents)
+   {
+      unlockRead();
+   }
+   
+   /**
+    * Write-lock this collection
+    * @param if true, parent collections will be locked too
+    */
+   public void lockWrite(boolean lockParents)
+   {
+      lockWrite();
+   }
+   
+   /**
+    * Write-unlock this collection
+    * @param if true, parent collections will be unlocked too
+    */
+   public void unlockWrite(boolean lockParents)
+   {
+      unlockWrite();
+   }
+   
+   private void addBinding(AdviceBinding binding)
+   {
+      if (bindings == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
+      {
+         bindings = new LinkedHashMap<String, AdviceBinding>();
+      }
+      bindings.put(binding.getName(), binding);
+      
+      addPointcut(binding.getPointcut());
+   }
+   
+   private void addGet(AdviceBinding binding)
+   {
+      if (BindingClassifier.isGet(binding))
+      {
+         if (fieldReadBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
+         {
+            fieldReadBindings = new CopyOnWriteArraySet<AdviceBinding>();
+         }
+         this.fieldReadBindings.add(binding);
+      }
+   }
+   
+   private void addSet(AdviceBinding binding)
+   {
+      if (BindingClassifier.isSet(binding))
+      {
+         if (fieldWriteBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
+         {
+            fieldWriteBindings = new CopyOnWriteArraySet<AdviceBinding>();
+         }
+         this.fieldWriteBindings.add(binding);
+      }
+   }
+   
+   private void addConstruction(AdviceBinding binding)
+   {
+      if (BindingClassifier.isConstruction(binding))
+      {
+         if (constructionBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
+         {
+            constructionBindings = new CopyOnWriteArraySet<AdviceBinding>();
+         }
+         this.constructionBindings.add(binding);
+      }
+   }
+   
+   private void addConstructorExecution(AdviceBinding binding)
+   {
+      if (BindingClassifier.isConstructorExecution(binding))
+      {
+         if (constructorExecutionBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
+         {
+            constructorExecutionBindings = new CopyOnWriteArraySet<AdviceBinding>();
+         }
+         this.constructorExecutionBindings.add(binding);
+      }
+   }
+   
+   private void addMethodExecution(AdviceBinding binding)
+   {
+      if (BindingClassifier.isMethodExecution(binding))
+      {
+         if (methodExecutionBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
+         {
+            methodExecutionBindings = new CopyOnWriteArraySet<AdviceBinding>();
+         }
+         this.methodExecutionBindings.add(binding);
+      }
+   }
+   
+   private void addMethodCall(AdviceBinding binding)
+   {
+      if (BindingClassifier.isMethodCall(binding))
+      {
+         if (methodCallBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
+         {
+            methodCallBindings = new CopyOnWriteArraySet<AdviceBinding>();
+         }
+         this.methodCallBindings.add(binding);
+      }
+   }
+   
+   private void addConstructorCall(AdviceBinding binding)
+   {
+      if (BindingClassifier.isConstructorCall(binding))
+      {
+         if (constructorCallBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
+         {
+            constructorCallBindings = new CopyOnWriteArraySet<AdviceBinding>();
+         }
+         this.constructorCallBindings.add(binding);
+      }
+   }
+   
+   private void addPointcut(Pointcut pointcut)
+   {
+      if (pointcuts == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
+      {
+         pointcuts = new LinkedHashMap<String, Pointcut>();
+      }
+      pointcuts.put(pointcut.getName(), pointcut);
+
+      if (pointcutInfos == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
+      {
+         pointcutInfos = new LinkedHashMap<String, PointcutInfo>();
+      }
+      pointcutInfos.put(pointcut.getName(), new PointcutInfo(pointcut, AspectManager.hasTransformationStarted()));
+   }
+}

Deleted: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingCollection.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingCollection.java	2008-09-11 16:44:09 UTC (rev 78454)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingCollection.java	2008-09-11 17:04:34 UTC (rev 78455)
@@ -1,503 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.aop.advice;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.util.BindingClassifier;
-import org.jboss.aop.util.UnmodifiableEmptyCollections;
-import org.jboss.aop.util.UnmodifiableLinkedHashMap;
-import org.jboss.aop.util.logging.AOPLogger;
-
-/**
- * Manages the binding collection contained in a domain. All bindings
- * contained in this collection are indexed according to their classification.
- * <p>
- * <i>For internal use only.</i>
- * 
- * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
- */
-public class ClassifiedBindingCollection
-{
-   private static final AOPLogger logger = AOPLogger.getLogger(AspectManager.class);
-   
-   private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
-  
-   private volatile LinkedHashMap<String, AdviceBinding> bindings;
-   private volatile Collection<AdviceBinding> fieldReadBindings;
-   private volatile Collection<AdviceBinding> fieldWriteBindings;
-   private volatile Collection<AdviceBinding> constructionBindings;
-   private volatile Collection<AdviceBinding> constructorExecutionBindings;
-   private volatile Collection<AdviceBinding> methodExecutionBindings;
-   private volatile Collection<AdviceBinding> constructorCallBindings;
-   private volatile Collection<AdviceBinding> methodCallBindings;
-   
-   /**
-    * Constructor.<p>
-    * All created instances must be initialized before being used for addition and
-    * removal operations, by calling {@code initialize()}.
-    */
-   @SuppressWarnings("all")
-   public ClassifiedBindingCollection()
-   {
-      bindings = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-      this.fieldReadBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-      this.fieldWriteBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-      this.constructionBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-      this.constructorExecutionBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-      this.methodExecutionBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-      this.constructorCallBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-      this.methodCallBindings = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
-   }
-   
-   /**
-    * Returns only the bindings whose pointcuts may match successfully field read
-    * joinpoints.<p>
-    * <b>Attention:</b> this collection is not supposed to be edited.
-    * 
-    * @return a collection containing exclusively the bindings that may match field
-    *         read pointcuts
-    */
-   public Collection<AdviceBinding> getFieldReadBindings()
-   {
-      lockRead();
-      try
-      {
-         return this.fieldReadBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
-   }
-   
-   /**
-    * Returns only the bindings whose pointcuts may match successfully field write
-    * joinpoints.<p>
-    * <b>Attention:</b> this collection is not supposed to be edited.
-    * 
-    * @return a collection containing exclusively the bindings that may match field
-    *         write pointcuts
-    */
-   public Collection<AdviceBinding> getFieldWriteBindings()
-   {
-      lockRead();
-      try
-      {
-         return this.fieldWriteBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
-   }
-   
-   /**
-    * Returns only the bindings whose pointcuts may match successfully construction
-    * joinpoints.<p>
-    * <b>Attention:</b> this collection is not supposed to be edited.
-    * 
-    * @return a collection containing exclusively the bindings that may match
-    *         construction pointcuts
-    */
-   public Collection<AdviceBinding> getConstructionBindings()
-   {
-      lockRead();
-      try
-      {
-         return this.constructionBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
-   }
-   
-   /**
-    * Returns only the bindings whose pointcuts may match successfully constructor
-    * execution joinpoints.<p>
-    * <b>Attention:</b> this collection is not supposed to be edited.
-    * 
-    * @return a collection containing exclusively the bindings that may match
-    *         constructor execution pointcuts
-    */
-   public Collection<AdviceBinding> getConstructorExecutionBindings()
-   {
-      lockRead();
-      try
-      {
-         return this.constructorExecutionBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
-   }
-   
-   /**
-    * Returns only the bindings whose pointcuts may match successfully method
-    * execution joinpoints.<p>
-    * <b>Attention:</b> this collection is not supposed to be edited.
-    * 
-    * @return a collection containing exclusively the bindings that may match
-    *         method execution pointcuts
-    */
-   public Collection<AdviceBinding> getMethodExecutionBindings()
-   {
-      lockRead();
-      try
-      {
-         return this.methodExecutionBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
-   }
-   
-   /**
-    * Returns only the bindings whose pointcuts may match successfully constructor
-    * call joinpoints.
-    * <p>
-    * <b>Attention:</b> this collection is not supposed to be edited.
-    * 
-    * @return a collection containing exclusively the bindings that may match
-    *         constructor call pointcuts
-    */
-   public Collection<AdviceBinding> getConstructorCallBindings()
-   {
-      lockRead();
-      try
-      {
-         return this.constructorCallBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
-   }
-   
-   /**
-    * Returns only the bindings whose pointcuts may match successfully method
-    * call joinpoints.<p>
-    * <b>Attention:</b> this collection is not supposed to be edited.
-    * 
-    * @return a collection containing exclusively the bindings that may match
-    *         method call pointcuts
-    */
-   public Collection<AdviceBinding> getMethodCallBindings()
-   {
-      lockRead();
-      try
-      {
-         return this.methodCallBindings;
-      }
-      finally
-      {
-         unlockRead();
-      }
-   }
-   
-   /**
-    * Indicate whether this collection is empty.
-    */
-   public boolean isEmpty()
-   {
-      lockRead();
-      try
-      {
-         return this.bindings.isEmpty();
-      }
-      finally
-      {
-         unlockRead();
-      }
-   }
-   
-   /**
-    * Returns the bindings map.
-    * <p>
-    * <b>Attention:</b> this collection is not supposed to be edited.
-    */
-   public LinkedHashMap<String, AdviceBinding> getBindings()
-   {
-      lockRead();
-      try
-      {
-         return new UnmodifiableLinkedHashMap<String, AdviceBinding>(bindings);
-      }
-      finally
-      { 
-         unlockRead();
-      }
-   }
-   
-   /**
-    * Adds a binding to this collection.
-    */
-   public void add(AdviceBinding binding)
-   {
-      lockWrite();
-      try
-      {
-         addBinding(binding);
-         addGet(binding);
-         addSet(binding);
-         addConstruction(binding);
-         addConstructorExecution(binding);
-         addMethodExecution(binding);
-         addConstructorCall(binding);
-         addMethodCall(binding);
-      }
-      finally
-      {
-         unlockWrite();
-      }
-   }
-
-   /**
-    * Removes the binding named {@code name}.
-    * 
-    * @param name name of the binding to be removed.
-    * @return the removed binding. If {@code null}, indicates that there is no
-    *         binding with name equal to {@code name} in this collection.
-    */
-   public AdviceBinding remove(String name)
-   {
-      lockWrite();
-      try
-      {
-         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;
-      }
-      finally
-      {
-         unlockWrite();
-      }
-   }
-   
-   /**
-    * Removes all bindings whose names are contained in {@code names}.
-    * 
-    * @param names names of all bindings to be removed
-    * @return the collection of the removed bindings
-    */
-   public ArrayList<AdviceBinding> remove(ArrayList<String> names)
-   {
-      lockWrite();
-      try
-      {
-         ArrayList<AdviceBinding> removedBindings = new ArrayList<AdviceBinding>();
-         for (String name: names)
-         {
-            AdviceBinding binding = this.remove(name);
-            if (binding == null)
-            {
-               logger.debug("ClassifiedBindingCollection.removeBindings() no binding found with name " + name);
-               continue;
-            }
-            removedBindings.add(binding);
-         }
-         return removedBindings;
-      }
-      finally
-      {
-         unlockWrite();
-      }
-   }
-
-   /**
-    * Read-lock just this collection
-    */
-   public final void lockRead()
-   {
-      lock.readLock().lock();
-   }
-   
-   /**
-    * Read-unlock just this collection
-    */
-   protected final void unlockRead()
-   {
-      lock.readLock().unlock();
-   }
-   
-   /**
-    * Write-lock just this collection
-    */
-   public final void lockWrite()
-   {
-      lock.writeLock().lock();
-   }
-   
-   /**
-    * Write-unlock this collection
-    */
-   public final void unlockWrite()
-   {
-      lock.writeLock().unlock();
-   }
-
-   /**
-    * Read-lock this collection
-    * @param if true, parent collections will be locked too
-    */
-   public void lockRead(boolean lockParents)
-   {
-      lockRead();
-   }
-   
-   /**
-    * Read-unlock this collection
-    * @param if true, parent collections will be unlocked too
-    */
-   public void unlockRead(boolean lockParents)
-   {
-      unlockRead();
-   }
-   
-   /**
-    * Write-lock this collection
-    * @param if true, parent collections will be locked too
-    */
-   public void lockWrite(boolean lockParents)
-   {
-      lockWrite();
-   }
-   
-   /**
-    * Write-unlock this collection
-    * @param if true, parent collections will be unlocked too
-    */
-   public void unlockWrite(boolean lockParents)
-   {
-      unlockWrite();
-   }
-   
-   private void addBinding(AdviceBinding binding)
-   {
-      if (bindings == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
-      {
-         bindings = new LinkedHashMap<String, AdviceBinding>();
-      }
-      bindings.put(binding.getName(), binding);
-   }
-   
-   private void addGet(AdviceBinding binding)
-   {
-      if (BindingClassifier.isGet(binding))
-      {
-         if (fieldReadBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
-         {
-            fieldReadBindings = new CopyOnWriteArraySet<AdviceBinding>();
-         }
-         this.fieldReadBindings.add(binding);
-      }
-   }
-   
-   private void addSet(AdviceBinding binding)
-   {
-      if (BindingClassifier.isSet(binding))
-      {
-         if (fieldWriteBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
-         {
-            fieldWriteBindings = new CopyOnWriteArraySet<AdviceBinding>();
-         }
-         this.fieldWriteBindings.add(binding);
-      }
-   }
-   
-   private void addConstruction(AdviceBinding binding)
-   {
-      if (BindingClassifier.isConstruction(binding))
-      {
-         if (constructionBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
-         {
-            constructionBindings = new CopyOnWriteArraySet<AdviceBinding>();
-         }
-         this.constructionBindings.add(binding);
-      }
-   }
-   
-   private void addConstructorExecution(AdviceBinding binding)
-   {
-      if (BindingClassifier.isConstructorExecution(binding))
-      {
-         if (constructorExecutionBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
-         {
-            constructorExecutionBindings = new CopyOnWriteArraySet<AdviceBinding>();
-         }
-         this.constructorExecutionBindings.add(binding);
-      }
-   }
-   
-   private void addMethodExecution(AdviceBinding binding)
-   {
-      if (BindingClassifier.isMethodExecution(binding))
-      {
-         if (methodExecutionBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
-         {
-            methodExecutionBindings = new CopyOnWriteArraySet<AdviceBinding>();
-         }
-         this.methodExecutionBindings.add(binding);
-      }
-   }
-   
-   private void addMethodCall(AdviceBinding binding)
-   {
-      if (BindingClassifier.isMethodCall(binding))
-      {
-         if (methodCallBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
-         {
-            methodCallBindings = new CopyOnWriteArraySet<AdviceBinding>();
-         }
-         this.methodCallBindings.add(binding);
-      }
-   }
-   
-   private void addConstructorCall(AdviceBinding binding)
-   {
-      if (BindingClassifier.isConstructorCall(binding))
-      {
-         if (constructorCallBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
-         {
-            constructorCallBindings = new CopyOnWriteArraySet<AdviceBinding>();
-         }
-         this.constructorCallBindings.add(binding);
-      }
-   }
-}




More information about the jboss-cvs-commits mailing list