List of usage examples for org.springframework.aop.support.annotation AnnotationMethodMatcher AnnotationMethodMatcher
public AnnotationMethodMatcher(Class<? extends Annotation> annotationType)
From source file:org.anyframe.iam.admin.common.web.JsonErrorAdvisingBeanPostProcessor.java
@SuppressWarnings("unchecked") public Object postProcessBeforeInitialization(final Object bean, String beanName) throws BeansException { // ? bean ? log.debug("postProcessBeforeInitialization with : " + beanName); Class clazz = bean.getClass(); // JsonError Annotation ? MethodMatcher AnnotationMethodMatcher annotationMethodMatcher = new AnnotationMethodMatcher(JsonError.class); // advice(JsonIAMException JsonExceptionTransfer) + Pointcut // ? Advisor/*from www.j a v a2 s . c om*/ DefaultPointcutAdvisor advisor = (DefaultPointcutAdvisor) context.getBean("jsonErrorAdvisor"); // bean Class ? JsonError Annotation ? // ? for (Method method : clazz.getDeclaredMethods()) { // JsonError Annotation ? if (annotationMethodMatcher.matches(method, clazz)) { // maching method log.debug("maching method : " + clazz.getSimpleName() + "." + method.getName()); // jsonErrorAdvisor Pointcut ? - JsonError // Annotation ? Bean ? Pointcut if (advisor.getPointcut() == Pointcut.TRUE) { advisor.setPointcut( new ComposablePointcut(new RootClassFilter(clazz), annotationMethodMatcher)); // ? Pointcut ? ?? JsonError Annotation ? // Bean ? Pointcut ? union ?. } else { ComposablePointcut pointcut = (ComposablePointcut) advisor.getPointcut(); pointcut.union(new ComposablePointcut(new RootClassFilter(clazz), annotationMethodMatcher)); advisor.setPointcut(pointcut); } } } return bean; }