[jboss-cvs] JBossAS SVN: r58669 - in projects/aop/trunk/aop/src/main/org/jboss/aop/advice: . annotation

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 24 12:14:26 EST 2006


Author: flaviarnn
Date: 2006-11-24 12:13:41 -0500 (Fri, 24 Nov 2006)
New Revision: 58669

Added:
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceInfo.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceMethodFactory.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AnnotatedParameterAdviceInfo.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Arg.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Args.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Callee.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Caller.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Invocation.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/JoinPoint.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/MultipleAdviceInfoException.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/ParameterAnnotationRule.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/ParameterAnnotationRuleException.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Return.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Target.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Thrown.java
Removed:
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/AdviceMethodFactory.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Arg.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Args.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Callee.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Caller.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Invocation.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/JoinPoint.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Return.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Target.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Thrown.java
Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/AdviceMethodProperties.java
Log:
[JBAOP-37] Refatored code moving classes to new package org.jboss.aop.advice.annotation

Deleted: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/AdviceMethodFactory.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/AdviceMethodFactory.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/AdviceMethodFactory.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -1,481 +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.lang.reflect.Method;
-import java.util.ArrayList;
-
-import javassist.NotFoundException;
-
-import org.jboss.aop.JoinPointInfo;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.util.ReflectUtils;
-
-/**
- * Utility class to figure out which advice method to use for a given joinpoint
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision$
- */
-public class AdviceMethodFactory
-{
-   private static final int IS_BEFORE = 1;
-   private static final int IS_AFTER = 2;
-   private static final int IS_THROWING = 3;
-   private static final int IS_AROUND = 4;
-   
-   public static final AdviceMethodFactory BEFORE = new AdviceMethodFactory(IS_BEFORE, false, true, false, false);
-   public static final AdviceMethodFactory AFTER = new AdviceMethodFactory(IS_AFTER, false, true, true, false);
-   public static final AdviceMethodFactory THROWING = new AdviceMethodFactory(IS_THROWING, false, true, false, true);
-   public static final AdviceMethodFactory AROUND = new AdviceMethodFactory(IS_AROUND, true, false, false, false);
-   
-   private static final Class INVOCATION = Invocation.class;
-   private static final Class THROWABLE = Throwable.class;
-         
-   int type;
-   boolean canHaveJoinpoint;
-   boolean canHaveInvocation;
-   boolean mustHaveReturnType;
-   boolean mustHaveThrowable;
-   
-   static final MatchData BEST_MATCH_START = new MatchData();
-   
-   private AdviceMethodFactory(int type, boolean canHaveInvocation, boolean canHaveJoinpoint, boolean canHaveReturnType, boolean canHaveThrowable)
-   {
-      this.type = type;
-      this.canHaveInvocation = canHaveInvocation;
-      this.canHaveJoinpoint = canHaveJoinpoint;
-      this.mustHaveReturnType = canHaveReturnType;
-      this.mustHaveThrowable = canHaveThrowable;
-   }
-   
-   public AdviceMethodProperties findAdviceMethod(AdviceMethodProperties properties)
-   {
-      Method[] methods = ReflectUtils.getMethodsWithName(properties.getAspectClass(), properties.getAdviceName());
-    
-      if (methods.length == 0) return null;
-      if (methods.length == 1 && methods[0].getParameterTypes().length == 0)
-      {
-         if (mustHaveReturnType && !properties.getJoinpointReturnType().equals(Void.TYPE))
-         {
-            return null;
-         }
-         if (mustHaveThrowable)
-         {
-            return null;
-         }
-         properties.setFoundProperties(methods[0], new ArrayList());
-         return properties;
-      }
-      
-      MatchData bestMatch = BEST_MATCH_START;
-      for (int i = 0 ; i < methods.length ; i++)
-      {
-         MatchData matchData = matchParameters(properties, methods[i], bestMatch);
-         if (matchData != null)
-         {
-            bestMatch = matchData;
-         }
-      }
-      
-      if (bestMatch.method != null)
-      {
-         return setupMethodAndArgsInProperties(properties, bestMatch);
-      }
-         
-      
-      return null;
-   }
-   
-   private AdviceMethodProperties setupMethodAndArgsInProperties(AdviceMethodProperties properties, MatchData matchData)
-   {
-      ArrayList args = new ArrayList();
-      if (matchData.invocationMatchDegree >= 0)
-      {
-         if (canHaveInvocation) args.add(AdviceMethodProperties.INVOCATION_ARG);
-         else if (canHaveJoinpoint) args.add(AdviceMethodProperties.JOINPOINT_ARG);
-      }
-
-      if (matchData.returnOrThrowingMatchDegree >= 0)
-      {
-         if (mustHaveReturnType) args.add(AdviceMethodProperties.RETURN_ARG);
-         else if (mustHaveThrowable) args.add(AdviceMethodProperties.THROWABLE_ARG);
-      }
-
-      if (matchData.argsIndices != null)
-      {
-         args.addAll(matchData.argsIndices);
-      }
-      
-      properties.setFoundProperties(matchData.method, args);
-      
-      return properties;
-   }
-
-   private MatchData matchParameters(AdviceMethodProperties properties, Method adviceMethod, MatchData bestMatch)
-   {
-      Class[] adviceParams = adviceMethod.getParameterTypes();
-      if (adviceParams.length == 0 && bestMatch.method == null) return new MatchData(adviceMethod); 
-
-      MatchData currentMatch = lookForJoinPointInfoOrInvocation(properties, adviceMethod, bestMatch);
-      if (currentMatch == null)
-      {
-         return null;
-      }
-
-      currentMatch = lookForThrowingOrReturn(properties, adviceMethod, currentMatch, bestMatch);
-      if (currentMatch == null)
-      {
-         return null;
-      }
-
-      currentMatch = matchActualArgs(properties, adviceMethod, currentMatch, bestMatch);
-      if (currentMatch == null)
-      {
-         return null;
-      }
-
-      if (currentMatch.currentParam == adviceMethod.getParameterTypes().length) return currentMatch;
-      
-      return currentMatch;
-   }
-   
-   
-   
-   /**
-    * Looks for an Invocation or a JoinPointInfo in the first parameter of the looked for method.
-    * Returns -1 if it cannot find the required class, 0 means an exact match, 1 the superclass of what we would expect etc.
-    */
-   private MatchData lookForJoinPointInfoOrInvocation(AdviceMethodProperties properties, Method method, MatchData bestMatch)
-   {
-      Class[] adviceParams = method.getParameterTypes();
-      int index = 0;
-      int matchDegree = -1;
-      boolean firstIsSpecial = false;
-   
-      if (canHaveInvocation)
-      {
-         //Check if adviceParams[index] is invocation of correct type
-         if (isInvocation(adviceParams[index]))
-         {
-            firstIsSpecial = true;
-            matchDegree = matchClass(adviceParams[index], properties.getInvocationType());
-         }
-      }
-      else if (canHaveJoinpoint)
-      {
-         //Check if adviceParams[index] is JoinPoint of correct type
-         if (isInfo(adviceParams[index]))
-         {
-            firstIsSpecial = true;
-            matchDegree = matchClass(adviceParams[index], properties.getInfoType());
-         }
-      }
-      
-      if (firstIsSpecial)
-      {
-         if (matchDegree < 0)
-         {
-            //First param was an invocation/joinpoint, but not of the right type
-            return null;
-         }
-         else
-         {
-            index++;
-         }
-      }
-
-      //Check if the best match is still the best
-      if (bestMatch.invocationMatchDegree >= 0 && (bestMatch.invocationMatchDegree < matchDegree || !firstIsSpecial))
-      {
-         return null;
-      }
-
-      return new MatchData(method, index, matchDegree);
-   }
-   
-   private MatchData lookForTargetObject(AdviceMethodProperties properties, Method adviceMethod, MatchData currentMatch, MatchData bestMatch) throws NotFoundException
-   {
-      return currentMatch;
-   }
-   
-   private MatchData lookForThrowingOrReturn(AdviceMethodProperties properties, Method adviceMethod, MatchData currentMatch, MatchData bestMatch)
-   {
-      if (currentMatch.currentParam == adviceMethod.getParameterTypes().length)
-      {
-         return currentMatch;
-      }
-
-      if (mustHaveReturnType)
-      {
-         currentMatch = lookForReturn(properties, adviceMethod, currentMatch, bestMatch);
-         if (currentMatch == null)
-         {
-            return null;
-         }
-      }
-      else if (mustHaveThrowable)
-      {
-         //Check if adviceParams[index] is subclass of throwable/one of the exceptions thrown by the method/ctor
-         currentMatch.returnOrThrowingMatchDegree = matchClass(adviceMethod.getParameterTypes()[currentMatch.currentParam], THROWABLE);
-         currentMatch.currentParam++;
-      }
-
-      //Check if the best match is still the best
-      if (bestMatch.returnOrThrowingMatchDegree >= 0 && bestMatch.returnOrThrowingMatchDegree < currentMatch.returnOrThrowingMatchDegree)
-      {
-         return null;
-      }
-      return currentMatch;
-   }
-   
-   private MatchData lookForReturn(AdviceMethodProperties properties, Method adviceMethod, MatchData currentMatch, MatchData bestMatch)
-   {
-      //Check if adviceParams[index] has same return type as method/field get/ctor
-      Class returnType = properties.getJoinpointReturnType(); 
-      if (returnType == null || returnType.equals(Void.TYPE))
-      {
-      }
-      else
-      {
-         //Check that the return type is correct - the return type of the called method must be a 
-         //subclass of the return type of the advice
-         currentMatch.returnOrThrowingMatchDegree = subClassMatch(returnType, adviceMethod.getReturnType());
-         
-         
-         
-         if (currentMatch.returnOrThrowingMatchDegree < 0)
-         {
-            return null;
-         }
-         
-         //Now check that we take the correct type of return parameter
-         Class param = adviceMethod.getParameterTypes()[currentMatch.currentParam];
-
-         if (!returnType.equals(param))
-         {
-            int match2 = subClassMatch(returnType, param);
-            if (match2 < 0)
-            {
-               return null;
-            }
-            
-            currentMatch.returnOrThrowingMatchDegree = (currentMatch.returnOrThrowingMatchDegree + match2)/2;
-         }
-         currentMatch.currentParam++;
-      }
-      
-      return currentMatch;
-   }
-   
-   private MatchData matchActualArgs(AdviceMethodProperties properties, Method adviceMethod, MatchData currentMatch, MatchData bestMatch)
-   {
-      int adviceParam = currentMatch.currentParam;
-      Class[] adviceParams = adviceMethod.getParameterTypes();
-      
-      Class[] targetParams = properties.getJoinpointParameters();
-      
-      if (adviceParams.length - currentMatch.currentParam > targetParams.length)
-      {
-         //The advice method takes more args than the target joinpoint itself! 
-         return null;
-      }
-      
-      if (adviceParam == adviceParams.length)
-      {
-         //There are no more parameters, return without initialising the argsIndices
-         return nullOrCurrentMatch(currentMatch, bestMatch);
-      }
-      
-      currentMatch.argsIndices = new ArrayList();
-      for (int i = 0; i < targetParams.length && adviceParam < adviceParams.length; i++)
-      {
-         int match = matchClass(adviceParams[adviceParam], targetParams[i]);
-         if (match < 0)
-         {
-            continue;
-         }
-         else
-         {
-            adviceParam++;
-            currentMatch.argsIndices.add(new Integer(i));
-            currentMatch.argsDegreeSum += match;
-         }
-      }
-      
-      if (currentMatch.argsIndices.size() != adviceParams.length - currentMatch.currentParam)
-      {
-         return null;
-      }
-      
-      return nullOrCurrentMatch(currentMatch, bestMatch);
-   }
-   
-   /**
-    * Returns null if bestMatch was the best, otherwise returns currentMatch
-    */
-   private MatchData nullOrCurrentMatch(MatchData currentMatch, MatchData bestMatch)
-   {
-      if (currentMatch.compare(bestMatch, true) < 0)
-      {
-         return currentMatch;
-      }
-      
-      return null;
-   }
-   
-   private boolean isInvocation(Class clazz)
-   {
-      return Invocation.class.isAssignableFrom(clazz);
-   }
-   
-   private boolean isInfo(Class clazz)
-   {
-      return JoinPointInfo.class.isAssignableFrom(clazz);
-   }
-   
-   /**
-    * Checks if clazz is of type lookingFor. The returned "match degree" indicates how many superclasses/interfaces we
-    * had to go through until finding lookingFor
-    */
-   private int matchClass(Class clazz, Class lookingFor)
-   {
-      return matchClass(clazz, lookingFor, 0);
-   }
-
-   private int subClassMatch(Class clazz, Class superClass)
-   {
-      return matchClass(superClass, clazz);
-   }
-   
-   private int matchClass(Class wanted, Class candidate, int matchDegree)
-   {
-      if (candidate == null) return -1;
-      if (candidate.equals(wanted))
-      {
-         return matchDegree;
-      }
-
-      matchDegree++;
-      
-      Class[] interfaces = candidate.getInterfaces();
-      for (int i = 0 ; i < interfaces.length ; i++)
-      {
-         if (matchClass(wanted, interfaces[i], matchDegree) > 0) return matchDegree;
-      }
-      
-      if (matchClass(wanted, candidate.getSuperclass(), matchDegree) > 0) return matchDegree;
-      
-      return -1;
-   }
-   
-}
-
-class MatchData
-{
-   Method method;
-   int invocationMatchDegree = -1;
-   int returnOrThrowingMatchDegree = -1;
-   ArrayList argsIndices = null;
-   int argsDegreeSum = 0;
-   
-   int currentParam;
-   
-   MatchData()
-   {
-   }
-   
-   MatchData(Method method)
-   {
-      this.method = method;
-   }
-   
-   MatchData(Method method, int currentParam, int firstParamMatchDegree)
-   {
-      this.method = method;
-      this.currentParam = currentParam;
-      this.invocationMatchDegree = firstParamMatchDegree;
-   }
-   
-   public String toString()
-   {
-      return "MatchData[invMatch="+ invocationMatchDegree + "rtnMatch=" + returnOrThrowingMatchDegree + "args=" + ((argsIndices != null )? argsIndices.size() : 0) + "sum=" + argsDegreeSum + "]";
-   }
-   
-   /**
-    * Return -1 if mine is a better match, 1 if other is, and 0 if equal
-    */
-   int compare(MatchData other, boolean checkArgs)
-   {
-      int invMatch = compareMatchDegrees(this.invocationMatchDegree, other.invocationMatchDegree);
-      if (invMatch != 0)
-      {
-         return invMatch;
-      }
-      
-      int retMatch = compareMatchDegrees(this.returnOrThrowingMatchDegree, other.returnOrThrowingMatchDegree);
-      if (retMatch != 0)
-      {
-         return retMatch;
-      }
-      
-      if (checkArgs)
-      {
-         if (this.argsIndices == null && other.argsIndices == null) return 0;
-         else if (this.argsIndices != null && other.argsIndices == null) return -1;
-         else if (this.argsIndices == null && other.argsIndices != null) return 1;
-         else
-         {
-            if (this.argsIndices.size() > other.argsIndices.size()) return -1;
-            else if (this.argsIndices.size() < other.argsIndices.size()) return 1;
-            else
-            {
-               return this.argsDegreeSum < other.argsDegreeSum ? -1 : 1;
-            }
-         }      
-      }      
-      
-      return 0;
-   }
-   
-   /**
-    * Return -1 if mine is a better match, 1 if other is, and 0 if equal
-    */
-   int compareMatchDegrees(int mine, int other)
-   {
-      if (mine < 0 && other >= 0)
-      {
-         return 1;
-      }
-      else if (mine >= 0 && other < 0)
-      {
-         return -1;
-      }
-      else if (mine >= 0 && other >= 0 && mine != other)
-      {
-         return mine > other ? -1 : 1;
-      }
-      
-      return 0;//They are equal
-   }
-   
-}

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/AdviceMethodProperties.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/AdviceMethodProperties.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/AdviceMethodProperties.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -22,10 +22,8 @@
 package org.jboss.aop.advice;
 
 import java.lang.reflect.Method;
