Results 1 to 2 of 2

Thread: Advising beans in a parent context

Hybrid View

  1. #1
    Join Date
    Dec 2005
    Posts
    21

    Unhappy 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •