[jboss-cvs] JBossAS SVN: r75065 - 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
Wed Jun 25 10:56:55 EDT 2008


Author: flavia.rainone at jboss.com
Date: 2008-06-25 10:56:55 -0400 (Wed, 25 Jun 2008)
New Revision: 75065

Added:
   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/Domain.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/InstanceDomain.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java
Log:
[JBAOP-579] Created a ClassifiedBindingCollection, that keeps bindings in classified collections for fast retrieval by Advisors.

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java	2008-06-25 14:43:30 UTC (rev 75064)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java	2008-06-25 14:56:55 UTC (rev 75065)
@@ -583,6 +583,17 @@
       return hasAnnotation(tgt, null, annotation);
    }
 
+   /**
+    * Indicates whether {@code tgt} has an annotation/meta data whose type is {@code
+    * annotationClass}, and name is {@code annotation}.
+    * 
+    * @param  tgt             the target class whose annotations/meta data will be
+    *                         examined
+    * @param  annotation      the name of an annotation
+    * @param  annotationClass the type of an annotation
+    * @return {@code true} if {@code tgt} has an annotation/meta data whose type is
+    * {@code annotationClass} and name is {@code annotation}
+    */
    private boolean hasAnnotation(Class<?> tgt, String annotation, Class<? extends Annotation> annotationClass)
    {
       if (annotation == null && annotationClass == null)
@@ -616,21 +627,59 @@
       return false;
    }
 
+   /**
+    * Returns an object representing the method {@code m} annotation of type
+    * {@code annotation}, if {@code m} has such annotation.
+    * 
+    * @param  m          the method whose annotation is being queried
+    * @param  annotation the type of the queried annotation
+    * @return the meta data/annotation of type {@code annotation} that apply to
+    *         {@code m}
+    */
    public Object resolveAnnotation(Method m, Class<? extends Annotation> annotation)
    {
       return resolveTypedAnnotation(0, m, annotation);
    }
    
+   /**
+    * Returns an object representing the method {@code m} annotation of type
+    * {@code annotation}, if {@code m} has such annotation.
+    * 
+    * @param  m          the method whose annotation is being queried
+    * @param  annotation the type of the queried annotation
+    * @return the meta data/annotation of type {@code annotation} that apply to
+    *         {@code m}
+    */
    public <T extends Annotation> T resolveTypedAnnotation(Method m, Class<T> annotation)
    {
       return resolveTypedAnnotation(0, m, annotation);
    }
 
+   /**
+    * Returns an object representing the method {@code m} annotation of type
+    * {@code annotation}, if {@code m} has such annotation.
+    * 
+    * @param hash        the hashcode of {@code m}
+    * @param  m          the method whose annotation is being queried
+    * @param  annotation the type of the queried annotation
+    * @return the meta data/annotation of type {@code annotation} that apply to
+    *         {@code m}
+    */
    public Object resolveAnnotation(long hash, Method m, Class<? extends Annotation> annotation)
    {
       return resolveTypedAnnotation(hash, m, annotation);
    }
    
+   /**
+    * Returns an object representing the method {@code m} annotation of type
+    * {@code annotation}, if {@code m} has such annotation.
+    * 
+    * @param hash        the hashcode of {@code m}
+    * @param  m          the method whose annotation is being queried
+    * @param  annotation the type of the queried annotation
+    * @return the meta data/annotation of type {@code annotation} that apply to
+    *         {@code m}
+    */
    public <T extends Annotation> T resolveTypedAnnotation(long hash, Method m, Class<T> annotation)
    {
       if (metadata != null)
@@ -656,6 +705,17 @@
       return value;
    }
 
+   /**
+    * Returns an object representing the method {@code m} annotation whose type is
+    * one of the elements in {@code annotationChoices}, if {@code m} has such
+    * annotation.
+    * 
+    * @param  m                 the method whose annotation is being queried
+    * @param  annotationChoices the queried annotation must have one of the types
+    *                           contained in this array
+    * @return the meta data/annotation that apply to {@code m} whose type is in
+    *         {@code annotationChoices} 
+    */
    public Object resolveAnnotation(Method m, Class<?>[] annotationChoices)
    {
       for (Class<?> ann : annotationChoices)
@@ -666,6 +726,17 @@
       return null;
    }
 
