1 22 package org.jboss.aop.instrument; 23 24 import javassist.CtConstructor; 25 import javassist.CtField; 26 import javassist.CtMember; 27 import javassist.CtMethod; 28 import javassist.NotFoundException; 29 30 import org.jboss.aop.Advisor; 31 import org.jboss.aop.pointcut.Pointcut; 32 33 49 public abstract class JoinpointClassifier 50 { 51 55 protected interface Matcher 56 { 57 67 boolean matches(Pointcut pointcut, Advisor advisor, CtMember member) throws NotFoundException; 68 } 69 70 73 private Matcher fieldGetMatcher = new Matcher() 74 { 75 public boolean matches(Pointcut pointcut, Advisor advisor, CtMember member) throws NotFoundException 76 { 77 return pointcut.matchesGet(advisor, (CtField) member); 78 } 79 }; 80 81 84 private Matcher fieldSetMatcher = new Matcher() 85 { 86 public boolean matches(Pointcut pointcut, Advisor advisor, CtMember member) throws NotFoundException 87 { 88 return pointcut.matchesSet(advisor, (CtField) member); 89 } 90 }; 91 92 95 private Matcher constructorMatcher = new Matcher() 96 { 97 public boolean matches(Pointcut pointcut, Advisor advisor, CtMember member) throws NotFoundException 98 { 99 return pointcut.matchesExecution(advisor, (CtConstructor) member); 100 } 101 }; 102 103 106 private Matcher methodMatcher = new Matcher() 107 { 108 public boolean matches(Pointcut pointcut, Advisor advisor, CtMember member) throws NotFoundException 109 { 110 return pointcut.matchesExecution(advisor, (CtMethod) member); 111 } 112 }; 113 114 125 protected abstract JoinpointClassification classifyJoinpoint(CtMember member, Advisor advisor, Matcher joinpointMatcher) throws NotFoundException; 126 127 134 public JoinpointClassification classifyFieldGet(CtField field, Advisor advisor) throws NotFoundException 135 { 136 return this.classifyJoinpoint(field, advisor, fieldGetMatcher); 137 } 138 139 146 public JoinpointClassification classifyFieldSet(CtField field, Advisor advisor) throws NotFoundException 147 { 148 return this.classifyJoinpoint(field, advisor, fieldSetMatcher); 149 } 150 151 158 public JoinpointClassification classifyConstructorExecution(CtConstructor cons, Advisor advisor) throws NotFoundException 159 { 160 return this.classifyJoinpoint(cons, advisor, constructorMatcher); 161 } 162 163 170 public JoinpointClassification classifyMethodExecution(CtMethod method, Advisor advisor) throws NotFoundException 171 { 172 return this.classifyJoinpoint(method, advisor, methodMatcher); 173 } 174 } | Popular Tags |