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