Announcement Announcement Module
Collapse
No announcement yet.
Advising beans in a parent context Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Advising beans in a parent context

    Hi,

    I am trying to set up a simple before advice on a method:

    Code:
    <aop:config>
      <aop:aspect id="myAspect" ref="adviceBean">
        <aop:before method="before" pointcut="execution(* com.package.AdvisedClass.advisedMethod(..))"/>
      </aop:aspect>
    </aop:config>
    
    <bean id="adviceBean" class="..." autowire="byName"/>
    This configuration and advice works fine in the root application context, where I actually have a bean of class 'com.package.AdvisedClass'. But when I move this to a child application context (a dispatcher servlet context), it no longer creates the AOP proxy!! Why not? Is this something that's theoretically possible or do all advised classes have to be in the same context file?

  • #2
    The AOP:config will result in BeanPostProcessors and BeanPostProcessor will only process beans in the ApplicationContexts its loaded in. So a BeanPostProcessor loaded by the root applicationcontext will only process beans in the root context. Where as one loaded by the WebApplicatonContext will only process beans in that context.

    Readup on BeanPostProcessor in the reference guide. Chapter 3.7 is the part you want to read.

    Comment

    Working...
    X