Multiple applicationContext.xml files?

  • Nigel Magnay

    Nigel Magnay - 2010-01-28


    In our app, we have multiple 'layers' of spring application contexts - I.E: each has a parent of the layer below. This way the databases are defined at a low level, then business beans, then web.

    Now, I can create a <bt:manager> at the database level… but this only tracks jdbc calls. Or I can create managers at each level - but then I loose the tracing context of the calls.

    Is there a way to configure it to have one bt:manager, but the advice applied to the other layers too?

  • Jason Trump

    Jason Trump - 2010-01-29


    As long as your <bt:manager> definition is at the deepest level, you should be fine.  That's assuming that your lower-level ApplicationContexts are parents of your higher-level ApplicationContexts - it sounds like they are.

    You should be able to use the <bt:advice> configuration tag in your child contexts to refer to a higher-level <bt:manager> tag.  You can then refer to bt:advice in AOP conifguration, similar to spring's <tx:advice>:

        <bt:advice id="btAdvice"/>
            <aop:pointcut id="trackedOperations" 
            <aop:advisor advice-ref="btAdvice" pointcut-ref="trackedOperations"/>

    You can also use the <bt:http-requests/> element in the same way.  It looks like we're missing some documentation on that… I'll log an issue.  E.g.

      parent context:  

    <bt:manager id="myManager">...</bt:manager>

      child  context:    

    <bt:http-requests tracking-manager="myManager" ... />

    This sort of configuration has not been extensively tested, but it should work.  What version of Spring are you using?



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks