I'm trying to have a Spring based plug-in/bundle serve up beans to other bundles. In one bundle I add all the spring stuff and spring works fine in that one bundle (its called org.omegaframework.system). Now I'm trying to initialize Spring with an applicationContext.xml from another bundle (called org.omegaframework.example). I know the 2 bundles have different classloaders so I have to do something in the Spring bundle to let it know about the classpath from the other bundle.
I tried 2 methods:
1. Using Equinox's BuddyLoader by putting...
Eclipse-RegisterBuddy: org.omegaframework.system in the example bundle. And Eclipse-BuddyPolicy: registered in the system bundle.
This didn't work, plus I'm looking for a platform independent way to do it anyway, if possible.
2. Passing the classloader...This method is in the system bundle and is called from the example bundle. I tried passing ExampleActivator.class.getClassloader() and this.getClassLoader()
public void init(String applicationContextXMLFile, ClassLoader classLoader) {
Thread current = Thread.currentThread();
ClassLoader original = current.getContextClassLoader();
current.setContextClassLoader(classLoader);
try {
context = new ClassPathXmlApplicationContext(
new String[] { applicationContextXMLFile }, this.getClass());
} catch (Exception e) {
e.printStackTrace();
} finally {
current.setContextClassLoader(original);
}
}
I can't get either to work. I've only tested on Equinox 3.3
Is there a "standard" way to allow a bundle access to another bundles classpath?
Thanks
_______________________________________________ general mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/general
