1 22 package org.jboss.aop.pointcut; 23 24 import javassist.CtMethod; 25 import javassist.NotFoundException; 26 import org.jboss.aop.Advisor; 27 import org.jboss.aop.pointcut.ast.ASTConstructor; 28 import org.jboss.aop.pointcut.ast.ASTExecution; 29 import org.jboss.aop.pointcut.ast.ASTField; 30 import org.jboss.aop.pointcut.ast.ASTHas; 31 import org.jboss.aop.pointcut.ast.ASTHasField; 32 import org.jboss.aop.pointcut.ast.ASTMethod; 33 import org.jboss.aop.pointcut.ast.ASTStart; 34 import org.jboss.aop.pointcut.ast.Node; 35 36 import java.lang.reflect.Method ; 37 38 44 public class ExecutionMethodMatcher extends MethodMatcher 45 { 46 public ExecutionMethodMatcher(Advisor advisor, CtMethod method, ASTStart start) throws NotFoundException 47 { 48 super(advisor, method, start); 49 } 50 51 public ExecutionMethodMatcher(Advisor advisor, Method method, ASTStart start) 52 { 53 super(advisor, method, start); 54 } 55 56 public Object visit(ASTExecution node, Object data) 57 { 58 return node.jjtGetChild(0).jjtAccept(this, data); 59 } 60 61 protected Boolean resolvePointcut(Pointcut p) 62 { 63 try 64 { 65 if (refMethod != null) 66 { 67 PointcutMethodMatch pmatch = p.matchesExecution(advisor, refMethod); 68 if (pmatch != null && pmatch.isMatch()) 69 { 70 this.matchedClass = pmatch.getMatchedClass(); 71 this.matchLevel = pmatch.getMatchLevel(); 72 this.isInstanceof = pmatch.isInstanceOf(); 73 return Boolean.TRUE; 74 } 75 return Boolean.FALSE; 76 } 77 return new Boolean (p.matchesExecution(advisor, ctMethod)); 78 } 79 catch (NotFoundException e) 80 { 81 throw new RuntimeException (e); } 83 } 84 85 public Object visit(ASTHas node, Object data) 86 { 87 Node n = node.jjtGetChild(0); 88 if (n instanceof ASTMethod) 89 { 90 if (ctMethod != null) 91 { 92 return new Boolean (Util.has(ctMethod.getDeclaringClass(), (ASTMethod) n, advisor)); 93 } 94 else 95 { 96 return new Boolean (Util.has(refMethod.getDeclaringClass(), (ASTMethod) n, advisor)); 97 98 } 99 } 100 else 101 { 102 if (ctMethod != null) 103 { 104 return new Boolean (Util.has(ctMethod.getDeclaringClass(), (ASTConstructor) n, advisor)); 105 } 106 else 107 { 108 return new Boolean (Util.has(refMethod.getDeclaringClass(), (ASTConstructor) n, advisor)); 109 110 } 111 } 112 } 113 114 public Object visit(ASTHasField node, Object data) 115 { 116 ASTField f = (ASTField) node.jjtGetChild(0); 117 if (ctMethod != null) 118 { 119 return new Boolean (Util.has(ctMethod.getDeclaringClass(), f, advisor)); 120 } 121 else 122 { 123 return new Boolean (Util.has(refMethod.getDeclaringClass(), f, advisor)); 124 } 125 126 } 127 128 129 } 130 | Popular Tags |