Jul 16th, 2012, 08:09 AM
Core and Local beans
I have an application where I'd like to distinguish between "core" beans and what I call "local" beans.
Core beans are provided and used by the applications core, typically specified in a small bean defintion file that is
generated by the programmers of the core. The "local" beans are typically plugins, extensions, or the like and specified in a second bean definition file, which is under the control of the core users, or local administrators.
I can achieve most of that by using something like
new ClassPathXmlApplicationContext("spring-beans-core.xml", "spring-beans-local.xml");
One thing is missing, though: As soon as the core beans are loaded, (or, in other words, after "spring-beans-core.xml" is loaded, an not after both are loaded) I'd have something like a core initializationmethod. Can I
get that somehow?
Jul 18th, 2012, 03:19 PM
No ideas? Or, on't you guys get my question? I'm trying to rephrase:
I'd like to initialize an application context by reading bean definitions from a file, then do some programmatical initialization and,
finally, add more bean definitions from another file. Can I do that? ClasspathXmlApplicationcontext seems generally right, except
that it insists in reading all the files at once.
Jul 19th, 2012, 01:46 AM
Maybe answering my own question: I am now using a ClasspathXmlApplicationContext with a parent. The parent is created using the first resource file, the other context using the second. Looks good so far...
Jul 19th, 2012, 11:18 AM
Instead of programatically referring to second bean xml, use the facility that spring has provided to refer one bean definition into other. Hence you can refer second bean difinition into the ifest bean file, further spring will take care of instantiating and initializing.