Example usage for org.springframework.aop.config AdviceEntry AdviceEntry

List of usage examples for org.springframework.aop.config AdviceEntry AdviceEntry

Introduction

In this page you can find the example usage for org.springframework.aop.config AdviceEntry AdviceEntry.

Prototype

public AdviceEntry(String kind) 

Source Link

Document

Creates a new instance of the AdviceEntry class.

Usage

From source file:eap.config.ConfigBeanDefinitionParser.java

/**
 * Parses one of '{@code before}', '{@code after}', '{@code after-returning}',
 * '{@code after-throwing}' or '{@code around}' and registers the resulting
 * BeanDefinition with the supplied BeanDefinitionRegistry.
 * @return the generated advice RootBeanDefinition
 *///  w  ww . j  a  v a2s . com
private AbstractBeanDefinition parseAdvice(String aspectName, int order, Element aspectElement,
        Element adviceElement, ParserContext parserContext, List<BeanDefinition> beanDefinitions,
        List<BeanReference> beanReferences) {

    try {
        this.parseState.push(new AdviceEntry(parserContext.getDelegate().getLocalName(adviceElement)));

        // create the method factory bean
        RootBeanDefinition methodDefinition = new RootBeanDefinition(MethodLocatingFactoryBean.class);
        methodDefinition.getPropertyValues().add("targetBeanName", aspectName);
        methodDefinition.getPropertyValues().add("methodName", adviceElement.getAttribute("method"));
        methodDefinition.setSynthetic(true);

        // create instance factory definition
        RootBeanDefinition aspectFactoryDef = new RootBeanDefinition(
                SimpleBeanFactoryAwareAspectInstanceFactory.class);
        aspectFactoryDef.getPropertyValues().add("aspectBeanName", aspectName);
        aspectFactoryDef.setSynthetic(true);

        // register the pointcut
        AbstractBeanDefinition adviceDef = createAdviceDefinition(adviceElement, parserContext, aspectName,
                order, methodDefinition, aspectFactoryDef, beanDefinitions, beanReferences);

        // configure the advisor
        RootBeanDefinition advisorDefinition = new RootBeanDefinition(AspectJPointcutAdvisor.class);
        advisorDefinition.setSource(parserContext.extractSource(adviceElement));
        advisorDefinition.getConstructorArgumentValues().addGenericArgumentValue(adviceDef);
        if (aspectElement.hasAttribute(ORDER_PROPERTY)) {
            advisorDefinition.getPropertyValues().add(ORDER_PROPERTY,
                    aspectElement.getAttribute(ORDER_PROPERTY));
        }

        // register the final advisor
        parserContext.getReaderContext().registerWithGeneratedName(advisorDefinition);

        return advisorDefinition;
    } finally {
        this.parseState.pop();
    }
}