May 10th, 2011, 06:23 AM
Using <import> with a spring bean xml file from an imported bundle
My question is simple. I have bundleA that defines contextA.xml. I want that another bundle can load that xml like it is in it's classpath.
Or, to put another way, <import resource="classpath*:contextA.xml"/> does not mean anything in an osgi environment and the xml is not loaded into the context, while it works in a JEE environment of course. I'm running on Karaf 2.2.0 that has spring-osgi 1.2.1 installed by default.
I'm wondering if there's a way to achieve this that is NOT defining some beans from A as osgi services. This is becaus I do not want to load the contextA.xml beans while A is loaded, that will result in a unique instance of those bean. I just want that any bundle that imports from A could load the contextA.xml beans.
The main purpose is not duplicate those contextA.xml in all the different bundles it is needed.
I also do NOT want to write some custom code in an Activator, cause, for example, I need that a web.xml that loads spring-web would work out of the box like it's doing now, just defining OsgiBundleXmlWebApplicationContext as the contextClass.
Thanks for any tip.
Tags for this Thread