org.springframework.aop.framework

Class AbstractAdvisingBeanPostProcessor

    • Field Detail

      • beforeExistingAdvisors

        protected boolean beforeExistingAdvisors
    • Constructor Detail

      • AbstractAdvisingBeanPostProcessor

        public AbstractAdvisingBeanPostProcessor()
    • Method Detail

      • setBeforeExistingAdvisors

        public void setBeforeExistingAdvisors(boolean beforeExistingAdvisors)
        Set whether this post-processor's advisor is supposed to apply before existing advisors when encountering a pre-advised object.

        Default is "false", applying the advisor after existing advisors, i.e. as close as possible to the target method. Switch this to "true" in order for this post-processor's advisor to wrap existing advisors as well.

        Note: Check the concrete post-processor's javadoc whether it possibly changes this flag by default, depending on the nature of its advisor.

      • postProcessBeforeInitialization

        public java.lang.Object postProcessBeforeInitialization(java.lang.Object bean,
                                                                java.lang.String beanName)
        Description copied from interface: BeanPostProcessor
        Apply this BeanPostProcessor to the given new bean instance before any bean initialization callbacks (like InitializingBean's afterPropertiesSet or a custom init-method). The bean will already be populated with property values. The returned bean instance may be a wrapper around the original.

        The default implementation returns the given bean as-is.

        Specified by:
        postProcessBeforeInitialization in interface BeanPostProcessor
        Parameters:
        bean - the new bean instance
        beanName - the name of the bean
        Returns:
        the bean instance to use, either the original or a wrapped one; if null, no subsequent BeanPostProcessors will be invoked
        See Also:
        InitializingBean.afterPropertiesSet()
      • postProcessAfterInitialization

        public java.lang.Object postProcessAfterInitialization(java.lang.Object bean,
                                                               java.lang.String beanName)
        Description copied from interface: BeanPostProcessor
        Apply this BeanPostProcessor to the given new bean instance after any bean initialization callbacks (like InitializingBean's afterPropertiesSet or a custom init-method). The bean will already be populated with property values. The returned bean instance may be a wrapper around the original.

        In case of a FactoryBean, this callback will be invoked for both the FactoryBean instance and the objects created by the FactoryBean (as of Spring 2.0). The post-processor can decide whether to apply to either the FactoryBean or created objects or both through corresponding bean instanceof FactoryBean checks.

        This callback will also be invoked after a short-circuiting triggered by a InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation(java.lang.Class<?>, java.lang.String) method, in contrast to all other BeanPostProcessor callbacks.

        The default implementation returns the given bean as-is.

        Specified by:
        postProcessAfterInitialization in interface BeanPostProcessor
        Parameters:
        bean - the new bean instance
        beanName - the name of the bean
        Returns:
        the bean instance to use, either the original or a wrapped one; if null, no subsequent BeanPostProcessors will be invoked
        See Also:
        InitializingBean.afterPropertiesSet(), FactoryBean
      • isEligible

        protected boolean isEligible(java.lang.Object bean,
                                     java.lang.String beanName)
        Check whether the given bean is eligible for advising with this post-processor's Advisor.

        Delegates to isEligible(Class) for target class checking. Can be overridden e.g. to specifically exclude certain beans by name.

        Note: Only called for regular bean instances but not for existing proxy instances which implement Advised and allow for adding the local Advisor to the existing proxy's Advisor chain. For the latter, isEligible(Class) is being called directly, with the actual target class behind the existing proxy (as determined by AopUtils.getTargetClass(Object)).

        Parameters:
        bean - the bean instance
        beanName - the name of the bean
        See Also:
        isEligible(Class)
      • isEligible

        protected boolean isEligible(java.lang.Class<?> targetClass)
        Check whether the given class is eligible for advising with this post-processor's Advisor.

        Implements caching of canApply results per bean target class.

        Parameters:
        targetClass - the class to check against
        See Also:
        AopUtils.canApply(Advisor, Class)
      • customizeProxyFactory

        protected void customizeProxyFactory(ProxyFactory proxyFactory)
        Subclasses may choose to implement this: for example, to change the interfaces exposed.

        The default implementation is empty.

        Parameters:
        proxyFactory - the ProxyFactory that is already configured with target, advisor and interfaces and will be used to create the proxy immediately after this method returns
        Since:
        4.2.3
        See Also:
        prepareProxyFactory(java.lang.Object, java.lang.String)