-import java.util.ArrayList;
 
 import javassist.CtClass;
-import javassist.CtMethod;
 import javassist.NotFoundException;
 
 /** Contains the properties of an advice method that we want to find.

Deleted: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Arg.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Arg.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Arg.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -1,36 +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.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Use this annotation on advice parameters that should contain values of 
- * advised joinpoint arguments.
- * 
- * @author Flavia Rainone
- */
- at Target (ElementType.PARAMETER) @Retention(RetentionPolicy.RUNTIME)
-public @interface Arg {}
\ No newline at end of file

Deleted: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Args.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Args.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Args.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -1,40 +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.lang.annotation.ElementType;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Use this annotation on the advice parameter that receives the complete list of
- * joinpoint argument values.
- * The annotated parameter must be of type <code>Object[]</code> and there
- * should not be any other advice parameter annotated either with {@link Arg} or
- * with <code>Args</code> itself.
- * 
- * @author Flavia Rainone
- */
- at Target (ElementType.PARAMETER) @Retention (RetentionPolicy.RUNTIME)
-public @interface Args {}
\ No newline at end of file

Deleted: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Callee.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Callee.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Callee.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -1,37 +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.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * 
- * 
- * @author Flavia Rainone
- */
- at Target (ElementType.PARAMETER) @Retention (RetentionPolicy.RUNTIME)
-public @interface Callee {}
\ No newline at end of file

Deleted: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Caller.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Caller.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Caller.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -1,35 +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.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-
-/**
- * 
- * @author Flavia Rainone
- */
- at Target (ElementType.PARAMETER) @Retention (RetentionPolicy.RUNTIME)
-public @interface Caller {}
\ No newline at end of file