+   /**
+    * Returns an object representing the method {@code m} annotation whose type is
+    * one of the elements in {@code annotationChoices}, if {@code m} has such
+    * annotation.
+    * 
+    * @param  m                 the method whose annotation is being queried
+    * @param  annotationChoices the queried annotation must have one of the types
+    *                           contained in this array
+    * @return the meta data/annotation that apply to {@code m} whose type is in
+    *         {@code annotationChoices} 
+    */
    public <T extends Annotation> T resolveTypedAnnotation(Method m, Class<T>[] annotationChoices)
    {
       for (Class<T> ann : annotationChoices)

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java	2008-06-25 14:43:30 UTC (rev 75064)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java	2008-06-25 14:56:55 UTC (rev 75065)
@@ -48,6 +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.DynamicCFlowDefinition;
 import org.jboss.aop.advice.InterceptorFactory;
 import org.jboss.aop.advice.PrecedenceDef;
@@ -133,7 +134,9 @@
    protected volatile LinkedHashMap<String, ArrayBinding> arrayBindings = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
    protected volatile LinkedHashMap<String, AnnotationIntroduction> annotationIntroductions =UnmodifiableEmptyCollections. EMPTY_LINKED_HASHMAP;
    protected volatile LinkedHashMap<String, AnnotationIntroduction> annotationOverrides = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   @Deprecated
    protected volatile LinkedHashMap<String, AdviceBinding> bindings = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   volatile ClassifiedBindingCollection 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;
@@ -470,7 +473,7 @@
     */
    public AspectManager()
    {
-
+      this.bindingCollection = new ClassifiedBindingCollection();
    }
    /**
     * Every &lt;class-metadata&gt; tag corresponds to
@@ -523,10 +526,32 @@
       throw new RuntimeException("OPERATION NOT SUPPORTED ANYMORE");
    }
 
+   /**
+    * Returns the binding map.
+    * <p>
+    * The returned map must be used for read purposes only. To edit the
+    * binding collection, call {@link #addBinding(AdviceBinding)} and
+    * {@link #removeBinding(String)} instead.
+    * 
+    * @return the map containing all advice bindings indexed by their names
+    */
    public LinkedHashMap<String, AdviceBinding> getBindings()
    {
-      return bindings;
+      return bindingCollection.getBindings();
    }
+   
+   /**
+    * Returns the classified binding collection.
+    * <p>
+    * <b>Attention:</b> this collection is not supposed to be edited. Hence, only
+    * get methods can be called by clients.
+    * 
+    * @return the classified binding collection
+    */
+   ClassifiedBindingCollection getBindingCollection()
+   {
+      return bindingCollection;
+   }
 
    protected Map<Class<?>, WeakReference<Domain>> getSubDomainsPerClass()
    {
@@ -1374,26 +1399,16 @@
       clearUnregisteredClassLoaders();
 
       HashSet<Advisor> bindingAdvisors = new HashSet<Advisor>();
-      ArrayList<AdviceBinding> removedBindings = new ArrayList<AdviceBinding>();
-      synchronized (bindings)
+      ArrayList<AdviceBinding> removedBindings = null;
+      synchronized (bindingCollection)
       {
-         int bindSize = binds.size();
-
-         for (int i = 0; i < bindSize; i++)
+         removedBindings = this.bindingCollection.remove(binds);
+         for (AdviceBinding removedBinding: removedBindings)
          {
-
-            AdviceBinding binding = bindings.get(binds.get(i));
-            if (binding == null)
-            {
-               logger.debug("AspectManager.removeBindings() no binding found with name " + binds.get(i));
-               continue;
-            }
-            ArrayList<Advisor> ads = binding.getAdvisors();
+            ArrayList<Advisor> ads = removedBinding.getAdvisors();
             bindingAdvisors.addAll(ads);
-            bindings.remove(binding.getName());
-            Pointcut pointcut = binding.getPointcut();
+            Pointcut pointcut = removedBinding.getPointcut();
             this.removePointcut(pointcut.getName());
-            removedBindings.add(binding);
          }
       }
       Iterator<Advisor> it = bindingAdvisors.iterator();
@@ -1435,12 +1450,6 @@
       {
          removedBinding = internalRemoveBinding(binding.getName());
          affectedAdvisors = removedBinding == null ? null : new HashSet<Advisor>(removedBinding.getAdvisors());
-         initBindingsMap();
-         synchronized (bindings)
-         {
-            bindings.put(binding.getName(), binding);
-         }
-
          initPointcutsMap();
          initPointcutInfosMap();
          synchronized (pointcuts)
@@ -1450,6 +1459,12 @@
             pointcutInfos.put(pointcut.getName(), new PointcutInfo(pointcut, binding, this.transformationStarted));
             updatePointcutStats(pointcut);
          }
+         
+         initBindingsMap();
+         synchronized (bindingCollection)
+         {
+            bindingCollection.add(binding);
+         }
       }
       synchronized (advisors)
       {
@@ -2066,9 +2081,9 @@
     */
    private synchronized AdviceBinding internalRemoveBinding(String name)
    {
-      synchronized (bindings)
+      synchronized (bindingCollection)
       {
-         AdviceBinding binding = bindings.remove(name);
+         AdviceBinding binding = bindingCollection.remove(name);
          if (binding == null)
          {
             return null;
@@ -2349,13 +2364,14 @@
 
    protected void initBindingsMap()
    {
-      if (bindings == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
+      if (!bindingCollection.isInitialized())
       {
          synchronized(lazyCollectionLock)
          {
-            if (bindings == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
+            if (!bindingCollection.isInitialized())
             {
-               bindings = new LinkedHashMap<String, AdviceBinding>();
+               bindingCollection.initialize();
+               bindings = bindingCollection.getBindings();
             }
          }
       }

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java	2008-06-25 14:43:30 UTC (rev 75064)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java	2008-06-25 14:56:55 UTC (rev 75065)
@@ -34,12 +34,14 @@
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.jboss.aop.advice.AdviceBinding;
 import org.jboss.aop.advice.AspectDefinition;
+import org.jboss.aop.advice.ClassifiedBindingCollection;
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.aop.instrument.ConstructorExecutionTransformer;
 import org.jboss.aop.instrument.FieldAccessTransformer;
@@ -267,7 +269,6 @@
       {
          //long start = System.currentTimeMillis();
 
-         final ClassAdvisor THIS = this;
          final AspectManager theManager = manager;
          //register class loader: necessary when clazz was precompiled through aopc
          manager.registerClassLoader(clazz.getClassLoader());
@@ -275,20 +276,20 @@
          {
             public Object run() throws Exception
             {
-               theManager.attachMetaData(THIS, clazz);
+               theManager.attachMetaData(ClassAdvisor.this, clazz);
                interfaceIntroductions.clear();
                // metadata should always come before creation of interceptor chain
                // so that the interceptor factories have access to metadata.
                // and so that metadata joinpoints can be checked
                //
 
-               THIS.clazz = clazz;
+               ClassAdvisor.this.clazz = clazz;
 
                // Also metadata needs to be applied before applyIntroductionPointcuts because
                // an annotation may be triggered by XML metadata as well as
                // after populateMixinMethods so that proper metadata is applied to added methods
                rebindClassMetaData();
-               theManager.applyInterfaceIntroductions(THIS, clazz);
+               theManager.applyInterfaceIntroductions(ClassAdvisor.this, clazz);
                createFieldTable();
                createMethodTables();
                createConstructorTables();
@@ -573,9 +574,14 @@
 //      }
 //   }
 
+   @SuppressWarnings("deprecation")
    protected void createInterceptorChains() throws Exception
    {
-      if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("Creating chains for " + clazz + " " + ((clazz != null) ? clazz.getClassLoader() : null ));
+      if (AspectManager.verbose && logger.isDebugEnabled())
+      {
+         logger.debug("Creating chains for " + clazz + " " +
+               ((clazz != null) ? clazz.getClassLoader() : null ));
+      }
       // TODO flavia remove this
       // this if is here because the subclass GeneratedClassAdvisor shouldn't be calling
       // this method anymore: the infos are already created during this class initalization (initalise method)
@@ -589,15 +595,9 @@
 
       initializeConstructorChain();
       initializeConstructionChain();
-
-      synchronized (manager.getBindings())
-      {
-         for (AdviceBinding binding : manager.getBindings().values())
-         {
-            resolvePointcuts(binding);
-         }
-      }
-
+      
+      resolveBindings(manager);
+      
       finalizeChains();
       populateInterceptorsFromInfos();
 
@@ -610,6 +610,60 @@
       }
    }
 
+   @SuppressWarnings("deprecation")
+   private void resolveBindings(AspectManager manager)
+   {
+      ClassifiedBindingCollection bindingCol = manager.bindingCollection;
+      synchronized (bindingCol)
+      {
+         for (AdviceBinding binding: bindingCol.getFieldReadBindings())
+         {
+            if (AspectManager.verbose && logger.isDebugEnabled())
+            {
+               logger.debug("iterate binding " + binding.getName() + " " +
+                     binding.getPointcut().getExpr());
+            }
+            resolveFieldPointcut(fieldReadInfos, binding, false);
+         }
+         for (AdviceBinding binding: bindingCol.getFieldWriteBindings())
+         {
+            if (AspectManager.verbose && logger.isDebugEnabled())
+            {
+               logger.debug("iterate binding " + binding.getName() + " " +
+                     binding.getPointcut().getExpr());
+            }
+            resolveFieldPointcut(fieldWriteInfos, binding, true);
+         }
+         for (AdviceBinding binding: bindingCol.getConstructionBindings())
+         {
+            if (AspectManager.verbose && logger.isDebugEnabled())
+            {
+               logger.debug("iterate binding " + binding.getName() + " " +
+                     binding.getPointcut().getExpr());
+            }
+            resolveConstructionPointcut(binding);
+         }
+         for (AdviceBinding binding: bindingCol.getConstructorExecutionBindings())
+         {
+            if (AspectManager.verbose && logger.isDebugEnabled())
+            {
+               logger.debug("iterate binding " + binding.getName() + " " +
+                     binding.getPointcut().getExpr());
+            }
+            resolveConstructorPointcut(binding);
+         }
+         for (AdviceBinding binding: bindingCol.getMethodExecutionBindings())
+         {
+            if (AspectManager.verbose && logger.isDebugEnabled())
+            {
+               logger.debug("iterate binding " + binding.getName() + " " +
+                     binding.getPointcut().getExpr());
+            }
+            resolveMethodPointcut(binding);
+         }
+      }
+   }
+   
    protected void updateInterceptorChains() throws Exception
    {
       if (AspectManager.verbose && logger.isDebugEnabled())
@@ -622,13 +676,7 @@
       {
          resetChains();
          
-         synchronized (manager.getBindings())
-         {
-            for (AdviceBinding binding : manager.getBindings().values())
-            {
-               resolvePointcuts(binding);
-            }
-         }
+         resolveBindings(manager);
 
          finalizeChains();
          populateInterceptorsFromInfos();
@@ -780,6 +828,9 @@
    
    protected void updateFieldPointcutAfterRemove(FieldInfo[] fieldInfos, AdviceBinding binding, boolean write)
    {
+      ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+      Collection<AdviceBinding> bindings = write? bindingCol.getFieldWriteBindings():
+            bindingCol.getFieldReadBindings();
       for (int i = 0; i < fieldInfos.length; i++)
       {
          Field field = fieldInfos[i].getField();
@@ -791,7 +842,7 @@
             if (AspectManager.verbose) System.err.println("[debug] Removing field, matched " + ((write) ? "write" : "read") + " binding: " + field);
             fieldInfos[i].clear();
             
-            for(AdviceBinding ab : manager.getBindings().values())
+            for(AdviceBinding ab : bindings)
             {
                if ((!write && ab.getPointcut().matchesGet(this, field))
                      || (write && ab.getPointcut().matchesSet(this, field)))
@@ -805,6 +856,7 @@
    
    protected void updateConstructorPointcutAfterRemove(AdviceBinding binding)
    {
+      ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
       if(constructorInfos != null && constructorInfos.length > 0)
       {
          for (int i = 0; i < constructors.length; i++)
@@ -815,7 +867,7 @@
             {
                if (AspectManager.verbose) System.err.println("[debug] Removing constructor, matched binding: " + constructor);
                constructorInfos[i].clear();
-               for(AdviceBinding ab : manager.getBindings().values())
+               for(AdviceBinding ab : bindingCol.getConstructorExecutionBindings())
                {
                   if (ab.getPointcut().matchesExecution(this, constructor))
                   {
@@ -829,6 +881,7 @@
    
    protected void updateConstructionPointcutAfterRemove(AdviceBinding binding)
    {
+      ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
       if (constructionInfos.length > 0)
       {
          for (int i = 0; i < constructionInfos.length ;i++)
@@ -840,7 +893,7 @@
             {
                if (AspectManager.verbose) System.err.println("[debug] Removing construction, matched binding: " + constructor);
                constructionInfos[i].clear();
-               for(AdviceBinding ab : manager.getBindings().values())
+               for(AdviceBinding ab : bindingCol.getConstructionBindings())
                {
                   if (binding.getPointcut().matchesConstruction(this, constructor))
                   {
@@ -964,8 +1017,6 @@
       }
    }
    
-   
-
    private ArrayList<AdviceBinding> getConstructorCallerBindings(int callingIndex, String cname, long calledHash)
    {
       try
@@ -977,16 +1028,18 @@
          Method calledMethod = MethodHashing.findMethodByHash(called, calledHash);
          if (calledMethod == null) throw new RuntimeException("Unable to figure out calledmethod of a caller pointcut");
 
-         ArrayList<AdviceBinding> bindings = new ArrayList<AdviceBinding>(manager.getBindings().size());
-         for(AdviceBinding ab : manager.getBindings().values())
+         Collection<AdviceBinding> bindings = manager.getBindingCollection().
+            getMethodCallBindings();
+         ArrayList<AdviceBinding> result = new ArrayList<AdviceBinding>(bindings.size());
+         for(AdviceBinding ab : bindings)
          {
-            if (BindingClassifier.isMethodCall(ab) && ab.getPointcut().matchesCall(this, callingConstructor, called, calledMethod))
+            if (ab.getPointcut().matchesCall(this, callingConstructor, called, calledMethod))
             {
-               bindings.add(ab);
+               result.add(ab);
             }
          }
          
-         return bindings;
+         return result;
       }
       catch(Exception e)
       {
@@ -1006,15 +1059,17 @@
          Constructor<?> calledCon = MethodHashing.findConstructorByHash(called, calledHash);
          if (calledCon == null) throw new RuntimeException("Unable to figure out calledcon of a caller pointcut");
 
-         ArrayList<AdviceBinding> bindings = new ArrayList<AdviceBinding>(manager.getBindings().size());
-         for(AdviceBinding ab : manager.getBindings().values())   
+         Collection<AdviceBinding> bindings = manager.getBindingCollection().
+            getConstructorCallBindings();
+         ArrayList<AdviceBinding> result= new ArrayList<AdviceBinding>(bindings.size());
+         for(AdviceBinding ab : bindings)   
          {
-            if (BindingClassifier.isConstructorCall(ab) && ab.getPointcut().matchesCall(this, callingConstructor, called, calledCon))
+            if (ab.getPointcut().matchesCall(this, callingConstructor, called, calledCon))
             {
-               bindings.add(ab);
+               result.add(ab);
             }
          }
-         return bindings;
+         return result;
       }
       catch(Exception e)
       {
@@ -1590,12 +1645,12 @@
          if (calledMethod == null) throw new RuntimeException("Unable to figure out calledmethod of a caller pointcut");
 
          boolean matched = false;
-
-         synchronized (manager.getBindings())
+         ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+         synchronized (bindingCol)
          {
-            for (AdviceBinding binding : manager.getBindings().values())
+            for (AdviceBinding binding : bindingCol.getConstructorCallBindings())
             {
-               if (BindingClassifier.isConstructorCall(binding) && binding.getPointcut().matchesCall(this, callingConstructor, called, calledMethod))
+               if (binding.getPointcut().matchesCall(this, callingConstructor, called, calledMethod))
                {
                   addConstructorCallerPointcut(callingIndex, calledClass, calledMethodHash, binding);
                   matched = true;
@@ -1656,11 +1711,12 @@
          if (calledCon == null) throw new RuntimeException("Unable to figure out calledcon of a caller pointcut");
 
          boolean matched = false;
-         synchronized (manager.getBindings())
+         ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+         synchronized (bindingCol)
          {
-            for (AdviceBinding binding : manager.getBindings().values())
+            for (AdviceBinding binding : bindingCol.getConstructorCallBindings())
             {
-               if (BindingClassifier.isConstructorCall(binding) && binding.getPointcut().matchesCall(this, callingConstructor, called, calledCon))
+               if (binding.getPointcut().matchesCall(this, callingConstructor, called, calledCon))
                {
                   addConstructorCalledByConPointcut(callingIndex, calledClass, calledConHash, binding);
                   matched = true;
@@ -2464,9 +2520,9 @@
             if (calledMethod == null) throw new RuntimeException("Unable to figure out calledmethod of a caller pointcut");
 
             boolean matched = false;
-            for (AdviceBinding binding : manager.getBindings().values())
+            for (AdviceBinding binding : manager.getBindingCollection().getMethodCallBindings())
             {
-               if (BindingClassifier.isMethodCall(binding) && binding.getPointcut().matchesCall(ClassAdvisor.this, callingMethod, called, calledMethod))
+               if (binding.getPointcut().matchesCall(ClassAdvisor.this, callingMethod, called, calledMethod))
                {
                   addMethodCalledByMethodPointcut(callingMethodHash, calledClass, calledMethodHash, binding);
                   matched = true;
@@ -2582,15 +2638,17 @@
             Method calledMethod = MethodHashing.findMethodByHash(called, calledHash);
             if (calledMethod == null) throw new RuntimeException("Unable to figure out calledmethod of a caller pointcut");
 
-            ArrayList<AdviceBinding> bindings = new ArrayList<AdviceBinding>(manager.getBindings().size());
-            for(AdviceBinding ab : manager.getBindings().values())
+            Collection<AdviceBinding> bindings = manager.getBindingCollection().
+               getMethodCallBindings();
+            ArrayList<AdviceBinding> result = new ArrayList<AdviceBinding>(bindings.size());
+            for(AdviceBinding ab : bindings)
             {
-               if (BindingClassifier.isMethodCall(ab) && ab.getPointcut().matchesCall(ClassAdvisor.this, callingMethod, called, calledMethod))
+               if (ab.getPointcut().matchesCall(ClassAdvisor.this, callingMethod, called, calledMethod))
                {
-                  bindings.add(ab);
+                  result.add(ab);
                }
             }
-            return bindings;
+            return result;
          }
          catch(Exception e)
          {
@@ -2653,16 +2711,18 @@
             Class<?> called = SecurityActions.getContextClassLoader().loadClass(cname);
             Constructor<?> calledCon = MethodHashing.findConstructorByHash(called, calledHash);
             if (calledCon == null) throw new RuntimeException("Unable to figure out calledcon of a constructor caller pointcut");
-
-            ArrayList<AdviceBinding> bindings = new ArrayList<AdviceBinding>(manager.getBindings().size());
-            for(AdviceBinding ab : manager.getBindings().values())
+            
+            Collection<AdviceBinding> bindings = manager.getBindingCollection().
+               getConstructorCallBindings();
+            ArrayList<AdviceBinding> result = new ArrayList<AdviceBinding>(bindings.size());
+            for(AdviceBinding ab : bindings)
             {
-               if (BindingClassifier.isConstructorCall(ab) && ab.getPointcut().matchesCall(ClassAdvisor.this, callingMethod, called, calledCon))
+               if (ab.getPointcut().matchesCall(ClassAdvisor.this, callingMethod, called, calledCon))
                {
-                  bindings.add(ab);
+                  result.add(ab);
                }
             }
-            return bindings;
+            return result;
          }
          catch(Exception e)
          {
@@ -2740,12 +2800,12 @@
             if (calledCon == null) throw new RuntimeException("Unable to figure out calledcon of a constructor caller pointcut");
 
             boolean matched = false;
-            synchronized (manager.getBindings())
+            ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+            synchronized (bindingCol)
             {
-               for (AdviceBinding binding : manager.getBindings().values())
+               for (AdviceBinding binding : bindingCol.getConstructorCallBindings())
                {
-                  if (BindingClassifier.isConstructorCall(binding) &&
-                        binding.getPointcut().matchesCall(ClassAdvisor.this, callingMethod, called, calledCon))
+                  if (binding.getPointcut().matchesCall(ClassAdvisor.this, callingMethod, called, calledCon))
                   {
                      addConstructorCalledByMethodPointcut(callingMethodHash, calledClass, calledConHash, binding);
                      matched = true;

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ClassContainer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ClassContainer.java	2008-06-25 14:43:30 UTC (rev 75064)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ClassContainer.java	2008-06-25 14:56:55 UTC (rev 75065)
@@ -27,10 +27,11 @@
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
-import java.util.LinkedHashMap;
 
 import org.jboss.aop.advice.AdviceBinding;
+import org.jboss.aop.advice.ClassifiedBindingCollection;
 import org.jboss.aop.metadata.ClassMetaDataBinding;
 import org.jboss.aop.metadata.ClassMetaDataLoader;
 import org.jboss.aop.util.Advisable;
@@ -293,18 +294,21 @@
 
    private void makeInterceptorChains()
    {
-      LinkedHashMap<String, AdviceBinding> bindings = manager.getBindings();
-      synchronized (bindings)
+      ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+      synchronized (bindingCol)
       {
-         if (bindings.size() > 0)
+         Collection<AdviceBinding> bindings = bindingCol.getConstructorExecutionBindings(); 
+         for (AdviceBinding binding : bindings)
          {
-            for (AdviceBinding binding : bindings.values())
-            {
-               if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("iterate binding " + binding.getName());
-               resolveMethodPointcut(binding);
-               resolveConstructorPointcut(binding);
-            }
+            if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("iterate binding " + binding.getName());
+            resolveConstructorPointcut(binding);
          }
+         bindings = bindingCol.getMethodExecutionBindings(); 
+         for (AdviceBinding binding : bindings)
+         {
+            if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("iterate binding " + binding.getName());
+            resolveMethodPointcut(binding);
+         }
       }
       finalizeChain(constructorInfos);
       finalizeMethodChain();

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java	2008-06-25 14:43:30 UTC (rev 75064)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java	2008-06-25 14:56:55 UTC (rev 75065)
@@ -25,14 +25,17 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 
 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.DynamicCFlowDefinition;
 import org.jboss.aop.advice.InterceptorFactory;
 import org.jboss.aop.advice.PrecedenceDef;
@@ -79,6 +82,7 @@
 
    public Domain(AspectManager manager, String name, boolean parentFirst)
    {
+      bindingCollection = new DomainClassifiedBindingCollection();
       this.parent = manager;
       this.parentFirst = parentFirst;
       this.name = name;
@@ -159,12 +163,12 @@
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
             LinkedHashMap<String, AdviceBinding> map = new LinkedHashMap<String, AdviceBinding>(parent.getBindings());
-            map.putAll(this.bindings);
+            map.putAll(this.bindingCollection.getBindings());
             return map;
          }
          else
          {
-            LinkedHashMap<String, AdviceBinding> map = new LinkedHashMap<String, AdviceBinding>(this.bindings);
+            LinkedHashMap<String, AdviceBinding> map = new LinkedHashMap<String, AdviceBinding>(this.bindingCollection.getBindings());
             map.putAll(parent.getBindings());
             return map;
          }
@@ -189,15 +193,15 @@
    public synchronized void removeBinding(String name)
    {
       super.removeBinding(name);
-      hasOwnBindings = bindings.size() > 0;
+      hasOwnBindings = !bindingCollection.isEmpty();
    }
    
    @Override
    public synchronized void removeBindings(ArrayList<String> binds)
    {
       super.removeBindings(binds);
-      hasOwnBindings = bindings.size() > 0;
-      hasOwnPointcuts = bindings.size() > 0;
+      hasOwnBindings = !bindingCollection.isEmpty();
+      hasOwnPointcuts = !bindingCollection.isEmpty();
    }
    
    @Override
@@ -1098,4 +1102,88 @@
    {
       return parent.isSet();
    }
-}
+   
+   private class DomainClassifiedBindingCollection extends ClassifiedBindingCollection
+   {
+      public Collection<AdviceBinding> getFieldReadBindings()
+      {
+         Collection<AdviceBinding> result = super.getFieldReadBindings();
+         Collection<AdviceBinding> parentResult = parent.getBindingCollection().
+            getFieldReadBindings();
+         return unifyCollections(result, parentResult, parentFirst);
+      }
+      
+      public Collection<AdviceBinding> getFieldWriteBindings()
+      {
+         Collection<AdviceBinding> result = super.getFieldWriteBindings();
+         Collection<AdviceBinding> parentResult = parent.getBindingCollection().
+            getFieldWriteBindings();
+         return unifyCollections(result, parentResult, parentFirst);
+      }
+      
+      public Collection<AdviceBinding> getConstructionBindings()
+      {
+         Collection<AdviceBinding> result = super.getConstructionBindings();
+         Collection<AdviceBinding> parentResult = parent.getBindingCollection().
+            getConstructionBindings();
+         return unifyCollections(result, parentResult, parentFirst);
+      }
+      
+      public Collection<AdviceBinding> getConstructorExecutionBindings()
+      {
+         Collection<AdviceBinding> result = super.getConstructorExecutionBindings();
+         Collection<AdviceBinding> parentResult = parent.getBindingCollection().
+            getConstructorExecutionBindings();
+         return unifyCollections(result, parentResult, parentFirst);
+      }
+      
+      public Collection<AdviceBinding> getMethodExecutionBindings()
+      {
+         Collection<AdviceBinding> result = super.getMethodExecutionBindings();
+         Collection<AdviceBinding> parentResult = parent.getBindingCollection().
+            getMethodExecutionBindings();
+         return unifyCollections(result, parentResult, parentFirst);
+      }
+      
+      public Collection<AdviceBinding> getConstructorCallBindings()
+      {
+         Collection<AdviceBinding> result = super.getConstructorCallBindings();
+         Collection<AdviceBinding> parentResult = parent.getBindingCollection().
+            getConstructorCallBindings();
+         return unifyCollections(result, parentResult, parentFirst);
+      }
+      
+      public Collection<AdviceBinding> getMethodCallBindings()
+      {
+         Collection<AdviceBinding> result = super.getMethodCallBindings();
+         Collection<AdviceBinding> parentResult = parent.getBindingCollection().
+            getMethodCallBindings();
+         return unifyCollections(result, parentResult, parentFirst);
+      }
+      
+      private <T> Collection<T> unifyCollections(Collection<T> collection1,
+            Collection<T> collection2, boolean prioritizeFirst)
+      {
+         if (collection1.isEmpty())
+         {
+            return collection2;
+         }
+         if (collection2.isEmpty())
+         {
+            return collection1;
+         }
+         if (prioritizeFirst)
+         {
+            collection1 = new LinkedHashSet<T>(collection1);
+            collection1.addAll(collection2);
+         }
+         else
+         {
+            Collection<T> temp = collection1;
+            collection1 = new LinkedHashSet<T>(collection2);
+            collection1.addAll(temp);
+         }
+         return collection1;
+      }
+   }
+}
\ No newline at end of file

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/InstanceDomain.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/InstanceDomain.java	2008-06-25 14:43:30 UTC (rev 75064)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/InstanceDomain.java	2008-06-25 14:56:55 UTC (rev 75065)
@@ -53,9 +53,9 @@
    {
       removeBinding(binding.getName());
       super.initBindingsMap();
-      synchronized (bindings)
+      synchronized (bindingCollection)
       {
-         bindings.put(binding.getName(), binding);
+         bindingCollection.add(binding);
       }
       if (advisor != null) advisor.newBindingAdded();
    }

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java	2008-06-25 14:43:30 UTC (rev 75064)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java	2008-06-25 14:56:55 UTC (rev 75065)
@@ -32,6 +32,7 @@
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
@@ -41,6 +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.InterceptorFactory;
 import org.jboss.aop.introduction.AnnotationIntroduction;
 import org.jboss.aop.microcontainer.lifecycle.LifecycleCallbackBinding;
@@ -90,10 +92,10 @@
    {
       if (!initialisedAspects)
       {
-         Map<String, AdviceBinding> bindings = advisor.getManager().getBindings();
-         bindMethodAdvices(clazz, bindings);
-         bindConstructorAdvices(bindings);
-         bindFieldAdvices(bindings);
+         ClassifiedBindingCollection bindingCol = advisor.getManager().getBindingCollection();
+         bindMethodAdvices(clazz, bindingCol);
+         bindConstructorAdvices(bindingCol);
+         bindFieldAdvices(bindingCol);
       }
       return aspects;
    }
@@ -165,6 +167,7 @@
       }
    }
    
+   @Deprecated
    protected void bindMethodAdvices(Class<?> superClass, Map<String, AdviceBinding> bindings)
    {
       createMethodMap(superClass); 
@@ -177,7 +180,22 @@
          }
       }
    }
+   
+   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++)
+         {
+            bindMethodAdvice((Method)methods[i], bindings);
+         }
+      }
+   }
 
+   @Deprecated
    protected void bindConstructorAdvices(Map<String, AdviceBinding> bindings)
    {
       Constructor<?>[] cons = AccessController.doPrivileged(new PrivilegedAction<Constructor<?>[]>() 
@@ -192,7 +210,24 @@
          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++)
+      {
+         bindConstructorAdvice(cons[i], bindings);
+      }
+   }
 
+   @Deprecated
    protected void bindFieldAdvices(Map<String, AdviceBinding> bindings)
    {
       Field[] fields = AccessController.doPrivileged(new PrivilegedAction<Field[]>() 
@@ -208,6 +243,27 @@
          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++)
+      {
+         bindFieldGetAdvice(fields[i], bindings);
+      }
+      bindings = bindingCol.getFieldWriteBindings();
+      for (int i = 0; i < fields.length; i++)
+      {
+         bindFieldSetAdvice(fields[i], bindings);
+      }
+   }
 
    protected boolean matches(AnnotationIntroduction ai, Object element)
    {
@@ -215,6 +271,7 @@
       return ((Boolean) ai.getTarget().jjtAccept(matcher, null)).booleanValue();
    }
 
+   @Deprecated
    protected void bindMethodAdvice(Method mi, Map<String, AdviceBinding> bindings)
    {
       ArrayList<InterceptorFactory> advices = methodAdvices.get(mi);
@@ -241,7 +298,36 @@
          }
       }
    }
+   
+   /**
+    * 
+    * @param mi
+    * @param bindings a collection of bindings classified as EXECUTION
+    */
+   protected void bindMethodAdvice(Method mi, Collection<AdviceBinding> bindings)
+   {
+      ArrayList<InterceptorFactory> advices = methodAdvices.get(mi);
+      for (AdviceBinding binding : bindings)
+      {
+         PointcutMethodMatch pmatch= binding.getPointcut().matchesExecution(advisor, mi);
+         
+         if (pmatch != null && pmatch.isMatch())
+         {
+            if (advices == null)
+            {
+               advices = new ArrayList<InterceptorFactory>();
+               methodAdvices.put(mi, advices);
+            }
+            advices.addAll(Arrays.asList(binding.getInterceptorFactories()));
+            for (int i = 0; i < binding.getInterceptorFactories().length; i++)
+            {
+               aspects.add(binding.getInterceptorFactories()[i].getAspect());
+            }
+         }
+      }
+   }
 
+   @Deprecated
    protected void bindConstructorAdvice(Constructor<?> mi, Map<String, AdviceBinding> bindings)
    {
       ArrayList<InterceptorFactory> advices = constructorAdvices.get(mi);
@@ -266,7 +352,29 @@
          }
       }
    }
+   
+   protected void bindConstructorAdvice(Constructor<?> mi, Collection<AdviceBinding> bindings)
+   {
+      ArrayList<InterceptorFactory> advices = constructorAdvices.get(mi);
+      for (AdviceBinding binding : bindings)
+      {
+         if (binding.getPointcut().matchesExecution(advisor, mi))
+         {
+            if (advices == null)
+            {
+               advices = new ArrayList<InterceptorFactory>();
+               constructorAdvices.put(mi, advices);
+            }
+            advices.addAll(Arrays.asList(binding.getInterceptorFactories()));
+            for (int i = 0; i < binding.getInterceptorFactories().length; i++)
+            {
+               aspects.add(binding.getInterceptorFactories()[i].getAspect());
+            }
+         }
+      }
+   }
 
+   @Deprecated
    protected void bindFieldGetAdvice(Field mi, Map<String, AdviceBinding> bindings)
    {
       ArrayList<InterceptorFactory> advices = fieldReadAdvices.get(mi);
@@ -291,7 +399,29 @@
          }
       }
    }
+   
+   protected void bindFieldGetAdvice(Field mi, Collection<AdviceBinding> bindings)
+   {
+      ArrayList<InterceptorFactory> advices = fieldReadAdvices.get(mi);
+      for (AdviceBinding binding : bindings)
+      {
+         if (binding.getPointcut().matchesGet(advisor, mi))
+         {
+            if (advices == null)
+            {
+               advices = new ArrayList<InterceptorFactory>();
+               fieldReadAdvices.put(mi, advices);
+            }
+            advices.addAll(Arrays.asList(binding.getInterceptorFactories()));
+            for (int i = 0; i < binding.getInterceptorFactories().length; i++)
+            {
+               aspects.add(binding.getInterceptorFactories()[i].getAspect());
+            }
+         }
+      }
+   }
 
+   @Deprecated
    protected void bindFieldSetAdvice(Field mi, Map<String, AdviceBinding> bindings)
    {
       ArrayList<InterceptorFactory> advices = fieldWriteAdvices.get(mi);
@@ -317,6 +447,27 @@
       }
    }
    
+   protected void bindFieldSetAdvice(Field mi, Collection<AdviceBinding> bindings)
+   {
+      ArrayList<InterceptorFactory> advices = fieldWriteAdvices.get(mi);
+      for (AdviceBinding binding : bindings)
+      {
+         if (binding.getPointcut().matchesSet(advisor, mi))
+         {
+            if (advices == null)
+            {
+               advices = new ArrayList<InterceptorFactory>();
+               fieldWriteAdvices.put(mi, advices);
+            }
+            advices.addAll(Arrays.asList(binding.getInterceptorFactories()));
+            for (int i = 0; i < binding.getInterceptorFactories().length; i++)
+            {
+               aspects.add(binding.getInterceptorFactories()[i].getAspect());
+            }
+         }
+      }
+   }
+   
    protected void bindLifecycles()
    {
       for (LifecycleCallbackBinding binding : advisor.getManager().getLifecycleBindings().values())

Added: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingCollection.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingCollection.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingCollection.java	2008-06-25 14:56:55 UTC (rev 75065)
@@ -0,0 +1,289 @@
+/*
+ * 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.LinkedHashSet;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.util.BindingClassifier;
+import org.jboss.aop.util.UnmodifiableEmptyCollections;
+import org.jboss.aop.util.logging.AOPLogger;
+import org.jboss.logging.Logger;
+
+/**
+ * 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 Logger logger = AOPLogger.getLogger(AspectManager.class);
+  
+   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;
+   
+   @SuppressWarnings("all")
+   /**
+    * Constructor.<p>
+    * All created instances must be initialized before being used for addition and
+    * removal operations, by calling {@code initialize()}.
+    */
+   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 synchronized Collection<AdviceBinding> getFieldReadBindings()
+   {
+      return this.fieldReadBindings;
+   }
+   
+   /**
+    * 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 synchronized Collection<AdviceBinding> getFieldWriteBindings()
+   {
+      return this.fieldWriteBindings;
+   }
+   
+   /**
+    * 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 synchronized Collection<AdviceBinding> getConstructionBindings()
+   {
+      return this.constructionBindings;
+   }
+   
+   /**
+    * 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 synchronized Collection<AdviceBinding> getConstructorExecutionBindings()
+   {
+      return this.constructorExecutionBindings;
+   }
+   
+   /**
+    * 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 synchronized Collection<AdviceBinding> getMethodExecutionBindings()
+   {
+      return this.methodExecutionBindings;
+   }
+   
+   /**
+    * 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 synchronized Collection<AdviceBinding> getConstructorCallBindings()
+   {
+      return this.constructorCallBindings;
+   }
+   
+   /**
+    * 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 synchronized Collection<AdviceBinding> getMethodCallBindings()
+   {
+      return this.methodCallBindings;
+   }
+   
+   /**
+    * Indicate whether this collection is empty.
+    */
+   public synchronized boolean isEmpty()
+   {
+      return this.bindings.isEmpty();
+   }
+   
+   /**
+    * Returns the bindings map.
+    * <p>
+    * <b>Attention:</b> this collection is not supposed to be edited.
+    */
+   public LinkedHashMap<String, AdviceBinding> getBindings()
+   {
+      return bindings;
+   }
+   
+   /**
+    * Adds a binding to this collection.
+    */
+   public synchronized void add(AdviceBinding binding)
+   {
+      bindings.put(binding.getName(), binding);
+      if (BindingClassifier.isGet(binding))
+      {
+         this.fieldReadBindings.add(binding);
+      }
+      if (BindingClassifier.isSet(binding))
+      {
+         this.fieldWriteBindings.add(binding);
+      }
+      if (BindingClassifier.isConstruction(binding))
+      {
+         this.constructionBindings.add(binding);
+      }
+      if (BindingClassifier.isConstructorExecution(binding))
+      {
+         this.constructorExecutionBindings.add(binding);
+      }
+      if (BindingClassifier.isMethodExecution(binding))
+      {
+         this.methodExecutionBindings.add(binding);
+      }
+      if (BindingClassifier.isConstructorCall(binding))
+      {
+         this.constructorCallBindings.add(binding);
+      }
+      if (BindingClassifier.isMethodCall(binding))
+      {
+         this.methodCallBindings.add(binding);
+      }
+   }
+   
+   /**
+    * 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 synchronized AdviceBinding remove(String name)
+   {
+      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;
+   }
+   
+   /**
+    * 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 synchronized ArrayList<AdviceBinding> remove(ArrayList<String> names)
+   {
+      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;
+   }
+   
+   /**
+    * Indicates if this collection is initialized. If it is not, no addition
+    * operation can be performed.
+    */
+   public synchronized boolean isInitialized()
+   {
+      return bindings != UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   }
+   
+   /**
+    * Initializes this collection. This method must be called only if this collection
+    * is not initialized.
+    */
+   public synchronized void initialize()
+   {
+      bindings = new LinkedHashMap<String, AdviceBinding>();
+      this.fieldReadBindings = new LinkedHashSet<AdviceBinding>(0);
+      this.fieldWriteBindings = new LinkedHashSet<AdviceBinding>(0);
+      this.constructionBindings = new LinkedHashSet<AdviceBinding>(0);
+      this.constructorExecutionBindings = new LinkedHashSet<AdviceBinding>(0);
+      this.methodExecutionBindings = new LinkedHashSet<AdviceBinding>(0);
+      this.constructorCallBindings = new LinkedHashSet<AdviceBinding>(0);
+      this.methodCallBindings = new LinkedHashSet<AdviceBinding>(0);
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list