I have an OSGi package that uses the bundle-context.xml file to initialize a bean.
<bean id="myBean" class="test.MyClass">
<property name="output" value="test"/>
</bean>
I have a factory class that should receive a bean instance. In a world other than OSGI, to initialize the context, I always need only the following: get ...
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("bundle-context.xml");
MyClass bean = (MyClass) applicationContext.getBean("myBean");
But on OSGI (FuseESB 4.2, Servicemix4), the container automatically loads the bundle-context.xml file and initializes the spring context. If I load the context explicitly (using the code above), 2 contexts are created (which is bad). So what is the correct way to get the handle in the same / bean context?
source
share