Deleted: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Invocation.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Invocation.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Invocation.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -1,39 +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.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Use this annotation on the advice method parameter that receives an
- * {@link org.jboss.aop.joinpoint.Invocation} or one of its subtypes.
- * <p>
- * For optimization, always prefer to use {@link JoinPoint} instead of <code>Invocation
- * </code>.
- * 
- * @author Flavia Rainone
- */
- at Target (ElementType.PARAMETER) @Retention (RetentionPolicy.RUNTIME)
-public @interface Invocation {}
\ No newline at end of file

Deleted: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/JoinPoint.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/JoinPoint.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/JoinPoint.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -1,38 +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.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.jboss.aop.JoinPointInfo;
-
-/**
- * Use this annotation on the advice parameter that receives {@link JoinPointInfo} or
- * one of its subtypes.
- * 
- * @author Flavia Rainone
- */
- at Target( { ElementType.PARAMETER }) @Retention(RetentionPolicy.RUNTIME)
-public @interface JoinPoint {}
\ No newline at end of file

Deleted: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Return.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Return.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Return.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -1,38 +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.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotate the advice parameter with <code>@Return</code> if it receives the return
- * type of the join point execution.
- * <p>
- * Can only be used in <i>after</i>/<i>around</i> advices. 
- * 
- * @author Flavia Rainone
- */
- at Target (ElementType.PARAMETER) @Retention (RetentionPolicy.RUNTIME)
-public @interface Return {}
\ No newline at end of file

Deleted: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Target.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Target.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Target.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -1,33 +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.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- *
- * @author Flavia Rainone
- */
- at java.lang.annotation.Target( { ElementType.PARAMETER }) @Retention(RetentionPolicy.RUNTIME)
-public @interface Target {}
\ No newline at end of file

Deleted: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Thrown.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Thrown.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Thrown.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -1,36 +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.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotate with <code>@Thrown</code> the <i>throwing</i> advice parameter that receives
- * the thrown exception.
- * 
- * @author Flavia Rainone
- */
- at Target (ElementType.PARAMETER) @Retention (RetentionPolicy.RUNTIME)
-public @interface Thrown {}
\ No newline at end of file

Added: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceInfo.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceInfo.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceInfo.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,144 @@
+package org.jboss.aop.advice.annotation;
+
+import java.lang.reflect.Method;
+
+import org.jboss.aop.advice.AdviceMethodProperties;
+
+/**
+ * Contains information about an advice method and its matching process.
+ * 
+ * @author Flavia Rainone
+ */
+abstract class AdviceInfo implements Comparable<AdviceInfo>
+{
+   // the righest the rank the better this advice is
+   protected int rank;
+   // advice method
+   protected Method method;
+   // since method.getParameterTypes creates a vector, better store this information
+   // instead of calling repeatedly getParameterTypes
+   protected Class<?>[] parameterTypes;
+   
+   /**
+    * Creates an advice info.
+    * 
+    * @param method the advice method
+    * @param rank   the initial rank value of this advice
+    */
+   protected AdviceInfo(Method method, int rank)
+   {
+      this.method = method;
+      this.rank = rank;
+      this.parameterTypes = method.getParameterTypes();
+   }
+   
+   /**
+    * Indicates the distance between <code>class</code> and <code>lookingFor</code>
+    * in the class hierarchy.
+    * 
+    * @param clazz      the type of an annotated parameter
+    * @param lookingFor the expected type of the parameter
+    * @return -1 if a value of type <code>lookingFor</code> can't be assigned to
+    *         a parameter of type <code>class</code>; the distance between <code>class
+    *         </code> and <code>lookingFor</code> otherwise.
+    */
+   protected int matchClass(Class clazz, Class lookingFor)
+   {
+      return matchClass(clazz, lookingFor, 0);
+   }
+   
+   /**
+    * Recursive method that return the distance between <code>wanted</code> and <code>
+    * candidate</code> in the class hierarchy.
+    * 
+    * @param wanted      the expected type of the parameter
+    * @param candidate   the current type being matched
+    * @param matchDegree the current matchDegree
+    * @return -1 if a value of type <code>lookingFor</code> can't be assigned to
+    *         a parameter of type <code>class</code>; the distance between <code>class
+    *         </code> and <code>lookingFor</code> otherwise.
+    */
+   private int matchClass(Class wanted, Class candidate, int matchDegree)
+   {
+      if (candidate == null)
+      {
+         return -1;
+      }
+      if (candidate.equals(wanted))
+      {
+         return matchDegree;
+      }
+
+      matchDegree++;
+      
+      Class[] interfaces = candidate.getInterfaces();
+      for (int i = 0 ; i < interfaces.length ; i++)
+      {
+         if (matchClass(wanted, interfaces[i], matchDegree) > 0)
+         {
+            return matchDegree;
+         }
+      }
+      
+      if (matchClass(wanted, candidate.getSuperclass(), matchDegree) > 0)
+      {
+         return matchDegree;
+      }
+      return -1;
+   }
+
+   /**
+    * Returns the rank of this advice.
+    * @return the rank value
+    */
+   public final int getRank()
+   {
+      return rank;
+   }
+   
+   /**
+    * Compares this advice info against <code>o</code> in decreasing order of the rank
+    * value.
+    */
+   public int compareTo(AdviceInfo o)
+   {
+      return ((AdviceInfo)o).rank - rank;
+   }
+   
+   public String toString()
+   {
+      return method.toString();
+   }
+   
+   /**
+    * Validate this advice, indicating whether it can be the answer to the method query
+    * contained in <code>properties</code>.
+    * 
+    * @param properties        contains information about the queried method
+    * @param mutuallyExclusive a list of mutually exclusive rules
+    * @param canReturn        indicates whether the advice method should return a value
+    * @return                  <code>true</code> only if this advice is valid
+    */
+   public abstract boolean validate(AdviceMethodProperties properties,
+         int[][] mutuallyExclusive, boolean canReturn);
+
+   /**
+    * Returns the distance in hierarchy between the annotated parameter identified by
+    * <code>annotationIndex</code>, and the expected type of this parameter.
+    * 
+    * @param annotationIndex  identifies a parameter annotation rule
+    * @param properties       contains information about the queried advice method
+    * @return                 the assignability degree if there is a parameter with the
+    *                         annotation identified by <code>typeIndex</code>; -1 otherwise.
+    */
+   public abstract int getAssignabilityDegree(int annotationIndex,
+         AdviceMethodProperties properties);
+   
+   /**
+    * Assign information of this advice to <code>properties</code>.
+    * 
+    * @param properties contains information about the queried advice method.
+    */
+   public abstract void assignAdviceInfo(AdviceMethodProperties properties);
+   
+}
\ No newline at end of file

