Dec 2nd, 2007, 12:09 AM
Processing additional bean.xml files at runtime
I'm migrating an existing fat client application to spring from J2EE. One thing the existing app does is access the server and get configuration data from it to find out what particular type of client 'module' this instance of the client is supposed to run.
In the spring world I am loading up the client using anClassPathXMLApplicationContext. This allows me to inject server services and access the same configuration data. However, now that I have the particular module class name to load I want to parse some additional bean.xml files which would then allow spring to take control of that particular module.
Is there a way I can easily do this? Possibly by telling the existing ApplicationContext to now go an look at some additional xml files?
Dec 2nd, 2007, 12:35 PM
You may want to look at using parent contexts. With a common parent that is already created, you create a new context that has the common parent as the parent and combine that with a child context created from those bean.xml files. One common parent can be used across multiple contexts at the same time.
I do this is in my RCP application that has a common parent for general config and other bean definitions. Then create another context per "server" that I connect to so I have a full stack of beans I need based on what is on that server. Each server could have a different set of resources ("modules") on it.