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

  • Advising beans in a parent context


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

      <aop:aspect id="myAspect" ref="adviceBean">
        <aop:before method="before" pointcut="execution(* com.package.AdvisedClass.advisedMethod(..))"/>
    <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.