Copied: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceMethodFactory.java (from rev 58452, projects/aop/trunk/aop/src/main/org/jboss/aop/advice/AdviceMethodFactory.java)
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/AdviceMethodFactory.java	2006-11-16 15:59:40 UTC (rev 58452)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceMethodFactory.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,402 @@
+/*
+* 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.annotation;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.advice.AdviceMethodProperties;
+import org.jboss.aop.util.ReflectUtils;
+
+/**
+ * Utility class to figure out which advice method to use for a given joinpoint
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author Flavia Rainone
+ * @version $Revision$
+ */
+public class AdviceMethodFactory
+{
+   /**
+    * Factory that selects advice methods for <i>before</i> interception.
+    */
+   public static final AdviceMethodFactory BEFORE = new AdviceMethodFactory (null,
+         new ParameterAnnotationRule[]{ParameterAnnotationRule.JOIN_POINT,
+         ParameterAnnotationRule.ARGS, ParameterAnnotationRule.ARG},
+         new int[][]{{1,2}}, false);
+   /**
+    * Factory that selects advice methods for <i>after</i> interception.
+    */
+   public static final       AdviceMethodFactory AFTER = new AdviceMethodFactory (null,
+         new ParameterAnnotationRule[]{ParameterAnnotationRule.JOIN_POINT,
+         ParameterAnnotationRule.RETURN, ParameterAnnotationRule.ARGS,
+         ParameterAnnotationRule.ARG}, new int[][]{{2, 3}}, true);
+   /**
+    * Factory that selects advice methods for <i>throwing</i> interception.
+    */
+   public static final AdviceMethodFactory THROWING = new AdviceMethodFactory (null,
+         new ParameterAnnotationRule[]{ParameterAnnotationRule.JOIN_POINT,
+         ParameterAnnotationRule.THROWABLE, ParameterAnnotationRule.ARGS,
+         ParameterAnnotationRule.ARG}, new int[][]{{2, 3}}, false);
+   /**
+    * Factory that selects advice methods for <i>aroung</i> interception.
+    */
+   public static final AdviceMethodFactory AROUND = new AdviceMethodFactory (
+         // around can also follow a specific signature instead of following
+         // parameter annotation rules
+         new AdviceSignatureRule()
+         {
+            public boolean applies(Method method)
+            {  
+               // only one parameter
+               Annotation[][] annotations = method.getParameterAnnotations();
+               if (annotations.length != 1)
+               {
+                 return false;
+               }
+               // not annotated
+               for (Annotation annotation: annotations[0])
+               {
+                  if (annotation.annotationType().getClass().getPackage() == 
+                     AdviceMethodProperties.class.getPackage())
+                  {
+                     return false;
+                  }
+               }
+               // returning Object
+               if (method.getReturnType() != Object.class)
+               {
+                  if (AspectManager.verbose)
+                  {
+                     adviceMatchingMessage.append("\n[warn] - method ");
+                     adviceMatchingMessage.append(method);
+                     adviceMatchingMessage.append(" doesn't match default around signature because it returns ");
+                     adviceMatchingMessage.append(method.getReturnType());
+                     adviceMatchingMessage.append(" intead of java.lang.Object");
+                  }
+                  return false;
+               }
+               return true;
+            }
+            
+            public AdviceInfo getAdviceInfo(Method method)
+            {
+               // creates an advice info with the greatest rank of all advices
+               return new AdviceInfo(method, 500)
+               {
+                  public boolean validate(AdviceMethodProperties properties,
+                        int[][] mutuallyExclusive, boolean mustReturn)
+                  {
+                     if(parameterTypes[0].isAssignableFrom(properties.getInvocationType()))
+                     {
+                        return true;
+                     }
+                     if (AspectManager.verbose)
+                     {
+                        adviceMatchingMessage.append("\n[warn] - argument 0 of method ");
+                        adviceMatchingMessage.append(method);
+                        adviceMatchingMessage.append(" isn't assignable from ");
+                        adviceMatchingMessage.append(properties.getInvocationType());
+                     }
+                     return false;
+                  }
+
+                  public int getAssignabilityDegree(int typeIndex,
+                        AdviceMethodProperties properties)
+                  {
+                     return matchClass(parameterTypes[0], properties.getInvocationType());
+                  }
+                  
+                  public void assignAdviceInfo(AdviceMethodProperties properties)
+                  {
+                     properties.setFoundProperties(this.method, new int[]{
+                           AdviceMethodProperties.INVOCATION_ARG});
+                  }
+               };
+            }
+         },         
+         new ParameterAnnotationRule[]{ParameterAnnotationRule.INVOCATION,
+         ParameterAnnotationRule.ARGS, ParameterAnnotationRule.ARG},
+         new int[][]{{1, 2}}, true);
+         
+
+   static StringBuffer adviceMatchingMessage = new StringBuffer();
+   
+   /**
+    * Method that returns log information about the last matching process executed.
+    * Should be called only if <code>Aspect.verbose</code> is <code>true</code>.
+    * 
+    * @return advice matching log information
+    */
+   public final static String getAdviceMatchingMessage()
+   {
+      String message = adviceMatchingMessage.toString();
+      adviceMatchingMessage = new StringBuffer();
+      return message;
+   }
+   
+   private boolean canReturn;
+   private AdviceSignatureRule adviceSignatureRule;
+   private ParameterAnnotationRule[] rules;
+   private int[][] mutuallyExclusive;
+
+   
+   /**
+    * Creates an advice method factory.
+    * 
+    * @param adviceSignatureRule the factory can have a highest priority signature rule,
+    *                            that avoids the parameter rules verification.
+    * @param rules               the parameter annotation rules that can be used by
+    *                            this factory on the advice method matching.
+    * @param mutuallyExclusive   collection of the rules that are mutually exclusive
+    * @param canReturn          indicates whether the queried advice methods can return
+    *                            a value to overwrite the join point execution result.
+    */
+   private AdviceMethodFactory(AdviceSignatureRule adviceSignatureRule,
+         ParameterAnnotationRule[] rules, int[][] mutuallyExclusive,
+         boolean canReturn)
+   {
+      this.adviceSignatureRule = adviceSignatureRule;
+      this.rules = rules;
+      this.mutuallyExclusive = mutuallyExclusive;
+      this.canReturn = canReturn;
+   }
+   
+   /**
+    * Finds the more appropriate advice method.
+    * 
+    * @param properties contains information regarding the queried advice method
+    * @return           a properties fullfilled with the found method information. Can be
+    *                   <code>null</code> if no suitable method was found.
+    */
+   public final AdviceMethodProperties findAdviceMethod(AdviceMethodProperties properties)
+   {
+      Method[] methods = ReflectUtils.getMethodsWithName(
+            properties.getAspectClass(), properties.getAdviceName());
+    
+      if (methods.length == 0)
+      {
+         if (AspectManager.verbose)
+         {
+            adviceMatchingMessage.append("\n[warn] - advice method ");
+            adviceMatchingMessage.append(properties.getAspectClass());
+            adviceMatchingMessage.append(".");
+            adviceMatchingMessage.append(properties.getAdviceName());
+            adviceMatchingMessage.append("not found");
+         }
+         return null;
+      }
+      
+      LinkedList<AdviceInfo> rankedAdvices = new LinkedList<AdviceInfo>();
+      for (int i = 0; i < methods.length; i++)
+      {
+         // advice applies to signature rule
+         if (adviceSignatureRule != null &&
+               adviceSignatureRule.applies(methods[i]))
+         {
+            rankedAdvices.add(adviceSignatureRule.getAdviceInfo(methods[i]));
+         }
+         else
+         {
+            try
+            {
+               // advice applies to annotated parameter rules
+               rankedAdvices.add(new AnnotatedParameterAdviceInfo(methods[i], rules));
+            }catch (ParameterAnnotationRuleException pare)
+            {
+               // no need to print messages -> exception prints automatically on verbose
+            } catch (MultipleAdviceInfoException maie)
+            {
+               // parameters with more than one annotation
+               rankedAdvices.addAll(AnnotatedParameterAdviceInfo.createAllAdviceInfo(
+                     methods[i], rules, maie.totalInstances, maie.annotations));
+            }
+         }
+      }
+      // no advice method following the rules was found
+      if (rankedAdvices.isEmpty())
+      {
+         return null;
+      }
+      // sort according to rank
+      Collections.sort(rankedAdvices);
+      // validate and retrive best match
+      AdviceInfo bestAdvice = bestValidAdvice(rankedAdvices, properties);
+      if (bestAdvice == null)
+      {
+         return null;
+      }
+      // assign best Advice info to properties 
+      bestAdvice.assignAdviceInfo(properties);
+      return properties;
+   }
+   
+   /**
+    * Validates the highest rank advice methods and return the best match.
+    * 
+    * @param rankedAdvices a sorted collection of advice infos
+    * @param properties    contains information about the queried advice method
+    * @return              information about the best advice method match
+    */
+   private AdviceInfo bestValidAdvice(LinkedList<AdviceInfo> rankedAdvices,
+         AdviceMethodProperties properties)
+   {
+      AdviceInfo bestAdvice = null;
+      ListIterator<AdviceInfo> iterator = rankedAdvices.listIterator();
+      while (iterator.hasNext())
+      {
+         AdviceInfo advice = iterator.next();
+         if (advice.validate(properties, mutuallyExclusive, canReturn))
+         {
+            bestAdvice = advice;
+            break;
+         }
+         else
+         {
+            iterator.remove();
+         }
+      }
+      
+      switch(rankedAdvices.size())
+      {
+      case 0:
+         // no valid advice method was found
+         return null;
+      case 1:
+         // only one valid advice method
+         return bestAdvice;
+      }
+      // is there only one advice method valid with the highest rank?
+      while (iterator.hasNext())
+      {
+         AdviceInfo advice = iterator.next();
+         if (advice.getRank() == bestAdvice.getRank())
+         {
+            if (!advice.validate(properties, mutuallyExclusive, canReturn))
+            {
+               iterator.remove();
+            }
+         }
+         else
+         {
+            iterator.previous();
+            break;
+         }
+      }
+      // if yes, return it
+      if (iterator.previous() == bestAdvice)
+      {
+         return bestAdvice;
+      }
+      iterator.next();
+      // if not, retrive the list of all valid advices with the highest rank
+      List<AdviceInfo> bestAdvices =
+         rankedAdvices.subList(0, iterator.nextIndex());
+      Class returnType = properties.getJoinpointReturnType();
+      // deep process these advices to find the best match
+      return bestMatch(bestAdvices, properties);
+   }
+   
+   /**
+    * Return the best advice method among the advices contained in <code>greatestRank
+    * </code>. The criteria used is the specificness of annotated parameters type,
+    * i.e., the more specific type <code>MethodInvocation</code> is better than
+    * <code>Invocation</code>.
+    * 
+    * @param greatestRank contains information about all valid advice methods with the
+    *                     highest rank
+    * @param properties   information about the queried advice method
+    * @return             information about the best advice method match
+    */
+   AdviceInfo bestMatch(Collection<AdviceInfo> greatestRank,
+         AdviceMethodProperties properties)
+   {
+      int bestDegree = -1;
+      AdviceInfo bestAdvice = null;
+      // rule i is more important than rule i + 1
+      for (int i = 0; i < rules.length; i++)
+      {
+         for (Iterator<AdviceInfo> iterator = greatestRank.iterator();
+               iterator.hasNext();)
+         {
+            AdviceInfo currentAdvice = iterator.next();
+            int currentDegree = currentAdvice.getAssignabilityDegree(i, properties);
+            // advice has no annotation of type i
+            if (currentDegree == -1)
+            {
+               if (bestDegree != -1)
+               {
+                  // this advice is worst than the best current match
+                  greatestRank.remove(currentAdvice);
+               }
+               else if (bestAdvice == null)
+               {
+                  // current best advice has no parameter with this annotation
+                  bestAdvice = currentAdvice;
+               }
+            }
+            // this advice is better than current best match
+            else if (bestDegree == -1 || currentDegree < bestDegree)
+            {
+               if (bestAdvice != null)
+               {
+                  // the old best advice is gone
+                  greatestRank.remove(bestAdvice);
+               }
+               bestDegree = currentDegree;
+               bestAdvice = currentAdvice;
+            }
+            // this advice is not as good as current best match
+            else if (currentDegree > bestDegree)
+            {
+               greatestRank.remove(currentAdvice);
+            }
+         }
+         // found the best
+         if (greatestRank.size() == 1)
+         {
+            return greatestRank.iterator().next();
+         }
+         // reset values
+         bestAdvice = null;
+         bestDegree = -1;
+      }
+      // two or more advices with the same match degree, pick any one of them
+      return greatestRank.iterator().next();
+   }
+   
+   /**
+    * Represents a highest priority signature rule alternative to the parameter rules.
+    */
+   interface AdviceSignatureRule
+   {
+      boolean applies(Method method);
+      AdviceInfo getAdviceInfo(Method method);
+   }
+}
\ No newline at end of file


