Announcement Announcement Module
Collapse
No announcement yet.
Import same applicationContext several times Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Import same applicationContext several times

    I have split my applicationContext into several small contexts, some are JavaConfig and some are xml. I have dao-context.xml, ldap-context.xml, etc. I have had a huge services-context.xml, but would like to split it up into smaller units, like servicex-context.xml and servicey-context.xml.

    The purpose of this is to make it easier to test a service without wiring up the entire context.

    I would like servicex-context to import dao-context and ldap-context, so that when I specify in my test that I'd like to use servicex-context I will automatically get the other contexts that servicex requires.

    In my top level applicationContext, main-application-context.xml, I will import servicex-context and servicey-context. As a result, dao-context.xml and ldap-context.xml will be imported several times. Is this a problem?

    I can remove the imports from servicex-context and servicey-context, and add them to main-application-context, but then I'll have to add several contexts in a test, so all the required classes are available. I'd like to avoid that.


    Regards, Haagen

  • #2
    I've not seen this kind of inclusion being problematic. Even if the same declarations are repeated multiple times, all the bean definitions are consolidated so that actually only a single instance for each bean declaration is created. This is automatically taken care of

    Comment

    Working...
    X