1 22 package org.jboss.aop.pointcut; 23 24 import javassist.CtConstructor; 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.Constructor ; 37 38 44 public class ExecutionConstructorMatcher extends ConstructorMatcher 45 { 46 public ExecutionConstructorMatcher(Advisor advisor, CtConstructor con, ASTStart start) throws NotFoundException 47 { 48 super(advisor, con, start); 49 } 50 51 public ExecutionConstructorMatcher(Advisor advisor, Constructor con, ASTStart start) 52 { 53 super(advisor, con, start); 54 } 55 56 public Object visit(ASTExecution node, Object data) 57 { 58 return node.jjtGetChild(0).jjtAccept(this, data); 59 } 60 61 public Object visit(ASTHas node, Object data) 62 { 63 Node n = node.jjtGetChild(0); 64 if (n instanceof ASTMethod) 65 { 66 if (ctCon != null) 67 { 68 return new Boolean (Util.has(ctCon.getDeclaringClass(), (ASTMethod) n, advisor)); 69 } 70 else 71 { 72 return new Boolean (Util.has(refCon.getDeclaringClass(), (ASTMethod) n, advisor)); 73 74 } 75 } 76 else 77 { 78 if (ctCon != null) 79 { 80 return new Boolean (Util.has(ctCon.getDeclaringClass(), (ASTConstructor) n, advisor)); 81 } 82 else 83 { 84 return new Boolean (Util.has(refCon.getDeclaringClass(), (ASTConstructor) n, advisor)); 85 86 } 87 } 88 } 89 90 public Object visit(ASTHasField node, Object data) 91 { 92 ASTField f = (ASTField) node.jjtGetChild(0); 93 if (ctCon != null) 94 { 95 return new Boolean (Util.has(ctCon.getDeclaringClass(), f, advisor)); 96 } 97 else 98 { 99 return new Boolean (Util.has(refCon.getDeclaringClass(), f, advisor)); 100 } 101 102 } 103 104 protected Boolean resolvePointcut(Pointcut p) 105 { 106 try 107 { 108 if (refCon != null) return new Boolean (p.matchesExecution(advisor, refCon)); 109 return new Boolean (p.matchesExecution(advisor, ctCon)); 110 } 111 catch (NotFoundException e) 112 { 113 throw new RuntimeException (e); } 115 } 116 } 117 | Popular Tags |