Property changes on: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceMethodFactory.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AnnotatedParameterAdviceInfo.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AnnotatedParameterAdviceInfo.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AnnotatedParameterAdviceInfo.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,630 @@
+package org.jboss.aop.advice.annotation;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.advice.AdviceMethodProperties;
+
+/**
+ * Information about an advice method whose parameters should annotated according to
+ * <code>ParameterAnnotationRule</code>s.
+ * 
+ * @author Flavia Rainone
+ */
+class AnnotatedParameterAdviceInfo extends AdviceInfo
+{
+   // list that may contain temporary information regarding parameters with more than one
+   // valid annotation. Field is static to avoid the cost of constantly creating a list
+   private static List<Integer> extraAnnotations = new ArrayList<Integer>();
+   
+   // the annotated parameter types
+   private ParameterAnnotationType paramTypes[];
+   
+   /**
+    * Creates an annotated parameter advice info.
+    * 
+    * @param method the advice method
+    * @param rules  the annnotated parameter rules this method should comply with
+    * 
+    * @throws ParameterAnnotationRuleException thrown when the advice method does not
+    *         comply with a parameter annotation rule.
+    * @throws MultipleAdviceInfoException thrown when one parameter contains more than one
+    *         valid annotation. Indicates that there must be multiple advice infos to
+    *         represent <code>method</code>.
+    */
+   public AnnotatedParameterAdviceInfo(Method method, ParameterAnnotationRule[] rules)
+      throws ParameterAnnotationRuleException, MultipleAdviceInfoException
+   {
+      this(rules, method);
+      this.applyRules();
+   }
+   
+   /**
+    * Private constructor. Called only internally, does not apply the parameter annotation
+    * rules to the advice method parameters.
+    * 
+    * @param rules  the parameter annotation rules this method should comply with
+    * @param method the advice method 
+    */
+   private AnnotatedParameterAdviceInfo(ParameterAnnotationRule[] rules, Method method)
+   {
+      super(method, 0);
+      this.paramTypes = new ParameterAnnotationType[rules.length];
+      // create appropriate annotated parameter types for each AP rule
+      for (int i = 0; i < rules.length; i++)
+      {
+         if (rules[i].isSingleEnforced())
+         {
+            this.paramTypes[i] = new SingleParameterType(rules[i]);
+         }
+         else
+         {
+            this.paramTypes[i] = new MultipleParameterType(rules[i],
+                  method.getParameterTypes().length);
+         }
+      }
+   }
+   
+   /**
+    * Creates all advice info instances necessary for representing the multi-annotated
+    * parameters of <code>method</code>.
+    * <p>Should be invoked when the constructor of <code>AnnotatedParamereAdviceInfo
+    * </code> throws a <code>MultipleAdviceInfoException</code>.
+    * 
+    * @param method          the method that contains parameters with more than one
+    *                        valid annotations
+    * @param rules           the parameter annotation rules
+    * @param totalInstances  the total number of instances that must be created
+    * @param annotations     the list of annotated parameter indexes
+    * @return  all advice info instances representing <code>method</code>.
+    */
+   public static List<AnnotatedParameterAdviceInfo> createAllAdviceInfo(
+         Method method, ParameterAnnotationRule[] rules, int totalInstances,
+         int[][]annotations)
+   {
+      List<AnnotatedParameterAdviceInfo> allAdvices =
+         new LinkedList<AnnotatedParameterAdviceInfo>();
+      Set<AnnotatedParameterAdviceInfo> removeAdvices =
+         new HashSet<AnnotatedParameterAdviceInfo>();
+      // create instances
+      for (int i = 0; i < totalInstances; i++)
+      {
+         allAdvices.add(new AnnotatedParameterAdviceInfo(rules, method));
+      }
+      // set all the possible combinations of parameter annotations to the instances
+      for (int i = 0; i < annotations.length; i++)
+      {
+         for (Iterator<AnnotatedParameterAdviceInfo> iterator = allAdvices.iterator();
+         iterator.hasNext();)
+         {
+            for (int j = 0; j < annotations[i].length; j++)
+            {
+               AnnotatedParameterAdviceInfo adviceInfo = iterator.next();
+               try
+               {
+                  adviceInfo.paramTypes[annotations[i][j]].setIndex(i);
+               } catch (ParameterAnnotationRuleException maoe)
+               {
+                  removeAdvices.add(adviceInfo);
+               }
+            }
+         }
+      }
+      // remove all combinations that resulted in multiple annotation exception
+      allAdvices.removeAll(removeAdvices);
+      return allAdvices;
+   }
+   
+   public boolean validate(AdviceMethodProperties properties,
+         int[][] mutuallyExclusive, boolean canReturn)
+   {
+      for (ParameterAnnotationType paramType: paramTypes)
+      {
+         if (!paramType.validate(properties))
+         {
+            return false;
+         }
+      }
+      if (canReturn && properties.getJoinpointReturnType() != void.class &&
+            !properties.getJoinpointReturnType().
+            isAssignableFrom(method.getReturnType()))
+      {
+         if (AspectManager.verbose)
+         {
+            AdviceMethodFactory.adviceMatchingMessage.append("\n[warn] - return value of ");
+            AdviceMethodFactory.adviceMatchingMessage.append(method);
+            AdviceMethodFactory.adviceMatchingMessage.append(" can not be assigned to type ");
+            AdviceMethodFactory.adviceMatchingMessage.append(properties.getJoinpointReturnType());
+         }
+         return false;
+      }
+      
+      for (int i = 0; i < mutuallyExclusive.length; i++)
+      {
+         int[] exclusiveParamTypes = mutuallyExclusive[i];
+         int found = -1;
+         for (int j = 0; j < exclusiveParamTypes.length; j++)
+         {
+            if (paramTypes[exclusiveParamTypes[j]].isSet())
+            {
+               if (found != -1)
+               {
+                  if (AspectManager.verbose)
+                  {
+                     AdviceMethodFactory.adviceMatchingMessage.append("\n[warn] - the use of parameter annotations ");
+                     AdviceMethodFactory.adviceMatchingMessage.append(paramTypes[exclusiveParamTypes[found]].rule.getAnnotation());
+                     AdviceMethodFactory.adviceMatchingMessage.append(" and ");
+                     AdviceMethodFactory.adviceMatchingMessage.append(paramTypes[exclusiveParamTypes[j]].rule.getAnnotation());
+                     AdviceMethodFactory.adviceMatchingMessage.append(" is mutually exclusive");
+                  }
+                  return false;
+               }
+               found = j;
+            }
+         }
+      }
+      return true;
+   }
+   
+   public int getAssignabilityDegree(int annotationIndex,
+         AdviceMethodProperties properties)
+   {
+      return paramTypes[annotationIndex].getAssignabilityDegree(properties);
+   }
+   
+   public void assignAdviceInfo(AdviceMethodProperties properties)
+   {
+      int args[] = new int[parameterTypes.length];
+      for (int i = 0; i < paramTypes.length; i++)
+      {
+         paramTypes[i].assignParameterInfo(args);
+      }
+      properties.setFoundProperties(this.method, args);
+   }
+
+   /**
+    * Applies all parameter annotation rules to the advice method parameters.
+    * 
+    * @throws ParameterAnnotationRuleException thrown when the advice method does not
+    *         comply with a parameter annotation rule.
+    * @throws MultipleAdviceInfoException thrown when one or more parameters is annotated
+    *         with more than one valid annotation
+    */
+   private void applyRules() throws ParameterAnnotationRuleException,
+      MultipleAdviceInfoException
+   {
+      Annotation[][] paramAnnotations = method.getParameterAnnotations();
+      int[] annotated = new int[paramAnnotations.length];
+      for (int i = 0; i < paramAnnotations.length; i++)
+      {
+         annotated[i] = -1;
+         extraAnnotations.clear();
+         for (Annotation annotation: paramAnnotations[i])
+         {
+            // no valid annotation found for parameter i yet
+            if (annotated[i] == -1)
+            for (int j = 0; j < paramTypes.length; j++)
+            {
+               // found
+                if (paramTypes[j].applies(annotation, i))
+                {
+                   annotated[i] = j;
+                   break;
+                }
+            }
+            else
+            {
+               // look for an extra annotation
+               extraAnnotations.add(annotated[i]);
+               for (int j = 0; j < paramTypes.length; j++)
+               {
+                  if (paramTypes[j].applies(annotation))
+                  {
+                     extraAnnotations.add(j);
+                  }
+               }
+            }
+         }
+         if (annotated[i] == -1)
+         {
+            throwAnnotationNotFoundException(i);
+            
+         }
+         else if(extraAnnotations.size() > 1)
+         {
+            throwMAIException(paramAnnotations, annotated, i);
+         }
+      }
+      
+   }
+
+   /**
+    * Throws an exception indicating the ith parameter of this advice is not annotated.
+    * 
+    * @param i the index of the not annotated parameter.
+    * 
+    * @throws ParameterAnnotationRuleException
+    */
+   private final void throwAnnotationNotFoundException(int i)
+      throws ParameterAnnotationRuleException
+   {
+      if (AspectManager.verbose)
+      {
+         throw new ParameterAnnotationRuleException("[warn] -parameter " + i  +
+               " of method " + method +  " is not annotated");
+      }
+      else
+      {
+         throw new ParameterAnnotationRuleException(null);
+      }
+   }
+
+   /**
+    * Throws an exception indicating this advice contains one ore more parameters with
+    * more than one valid annotation.
+    * The exception thrown contains all information about the advice method parameter
+    * annotations.
+    * 
+    * @param paramAnnotations      the list of parameter annotations of this advice method
+    * @param singleAnnotations     the list of previous parameters whose single annotation
+    *                              has been processed
+    * @param singleAnnotationsSize the number parameteres whose single annotation has been
+    *                              processed before a multi-annotated parameter was found
+    * @throws MultipleAdviceInfoException
+    */
+   private void throwMAIException(Annotation[][] paramAnnotations,
+      int[] singleAnnotations, int singleAnnotationsSize)
+      throws MultipleAdviceInfoException
+   {
+      int[][] allAnnotations = new int[paramAnnotations.length][];
+      int i = singleAnnotationsSize;
+      // record single annotation information
+      for (int j = 0; j < i; j++)
+      {
+         allAnnotations[j] = new int[1];
+         allAnnotations[j][0] = singleAnnotations[j];
+      }
+      // fill multi-annotations information
+      int totalCombinations = fillAllAnnotations(allAnnotations, i);
+      
+      while (++i < paramAnnotations.length)
+      {
+         extraAnnotations.clear();
+         for (Annotation annotation: paramAnnotations[i])
+         {
+            for (int j = 0; j < paramTypes.length; j++)
+            {
+               if (paramTypes[j].applies(annotation))
+               {
+                  extraAnnotations.add(j);
+               }
+            }
+         }
+         if (extraAnnotations.isEmpty())
+         {
+            throw new RuntimeException("Parameter " + singleAnnotationsSize  + " of method " +
+                  method +  " is not annotated");
+         }
+         totalCombinations *= fillAllAnnotations(allAnnotations, i);
+      }
+      throw new MultipleAdviceInfoException(totalCombinations, allAnnotations);
+   }
+   
+   /**
+    * Helper method that fills <code>allAnnotations[i]</code> with all annotations found
+    * on the ith advice parameter.
+    * @param allAnnotations the list of all annotations found on this advice method
+    * @param i              the index of the parameter whose annotations must be filled in
+    *                       <code>allAnnotations</code>.
+    * @return the total number of annotations found on the ith parameter
+    */
+   private int fillAllAnnotations(int[][] allAnnotations, int i)
+   {
+      allAnnotations[i] = new int[extraAnnotations.size()];
+      Iterator<Integer> iterator = extraAnnotations.iterator();
+      for (int k = 0; k < allAnnotations[i].length; k++)
+      {
+         allAnnotations[i][k] = iterator.next();
+      }
+      return allAnnotations[i].length;
+   }
+   
+   /**
+    * Contains validation data concerning a parameter annotation rule.
+    */
+   abstract class ParameterAnnotationType
+   {
+      ParameterAnnotationRule rule;
+      
+      public ParameterAnnotationType(ParameterAnnotationRule rule)
+      {
+         this.rule = rule;
+      }
+      
+      /**
+       * Indicates whether <code>parameterAnnotation</code> is of this type.
+       * 
+       * @param parameterAnnotation the parameter annotation
+       * @return <code>true</code> if parameter annotation is of this type
+       */
+      public final boolean applies(Annotation parameterAnnotation)
+      {
+         return parameterAnnotation.annotationType() == rule.getAnnotation();
+      }
+      
+      /**
+       * Verifies if <code>parameterAnnotation</code> is of this type, and, if it is,
+       * sets the parameter index information.
+       * 
+       * @param parameterAnnotation the parameter annotation
+       * @param parameterIndex      the parameter index
+       * @return <code>true</code> if <code>parameterAnnotation</code> is of this type
+       * @throws ParameterAnnotationRuleException if the parameter annotation has more
+       *         than one occurrence and this is forbidden by the annotation rule
+       */
+      public final boolean applies(Annotation parameterAnnotation, int parameterIndex)
+         throws ParameterAnnotationRuleException
+      {
+         if (parameterAnnotation.annotationType() == rule.getAnnotation())
+         {
+            setIndex(parameterIndex);
+            return true;
+         }
+         return false;
+      }
+
+      /**
+       * Validates the occurences of this parameter type, according to the annotaion rule
+       * and to <code>properties</code>.
+       * 
+       * @param properties contains information about the queried method
+       * @return <code>true</code> if the occurrences of this parameter type are all valid
+       */
+      public final boolean validate(AdviceMethodProperties properties)
+      {
+         if (rule.isMandatory() && !isSet())
+         {
+            if (AspectManager.verbose)
+            {
+               AdviceMethodFactory.adviceMatchingMessage.append("\n[warn] - mandatory parameter annotation ");
+               AdviceMethodFactory.adviceMatchingMessage.append(rule.getAnnotation());
+               AdviceMethodFactory.adviceMatchingMessage.append("not found on method ");
+               AdviceMethodFactory.adviceMatchingMessage.append(method);
+            }
+            return false;
+         }
+         return internalValidate(properties);
+      }
+
+      
+      /**
+       * Records that the parameter identified by <code>paramterIndex</code> is of this
+       * type.
+       * @param parameterIndex the index of the parameter
+       * @throws ParameterAnnotationRuleException if the parameter annotation has more
+       *         than one occurrence and this is forbidden by the annotation rule
+       */
+      public abstract void setIndex(int parameterIndex) throws ParameterAnnotationRuleException;
+
+      /**
+       * Returns <code>true</code> if there is a parameter of this type.
+       */
+      public abstract boolean isSet();
+      
+      /**
+       * Validates the occurences of this parameter type, according to the annotation rule
+       * and to <code>properties</code>.
+       * 
+       * @param properties contains information about the queried method
+       * @return <code>true</code> if the occurrences of this parameter type are all valid
+       */
+      public abstract boolean internalValidate(AdviceMethodProperties properties);
+      
+      /**
+       * Returns the sum of the assignability degrees of every paramater of this type.
+       * 
+       * @param properties       contains information about the queried advice method
+       * @return                 the assignability degree if this parameter type on the
+       *                         advice method
+       */
+      public abstract int getAssignabilityDegree(AdviceMethodProperties properties);
+      
+      /**
+       * Assigns information regarding all occurences of this parameter type on the
+       * advice method to <code>args</code>.
+       * 
+       * @param args array containing information of parameter type occurrences
+       */
+      public abstract void assignParameterInfo(int[] args);
+   }
+
+   /**
+    * A parameter type whose annotation can occur only once in an advice method.
+    */
+   class SingleParameterType extends ParameterAnnotationType
+   {
+      int index;
+      
+      public SingleParameterType(ParameterAnnotationRule rule)
+      {
+         super(rule);
+         this.index = -1;
+      }
+      
+      public final void setIndex(int parameterIndex)
+         throws ParameterAnnotationRuleException
+      {
+         if (this.index != -1)
+         {
+            if (AspectManager.verbose)
+            {
+               throw new ParameterAnnotationRuleException("[warn] - found more than "
+                     + "one occurence of " + rule.getAnnotation().getName() +
+                     " on parameters of advice" + method);  
+            }
+            throw new ParameterAnnotationRuleException(null);
+         }
+         this.index = parameterIndex;
+         rank += rule.getRankGrade();
+      }
+
+      public final boolean isSet()
+      {
+         return this.index != -1;
+      }
+      
+      public final boolean internalValidate(AdviceMethodProperties properties)
+      {
+         if (index != -1 && !method.getParameterTypes()[index].isAssignableFrom(
+               (Class) rule.getAssignableFrom(properties)))
+         {
+            if (AspectManager.verbose)
+            {
+               AdviceMethodFactory.adviceMatchingMessage.append("\n[warn] - parameter annotated with ");
+               AdviceMethodFactory.adviceMatchingMessage.append(rule.getAnnotation());
+               AdviceMethodFactory.adviceMatchingMessage.append(" is not assignable from expected type ");
+               AdviceMethodFactory.adviceMatchingMessage.append(rule.getAssignableFrom(properties));   
+               AdviceMethodFactory.adviceMatchingMessage.append(" on  method ");
+               AdviceMethodFactory.adviceMatchingMessage.append(method);
+            }
+            return false;
+         }
+         return  true;
+      }
+
+      public final int getAssignabilityDegree(AdviceMethodProperties properties)
+      {
+         if (this.index == -1)
+         {
+            return -1;
+         }
+         return matchClass(method.getParameterTypes()[this.index],
+               (Class) rule.getAssignableFrom(properties));
+      }
+      
+      public final void assignParameterInfo(int[] args)
+      {
+         if (this.index != -1)
+         {
+            args[index] = rule.getProperty();
+         }
+      }
+   }
+
+   /**
+    * A parameter type whose annotation can occur more than once in an advice method.
+    */   
+   class MultipleParameterType extends ParameterAnnotationType
+   {
+      private int[][] indexes;
+      private int indexesLength;
+      
+      // maximum size is the total number of parameters
+      public MultipleParameterType(ParameterAnnotationRule rule, int totalParams)
+      {
+         super(rule);
+         this.indexes = new int[totalParams][2];
+         this.indexesLength = 0;
+      }
+      
+      public final void setIndex(int index) throws ParameterAnnotationRuleException
+      {
+         if (indexesLength == indexes.length)
+         {
+            throw new ParameterAnnotationRuleException("Found more arg annotated parameters");
+         }
+         indexes[indexesLength++][0] = index;
+         rank += rule.getRankGrade();
+      }
+      
+      public final boolean isSet()
+      {
+         return indexesLength > 0;
+      }
+      
+      public final boolean internalValidate(AdviceMethodProperties properties)
+      {
+         Class<?>[] expectedTypes = (Class<?>[]) rule.getAssignableFrom(properties);
+         Class<?>[] adviceTypes = method.getParameterTypes();
+         boolean[] taken = new boolean[expectedTypes.length];
+         for (int i = 0; i < indexesLength; i++)
+         {
+            boolean found = false;
+            for (int j = 0; j < expectedTypes.length; j++)
+            {
+               if (adviceTypes[indexes[i][0]] == expectedTypes[j] && !taken[j])
+               {
+                  indexes[i][1] = j;
+                  taken[j] = true;
+                  found = true;
+                  break;
+               }
+            }
+            if (!found)
+            {
+               for (int j = 0; j < expectedTypes.length; j++)
+               {
+                  if (adviceTypes[indexes[i][0]].isAssignableFrom(expectedTypes[j]) &&
+                        !taken[j])
+                  {
+                     indexes[i][1] = j;
+                     taken[j] = true;
+                     found = true;
+                     break;
+                  }
+               }
+               if (!found)
+               {
+                  if (AspectManager.verbose)
+                  {
+                     AdviceMethodFactory.adviceMatchingMessage.append("\n[warn] - not found a match for argument ");
+                     AdviceMethodFactory.adviceMatchingMessage.append(adviceTypes[indexes[i][0]]);
+                     AdviceMethodFactory.adviceMatchingMessage.append(" of ");
+                     AdviceMethodFactory.adviceMatchingMessage.append(method);
+                     AdviceMethodFactory.adviceMatchingMessage.append("\n[warn]   expected one of types:");
+                     for (int j = 0; j < expectedTypes.length; j++)
+                     {
+                        AdviceMethodFactory.adviceMatchingMessage.append(expectedTypes[j]);
+                        AdviceMethodFactory.adviceMatchingMessage.append(" ");
+                     }
+                  }
+                  return false;
+               }
+            }
+         }
+         return true;
+      }
+      
+      public int getAssignabilityDegree(AdviceMethodProperties properties)
+      {
+         if (indexesLength == 0)
+         {
+            return -1;
+         }
+         Class[] expectedTypes = (Class[]) rule.getAssignableFrom(properties);
+         Class[] paramTypes = method.getParameterTypes();
+         int level = 0;
+         for (int i = 0; i < indexesLength; i++)
+         {
+            level += matchClass(method.getParameterTypes()[this.indexes[i][0]],
+                  expectedTypes[this.indexes[i][1]]);
+         }
+         return level; 
+      }
+      
+      public void assignParameterInfo(int args[])
+      {
+         for (int i = 0; i < indexesLength; i++)
+         {
+            args[this.indexes[i][0]] = this.indexes[i][1];
+         }
+      }  
+   }
+}
\ No newline at end of file

