1 16 17 package org.springframework.aop.support.annotation; 18 19 import java.lang.annotation.Annotation ; 20 import java.lang.reflect.Method ; 21 22 import org.springframework.aop.support.AopUtils; 23 import org.springframework.aop.support.StaticMethodMatcher; 24 import org.springframework.util.Assert; 25 26 35 public class AnnotationMethodMatcher extends StaticMethodMatcher { 36 37 private final Class <? extends Annotation > annotationType; 38 39 40 44 public AnnotationMethodMatcher(Class <? extends Annotation > annotationType) { 45 Assert.notNull(annotationType, "Annotation type must not be null"); 46 this.annotationType = annotationType; 47 } 48 49 50 public boolean matches(Method method, Class targetClass) { 51 if (method.isAnnotationPresent(this.annotationType)) { 52 return true; 53 } 54 Method specificMethod = AopUtils.getMostSpecificMethod(method, targetClass); 56 return (specificMethod != method && specificMethod.isAnnotationPresent(this.annotationType)); 57 } 58 59 } 60 | Popular Tags |