Example usage for org.springframework.aop.support RootClassFilter RootClassFilter

List of usage examples for org.springframework.aop.support RootClassFilter RootClassFilter

Introduction

In this page you can find the example usage for org.springframework.aop.support RootClassFilter RootClassFilter.

Prototype

public RootClassFilter(Class<?> clazz) 

Source Link

Usage

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/*w ww .ja v a  2 s  .co  m*/
    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;
}