Copied: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Arg.java (from rev 58665, projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Arg.java)
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Arg.java	2006-11-24 00:52:12 UTC (rev 58665)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Arg.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,36 @@
+/*
+ * 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.annotation;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Use this annotation on advice parameters that should contain values of 
+ * advised joinpoint arguments.
+ * 
+ * @author Flavia Rainone
+ */
+ at Target (ElementType.PARAMETER) @Retention(RetentionPolicy.RUNTIME)
+public @interface Arg {}
\ No newline at end of file

Copied: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Args.java (from rev 58665, projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Args.java)
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Args.java	2006-11-24 00:52:12 UTC (rev 58665)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Args.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,40 @@
+/*
+ * 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.annotation;
+
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Use this annotation on the advice parameter that receives the complete list of
+ * joinpoint argument values.
+ * The annotated parameter must be of type <code>Object[]</code> and there
+ * should not be any other advice parameter annotated either with {@link Arg} or
+ * with <code>Args</code> itself.
+ * 
+ * @author Flavia Rainone
+ */
+ at Target (ElementType.PARAMETER) @Retention (RetentionPolicy.RUNTIME)
+public @interface Args {}
\ No newline at end of file

Copied: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Callee.java (from rev 58665, projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Callee.java)
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Callee.java	2006-11-24 00:52:12 UTC (rev 58665)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Callee.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,37 @@
+/*
+  * 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.annotation;
+
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 
+ * 
+ * @author Flavia Rainone
+ */
+ at Target (ElementType.PARAMETER) @Retention (RetentionPolicy.RUNTIME)
+public @interface Callee {}
\ No newline at end of file

