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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed May 21 15:19:25 EDT 2008


Author: kabir.khan at jboss.com
Date: 2008-05-21 15:19:25 -0400 (Wed, 21 May 2008)
New Revision: 73565

Added:
   projects/aop/trunk/aop/src/main/org/jboss/aop/util/BindingClassifier.java
Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java
Log:
[JBAOP-579] Make ReflectiveAspectBinder only try to match the appropriate bindings


Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java	2008-05-21 18:25:43 UTC (rev 73564)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java	2008-05-21 19:19:25 UTC (rev 73565)
@@ -49,6 +49,7 @@
 import org.jboss.aop.pointcut.PointcutMethodMatch;
 import org.jboss.aop.proxy.container.InstanceProxyContainer;
 import org.jboss.aop.util.Advisable;
+import org.jboss.aop.util.BindingClassifier;
 import org.jboss.util.MethodHashing;
 
 /**
@@ -219,6 +220,10 @@
       ArrayList<InterceptorFactory> advices = methodAdvices.get(mi);
       for (AdviceBinding binding : bindings.values())
       {
+         if (!BindingClassifier.isMethodExecution(binding))
+         {
+            continue;
+         }
          PointcutMethodMatch pmatch= binding.getPointcut().matchesExecution(advisor, mi);
          
          if (pmatch != null && pmatch.isMatch())
@@ -242,6 +247,10 @@
       ArrayList<InterceptorFactory> advices = constructorAdvices.get(mi);
       for (AdviceBinding binding : bindings.values())
       {
+         if (!BindingClassifier.isConstructorExecution(binding))
+         {
+            continue;
+         }
          if (binding.getPointcut().matchesExecution(advisor, mi))
          {
             if (advices == null)
@@ -263,6 +272,10 @@
       ArrayList<InterceptorFactory> advices = fieldReadAdvices.get(mi);
       for (AdviceBinding binding : bindings.values())
       {
+         if (!BindingClassifier.isGet(binding))
+         {
+            continue;
+         }
          if (binding.getPointcut().matchesGet(advisor, mi))
          {
             if (advices == null)
@@ -284,6 +297,10 @@
       ArrayList<InterceptorFactory> advices = fieldWriteAdvices.get(mi);
       for (AdviceBinding binding : bindings.values())
       {
+         if (!BindingClassifier.isSet(binding))
+         {
+            continue;
+         }
          if (binding.getPointcut().matchesSet(advisor, mi))
          {
             if (advices == null)

Added: projects/aop/trunk/aop/src/main/org/jboss/aop/util/BindingClassifier.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/util/BindingClassifier.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/util/BindingClassifier.java	2008-05-21 19:19:25 UTC (rev 73565)
@@ -0,0 +1,157 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.util;
+
+import org.jboss.aop.advice.AdviceBinding;
+import org.jboss.aop.pointcut.Pointcut;
+import org.jboss.aop.pointcut.PointcutExpression;
+import org.jboss.aop.pointcut.PointcutStats;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BindingClassifier
+{
+   public static boolean isExecution(AdviceBinding binding)
+   {
+      PointcutStats stats = getPointcutStats(binding);
+      if (stats != null)
+      {
+         return stats.isExecution();
+      }
+      return false;
+   }
+
+   public static boolean isMethodExecution(AdviceBinding binding)
+   {
+      PointcutStats stats = getPointcutStats(binding);
+      if (stats != null)
+      {
+         return stats.isMethodExecution();
+      }
+      return false;
+   }
+
+   public static boolean isConstructorExecution(AdviceBinding binding)
+   {
+      PointcutStats stats = getPointcutStats(binding);
+      if (stats != null)
+      {
+         return stats.isConstructorExecution();
+      }
+      return false;
+   }
+
+   public static boolean isConstruction(AdviceBinding binding)
+   {
+      PointcutStats stats = getPointcutStats(binding);
+      if (stats != null)
+      {
+         return stats.isConstruction();
+      }
+      return false;
+   }
+
+   public static boolean isCall(AdviceBinding binding)
+   {
+      PointcutStats stats = getPointcutStats(binding);
+      if (stats != null)
+      {
+         return stats.isCall();
+      }
+      return false;
+   }
+   
+   public static boolean isMethodCall(AdviceBinding binding)
+   {
+      PointcutStats stats = getPointcutStats(binding);
+      if (stats != null)
+      {
+         return stats.isMethodCall();
+      }
+      return false;
+   }
+
+   public static boolean isConstructorCall(AdviceBinding binding)
+   {
+      PointcutStats stats = getPointcutStats(binding);
+      if (stats != null)
+      {
+         return stats.isConstructorCall();
+      }
+      return false;
+   }
+
+   public static boolean isWithin(AdviceBinding binding)
+   {
+      PointcutStats stats = getPointcutStats(binding);
+      if (stats != null)
+      {
+         return stats.isWithin();
+      }
+      return false;
+   }
+
+   public static boolean isGet(AdviceBinding binding)
+   {
+      PointcutStats stats = getPointcutStats(binding);
+      if (stats != null)
+      {
+         return stats.isGet();
+      }
+      return false;
+   }
+
+   public static boolean isSet(AdviceBinding binding)
+   {
+      PointcutStats stats = getPointcutStats(binding);
+      if (stats != null)
+      {
+         return stats.isSet();
+      }
+      return false;
+   }
+
+   public static boolean isWithincode(AdviceBinding binding)
+   {
+      PointcutStats stats = getPointcutStats(binding);
+      if (stats != null)
+      {
+         return stats.isWithincode();
+      }
+      return false;
+   }
+
+   private static PointcutStats getPointcutStats(AdviceBinding binding)
+   {
+      Pointcut pointcut = binding.getPointcut();
+      if (pointcut instanceof PointcutExpression)
+      {
+         PointcutExpression expr =  (PointcutExpression)pointcut;
+         return expr.getStats();
+      }
+      return null;
+   }
+
+}




More information about the jboss-cvs-commits mailing list