Aop in child-parent context relationship
I have a problems with my AOP configuration.
I am having quite a big project on WAS 6.1.0.13, Spring 2.5.4.
My projects is a EAR that consists of 2 WARS (web module and webservices module) and EJB module.
I have a hierarchy of context :
each of wars have its own context (specified in web.xml ) with module specific beans and there is a shared context with some back-end beans. Sharing of context is achieved by using locatorFactorySelector , and parentContextKey in both of web.xml files.
Everything works great but i have a problem with configuring AOP in webservices module context.
I am using namespace aop syntax approach to configure aspects.
In my shared context i have
Code:
<tx:annotation-driven transaction-manager="transactionManager" order="200"/>
<context:annotation-config />
<bean id="timeMeasureinterceptor" class="pl.spring.interceptor.TimeMeasureInterceptor">
<property name="tier" value="tier"/>
</bean>
<bean id="modulesInterceptor" class="pl.spring.interceptor.ModulesInterceptor"/>
<aop:config proxy-target-class="false">
<aop:advisor advice-ref="timeMeasureinterceptor" order="1" pointcut="bean(*Validator) or bean(*Manager) or bean(*DAO)" />
<aop:advisor advice-ref="modulesInterceptor" order="10" pointcut="bean(authorizationModule) or bean(administrationModule) or bean(informationModule)" />
</aop:config>
Both TimeMeasureInterceptor and ModulesInterceptor implements org.aopalliance.intercept.MethodInterceptor interface.
Everything works as expected.
Next I added in my webservices module context the following line:
Code:
<bean id="requestContextBindingAspect" class="pl.ws.aspects.RequestContextBindingAspect"/>
<aop:config proxy-target-class="false">
<aop:advisor advice-ref="requestContextBindingAspect" order="1" pointcut="execution(* org.springframework.ws.server.endpoint.MessageEndpoint.*(..))" />
</aop:config>
RequestContextBindingAspect is implementation of MethodInterceptor interface.
I want to intercept all calls on MessageEndpoint implementations (just one method invoke() ) but what i see in my logs looks very weird.
ModulesInterceptor defined above, that should only intercept method calls of beans with names: administrationModule , authorizationModule, informationModule, is fired on execution of any method of each bean defined in my webservices context => all internal spring webservices beans ( impliciltly created by Spring WebServices) and my own defined beans are wrapped by ModulesInterceptor.
My own beans are also wrapped by requestContextBindingAspect (which is what i expect).
I decided to make 2 tests:
1) Remove modulesInterceptor along with its advisor => everything works as expected (only requestContextBindingAspect in proper pointcuts is fired)
There is 1 funny thing in this test : timeMeasureinterceptor which is defined in similar fashion like modulesInterceptor does not intercept beans in webservices context.
2) Remove requestContextBindingAspect => now beans defined in webservices modules are not intercepted by anything (modulesInterceptor does not intercept any calls except for these on beans with names authorizationModule or administrationModule or informationModule)
Can anyone explain me what is going on??
Why child context beans are somehow autoproxied by one of the interceptors (and just one - modulesInterceptor ) defined in parent context?