Copied: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Caller.java (from rev 58665, projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Caller.java)
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Caller.java	2006-11-24 00:52:12 UTC (rev 58665)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Caller.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,35 @@
+/*
+  * 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * 
+ * @author Flavia Rainone
+ */
+ at Target (ElementType.PARAMETER) @Retention (RetentionPolicy.RUNTIME)
+public @interface Caller {}
\ No newline at end of file

Copied: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Invocation.java (from rev 58665, projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Invocation.java)
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Invocation.java	2006-11-24 00:52:12 UTC (rev 58665)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Invocation.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,39 @@
+/*
+ * 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Use this annotation on the advice method parameter that receives an
+ * {@link org.jboss.aop.joinpoint.Invocation} or one of its subtypes.
+ * <p>
+ * For optimization, always prefer to use {@link JoinPoint} instead of <code>Invocation
+ * </code>.
+ * 
+ * @author Flavia Rainone
+ */
+ at Target (ElementType.PARAMETER) @Retention (RetentionPolicy.RUNTIME)
+public @interface Invocation {}
\ No newline at end of file

Copied: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/JoinPoint.java (from rev 58665, projects/aop/trunk/aop/src/main/org/jboss/aop/advice/JoinPoint.java)
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/JoinPoint.java	2006-11-24 00:52:12 UTC (rev 58665)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/JoinPoint.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,38 @@
+/*
+ * 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.jboss.aop.JoinPointInfo;
+
+/**
+ * Use this annotation on the advice parameter that receives {@link JoinPointInfo} or
+ * one of its subtypes.
+ * 
+ * @author Flavia Rainone
+ */
+ at Target( { ElementType.PARAMETER }) @Retention(RetentionPolicy.RUNTIME)
+public @interface JoinPoint {}
\ No newline at end of file

Added: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/MultipleAdviceInfoException.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/MultipleAdviceInfoException.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/MultipleAdviceInfoException.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,31 @@
+package org.jboss.aop.advice.annotation;
+
+/**
+ * Exception thrown when there is need to create more than one {@link
+ * AnnotatedParameterAdviceInfo} to represent the same advice method.
+ * 
+ * @author Flavia Rainone
+ */
+class MultipleAdviceInfoException extends Exception
+{
+
+   private static final long serialVersionUID = 1L;
+   
+   /**
+    * Contains the total number of AdviceInfo instances needed to represent the advice
+    * method that triggered this exception.
+    */
+   int totalInstances;
+   
+   /**
+    * Contains information about all parameter annotations of the advice method that
+    * triggered this exception. 
+    */
+   int[][] annotations;
+   
+   public MultipleAdviceInfoException(int totalInstances, int[][] annotations)
+   {
+      this.totalInstances = totalInstances;
+      this.annotations = annotations;
+   }
+}
\ No newline at end of file

Added: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/ParameterAnnotationRule.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/ParameterAnnotationRule.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/ParameterAnnotationRule.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,191 @@
+package org.jboss.aop.advice.annotation;
+
+import org.jboss.aop.JoinPointInfo;
+import org.jboss.aop.advice.AdviceMethodProperties;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * Represents the set of rules associated with a parameter annotation. Every parameter
+ * that has this annotation must comply with this rule.
+ * 
+ * @author Flavia Rainone
+ */
+enum ParameterAnnotationRule
+{
+   /**
+    * Rule for parameter annotation {@link JoinPoint}.
+    */
+   JOIN_POINT (
+         JoinPoint.class, JoinPointInfo.class, AdviceMethodProperties.JOINPOINT_ARG, 100,
+         false, true)
+   {
+      public Object getAssignableFrom(AdviceMethodProperties properties)
+      {
+         return properties.getInfoType();
+      }
+   },
+   
+   /**
+    * Rule for parameter annotation {@link Invocation}.
+    */
+   INVOCATION (
+         org.jboss.aop.advice.annotation.Invocation.class, Invocation.class,
+         AdviceMethodProperties.INVOCATION_ARG, 100, false, true)
+   {
+      public Object getAssignableFrom(AdviceMethodProperties properties)
+      {
+         return properties.getInvocationType();
+      }
+   },
+   
+   /**
+    * Rule for parameter annotation {@link Thrown}.
+    */
+   THROWABLE (
+         Thrown.class, Throwable.class, AdviceMethodProperties.THROWABLE_ARG, 40, true,
+         true),
+   
+   /**
+    * Rule for parameter annotation {@link Return}.
+    */
+   RETURN (
+         Return.class, null, AdviceMethodProperties.RETURN_ARG, 40, false, true)
+   {
+      public Object getAssignableFrom(AdviceMethodProperties properties)
+      {
+         return properties.getJoinpointReturnType();
+      }
+   },
+   
+   /**
+    * Rule for parameter annotation {@link Callee}.
+    */
+   CALLEE (
+        Callee.class, null, AdviceMethodProperties.CALLEE_ARG, 45, false, true),
+   
+   /**
+    * Rule for parameter annotation {@link Caller}.
+    */
+   CALLER (
+         Caller.class, null, AdviceMethodProperties.CALLER_ARG, 45, false, true),
+   
+   /**
+    * Rule for parameter annotation {@link Target}.
+    */
+   TARGET (
+         Target.class, null, AdviceMethodProperties.TARGET_ARG, 90, false, true),
+   
+   /**
+    * Rule for parameter annotation {@link Arg}.
+    */
+   ARG (
+         Arg.class, null, AdviceMethodProperties.ARG_ARG, 1, false, false)
+   {
+      public Object getAssignableFrom(AdviceMethodProperties properties)
+      {
+         return properties.getJoinpointParameters();
+      }
+   },
+   
+   /**
+    * Rule for parameter annotation {@link Args}.
+    */
+   ARGS (
+         Args.class, Object[].class, AdviceMethodProperties.ARGS_ARG, 30, false, true);
+   
+   private Class annotation;
+   private Class assignableFrom;
+   private int rankGrade;
+   private boolean mandatory;
+   private boolean singleEnforced;
+   private int property;
+   //AnnotatedParameterRule() {}
+   
+   /**
+    * Constructor.
+    * 
+    * @param annotation      the parameter annotation
+    * @param assignableFrom  the expected type from which the annotated parameter type
+    *                        must be assignable
+    * @param property        the property number identifying the parameter type. Must
+    *                        be one defined in {@link AdviceMethodProperties}
+    * @param rankGrade       the rank grade a parameter annotated with <code>annotatio
+    *                        </code> is worth 
+    * @param mandatory       indicates whether there must be a parameter annotated with
+    *                        <code>annotation</code>
+    * @param singleEnforced  indicates whether the multiple ocurrence of <code>
+    *                        annotation</code> in the advice method parameters is
+    *                        forbidden
+    */
+   private ParameterAnnotationRule(Class annotation, Class assignableFrom, int property,
+         int rankGrade, boolean mandatory, boolean singleEnforced)
+   {
+      this.annotation = annotation;
+      this.assignableFrom = assignableFrom;
+      this.property = property;
+      this.rankGrade = rankGrade;
+      this.mandatory = mandatory;
+      this.singleEnforced = singleEnforced;      
+   }
+
+   /**
+    * Returns the annotation associated with this rule.
+    * @return the annotation associated with this rule.
+    */
+   public final Class getAnnotation()
+   {
+      return annotation;
+   }
+
+   /**
+    * Returns the class from which the annotated parameter must be assignable.
+    * 
+    * @param properties describes the queried advice method
+    * @return the class from which the annotated parameter must be assignable
+    */
+   public Object getAssignableFrom(AdviceMethodProperties properties)
+   {
+      return assignableFrom;
+   }
+   
+   /**
+    * Returns the property identifying the annotated parameter type.
+    * @return one of the constant values defined in {@link AdviceMethodProperties}
+    */
+   public final int getProperty()
+   {
+      return this.property;
+   }
+
+   /**
+    * Returns the rank grade an annotaed parameter is worth for an instance of <code>
+    * AdviceInfo</code>.
+    * 
+    * @return the rank grade
+    */
+   public final int getRankGrade()
+   {
+      return rankGrade;
+   }   
+   
+   /**
+    * Indicates whether this annotation is mandatory.
+    * 
+    * @return <code>true</code> only if this annotation is mandatory
+    */
+   public final boolean isMandatory()
+   {
+      return mandatory;
+   }
+   
+   /**
+    * Indicates whether a multiple occurrence of this annotation is forbidden.
+    *  
+    * @return <code>true</code> only if there can be only one occurence of this annotation
+    *         on the parameters of an advice method
+    */
+   public final boolean isSingleEnforced()
+   {
+      return singleEnforced;
+   }
+}
\ No newline at end of file

Added: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/ParameterAnnotationRuleException.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/ParameterAnnotationRuleException.java	2006-11-24 13:15:39 UTC (rev 58668)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/ParameterAnnotationRuleException.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,31 @@
+package org.jboss.aop.advice.annotation;
+
+import org.jboss.aop.AspectManager;
+
+/**
+ * Exception thrown when an advice method does not comply with a parameter rule.  
+ * 
+ * @author Flavia Rainone
+ */
+class ParameterAnnotationRuleException extends Exception
+{
+   private static final long serialVersionUID = 1L;
+   
+   /**
+    * Constructor.
+    * <p>
+    * Adds <code>errorMessage</code> to {@link AdviceMethodFactory#adviceMatchingMessage}
+    * on verbose mode.
+    * 
+    * @param message a message describing why the parameter annotation rule could
+    *                not be applied to an advice method
+    */
+   public ParameterAnnotationRuleException(String message)
+   {
+      super(message);
+      if (AspectManager.verbose)
+      {
+         AdviceMethodFactory.adviceMatchingMessage.append(message);
+      }
+   }
+}
\ No newline at end of file

Copied: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Return.java (from rev 58665, projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Return.java)
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Return.java	2006-11-24 00:52:12 UTC (rev 58665)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Return.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,38 @@
+/*
+ * 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotate the advice parameter with <code>@Return</code> if it receives the return
+ * type of the join point execution.
+ * <p>
+ * Can only be used in <i>after</i>/<i>around</i> advices. 
+ * 
+ * @author Flavia Rainone
+ */
+ at Target (ElementType.PARAMETER) @Retention (RetentionPolicy.RUNTIME)
+public @interface Return {}
\ No newline at end of file

Copied: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Target.java (from rev 58665, projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Target.java)
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Target.java	2006-11-24 00:52:12 UTC (rev 58665)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Target.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,33 @@
+/*
+ * 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ *
+ * @author Flavia Rainone
+ */
+ at java.lang.annotation.Target( { ElementType.PARAMETER }) @Retention(RetentionPolicy.RUNTIME)
+public @interface Target {}
\ No newline at end of file

Copied: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Thrown.java (from rev 58665, projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Thrown.java)
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/Thrown.java	2006-11-24 00:52:12 UTC (rev 58665)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/Thrown.java	2006-11-24 17:13:41 UTC (rev 58669)
@@ -0,0 +1,36 @@
+/*
+  * 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotate with <code>@Thrown</code> the <i>throwing</i> advice parameter that receives
+ * the thrown exception.
+ * 
+ * @author Flavia Rainone
+ */
+ at Target (ElementType.PARAMETER) @Retention (RetentionPolicy.RUNTIME)
+public @interface Thrown {}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list