[jboss-cvs] JBossAS SVN: r68644 - in projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut: ast and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Jan 5 17:48:50 EST 2008
Author: flavia.rainone at jboss.com
Date: 2008-01-05 17:48:50 -0500 (Sat, 05 Jan 2008)
New Revision: 68644
Modified:
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/FieldMatcher.java
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/MethodCallMatcher.java
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/MethodMatcher.java
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/ast/IdentifierExpression.java
Log:
[JBAOP-504] Added type to IdentifierExpression instead of adding an extra method isPattern (needed by the SearchKeyParser)
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/FieldMatcher.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/FieldMatcher.java 2008-01-05 22:44:35 UTC (rev 68643)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/FieldMatcher.java 2008-01-05 22:48:50 UTC (rev 68644)
@@ -22,6 +22,10 @@
package org.jboss.aop.pointcut;
import java.lang.reflect.Field;
+
+import javassist.CtField;
+import javassist.NotFoundException;
+
import org.jboss.aop.Advisor;
import org.jboss.aop.pointcut.ast.ASTAll;
import org.jboss.aop.pointcut.ast.ASTAttribute;
@@ -33,9 +37,8 @@
import org.jboss.aop.pointcut.ast.ASTMethod;
import org.jboss.aop.pointcut.ast.ASTStart;
import org.jboss.aop.pointcut.ast.ClassExpression;
+import org.jboss.aop.pointcut.ast.IdentifierExpression;
import org.jboss.aop.pointcut.ast.Node;
-import javassist.CtField;
-import javassist.NotFoundException;
/**
* Comment
@@ -113,7 +116,7 @@
throw new RuntimeException(nfe);
}
- if (node.getFieldIdentifier().isAnnotation())
+ if (node.getFieldIdentifier().getType() == IdentifierExpression.Type.ANNOTATION)
{
String sub = node.getFieldIdentifier().getOriginal().substring(1);
if (advisor.getFieldMetaData().hasTag(fieldName, sub) || advisor.getDefaultMetaData().hasTag(sub))
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/MethodCallMatcher.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/MethodCallMatcher.java 2008-01-05 22:44:35 UTC (rev 68643)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/MethodCallMatcher.java 2008-01-05 22:48:50 UTC (rev 68644)
@@ -24,6 +24,7 @@
import javassist.CtMethod;
import javassist.NotFoundException;
import javassist.expr.MethodCall;
+
import org.jboss.aop.Advisor;
import org.jboss.aop.AspectManager;
import org.jboss.aop.pointcut.ast.ASTCall;
@@ -35,6 +36,7 @@
import org.jboss.aop.pointcut.ast.ASTStart;
import org.jboss.aop.pointcut.ast.ASTWithin;
import org.jboss.aop.pointcut.ast.ASTWithincode;
+import org.jboss.aop.pointcut.ast.IdentifierExpression;
import org.jboss.aop.pointcut.ast.Node;
/**
@@ -67,7 +69,7 @@
if (astMethod.getClazz().isSimple())
{
if (!astMethod.getClazz().matches(call.getClassName())) return Boolean.FALSE;
- if (!astMethod.getMethodIdentifier().isAnnotation())
+ if (astMethod.getMethodIdentifier().getType() != IdentifierExpression.Type.ANNOTATION)
{
if (!astMethod.getMethodIdentifier().matches(call.getMethodName())) return Boolean.FALSE;
}
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/MethodMatcher.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/MethodMatcher.java 2008-01-05 22:44:35 UTC (rev 68643)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/MethodMatcher.java 2008-01-05 22:48:50 UTC (rev 68644)
@@ -24,16 +24,17 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
+import javassist.CtMethod;
+import javassist.NotFoundException;
+
import org.jboss.aop.Advisor;
import org.jboss.aop.pointcut.ast.ASTAll;
import org.jboss.aop.pointcut.ast.ASTAttribute;
import org.jboss.aop.pointcut.ast.ASTMethod;
import org.jboss.aop.pointcut.ast.ASTStart;
import org.jboss.aop.pointcut.ast.ClassExpression;
+import org.jboss.aop.pointcut.ast.IdentifierExpression;
-import javassist.CtMethod;
-import javassist.NotFoundException;
-
/**
* Comment
*
@@ -284,70 +285,63 @@
protected boolean matchesIdentifier(ASTMethod node)
{
- if (node.getMethodIdentifier().isAnnotation())
+ IdentifierExpression.Type idType = node.getMethodIdentifier().getType();
+ switch (idType)
{
- if (advisor == null) return false;
- String sub = node.getMethodIdentifier().getOriginal().substring(1);
- if (ctMethod != null)
- {
- if (!advisor.getMethodMetaData().hasGroup(ctMethod, sub))
+ case ANNOTATION:
+
+ if (advisor == null)
{
- if (!advisor.getDefaultMetaData().hasTag(sub))
+ return false;
+ }
+ String sub = node.getMethodIdentifier().getOriginal().substring(1);
+ if (ctMethod != null &&
+ !advisor.getMethodMetaData().hasGroup(ctMethod, sub) &&
+ !advisor.getDefaultMetaData().hasTag(sub) &&
+ !advisor.hasAnnotation(ctMethod, sub))
+ {
+ return false;
+ }
+ else
+ {
+ if (!advisor.getMethodMetaData().hasTag(refMethod, sub) &&
+ !advisor.getDefaultMetaData().hasTag(sub))
{
- if (!advisor.hasAnnotation(ctMethod, sub)) return false;
+ if (!advisor.hasAnnotation(refMethod, sub)) return false;
}
}
- }
- else
- {
- if (!advisor.getMethodMetaData().hasTag(refMethod, sub))
+ return true;
+
+ case IMPLEMENTS:
+ case IMPLEMENTING:
+ // Implementing will check all super classes
+ boolean exactSuper = (idType == (IdentifierExpression.Type.IMPLEMENTS));
+ try
{
- if (!advisor.getDefaultMetaData().hasTag(sub))
+ ClassExpression implemented = node.getMethodIdentifier().getImplementsExpression();
+ if (ctMethod != null)
{
- try
+ if (Util.methodExistsInSuperClassOrInterface(ctMethod, implemented, exactSuper))
{
- if (!advisor.hasAnnotation(refMethod, sub)) return false;
+ return true;
}
- catch (Exception e)
- {
- throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
- }
}
- }
- }
- }
- else if (node.getMethodIdentifier().isImplements() || node.getMethodIdentifier().isImplementing())
- {
- try
- {
- boolean exactSuper = node.getMethodIdentifier().isImplements(); //Implementing will check all super classes
- ClassExpression implemented = node.getMethodIdentifier().getImplementsExpression();
- if (ctMethod != null)
- {
- if (Util.methodExistsInSuperClassOrInterface(ctMethod, implemented, exactSuper))
+ else if (Util.methodExistsInSuperClassOrInterface(refMethod, implemented, exactSuper, advisor))
{
return true;
}
}
- else
+ catch (Exception e)
{
- if (Util.methodExistsInSuperClassOrInterface(refMethod, implemented, exactSuper, advisor))
- {
- return true;
- }
+ throw new RuntimeException(e);
}
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- return false;
+ return false;
+ case PATTERN:
+ return node.getMethodIdentifier().matches(methodName);
+ default:
+ throw new RuntimeException ("Unexpected type: " +
+ node.getMethodIdentifier().getType());
}
- else
- {
- if (!node.getMethodIdentifier().matches(methodName)) return false;
- }
- return true;
}
protected boolean matchesExceptions(ASTMethod node)
Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/ast/IdentifierExpression.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/ast/IdentifierExpression.java 2008-01-05 22:44:35 UTC (rev 68643)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/pointcut/ast/IdentifierExpression.java 2008-01-05 22:48:50 UTC (rev 68644)
@@ -33,35 +33,33 @@
**/
public class IdentifierExpression
{
+ public enum Type {PATTERN, ANNOTATION, IMPLEMENTS, IMPLEMENTING}
private String original;
private Pattern namePattern;
- private boolean isAnnotation;
-
- private boolean isImplements;
- private boolean isImplementing;
private ClassExpression implementsExpr;
-
+ private Type type;
public IdentifierExpression(String expr)
{
original = expr;
if (expr.startsWith("@"))
{
- isAnnotation = true;
+ type = Type.ANNOTATION;
}
else if (expr.startsWith("$implements{"))
{
- isImplements = true;
+ type = Type.IMPLEMENTS;
expr = expr.substring(12, expr.length() - 1);
implementsExpr = new ClassExpression(expr.trim());
}
else if (expr.startsWith("$implementing{"))
{
- isImplementing = true;
+ type = Type.IMPLEMENTING;
expr = expr.substring(14, expr.length() - 1);
implementsExpr = new ClassExpression(expr.trim());
}
else
{
+ type = Type.PATTERN;
expr = expr.replaceAll("\\*", ".*");
namePattern = Pattern.compile(expr);
}
@@ -69,14 +67,16 @@
public boolean matches(String name)
{
- if (isAnnotation) return false;
+ // TODO
+ //if (isAnnotation) return false;
Matcher m = namePattern.matcher(name);
return m.matches();
}
public boolean matchesAnnotation(String annotation)
{
- if (!isAnnotation) return false;
+ // TODO
+ //if (!isAnnotation) return false;
Matcher m = namePattern.matcher(annotation);
return m.matches();
}
@@ -86,21 +86,11 @@
return original;
}
- public boolean isAnnotation()
+ public Type getType()
{
- return this.isAnnotation;
+ return this.type;
}
-
- public boolean isImplements()
- {
- return this.isImplements;
- }
- public boolean isImplementing()
- {
- return this.isImplementing;
- }
-
public ClassExpression getImplementsExpression()
{
return implementsExpr;
More information about the jboss-cvs-commits
mailing list