Announcement Announcement Module
Collapse
No announcement yet.
aop:aspect id, import resource and double advising Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • aop:aspect id, import resource and double advising

    Hi,
    Deployment environment: Spring 2.0.3 or 2.0.7 and Weblogic 10.0.
    I have a Spring xml config file called common-app-context.xml that defines an aspect as follows:
    Code:
    	<aop:config>
    		<aop:pointcut id="dataAccessOperation" 
    expression="execution(* com.test.dao.*.*(..))"/>
    		<aop:aspect id="timingAspect" ref="timingAdvice">
    		  <aop:around pointcut-ref="dataAccessOperation" 
                          method="captureTiming"/>
    		</aop:aspect>	
    	</aop:config>
    I also have other two other xml configuration files app-context1.xml and app-context2.xml where I import in both the above common-app-context.xml using <import resource="common-app-context.xml"/> . As well, app-context1.xml imports app-context2.xml resource. During container start-up, app-context1.xml is used by a ClasspathXmlApplicationContext to initialize the appContext.
    Here's the scheme:
    Code:
    app-context2.xml---->common-app-context.xml
        ^                       ^
        |                       |
    app-context1.xml-------------
    Obviously this isn't exactly correct since app-context1.xml doesn't have to import the resource common-app-context.xml but this is how I found that this way the timingAspect is applied twice at runtime which means that the timingAspect was created twice.
    My understanding was that at runtime Spring merges all <spring:config> definitions and since I have ID'd my aspect I expected that only one timingAspect is created at runtime.

    Is this by design? Please advise.
    thanks!
    florin
Working...
X