-
Nov 2nd, 2012, 04:37 AM
#1
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
-
Dec 16th, 2012, 06:32 AM
#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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules