0 Replies Latest reply on Aug 26, 2009 12:39 PM by crankydillo

    Instantiating beans via Spring inside a bundle

    crankydillo

      Hi,

       

      I have a bundle in which I've placed a META-INF/spring/beans.xml.  Inside this bundle, I need to instantiate beans via Spring using that beans.xml.  I'm not sure how to get the appropriate ApplicationContext or BeanFactory.  Would you help me tackle this problem? 

       

      Most of what I've read so far suggests that I need to go through the OSGi service registry.  Do I really need to do this if I'm not trying to use bean definitions from other bundles?

       

      My last failed effort involved:

      String[] configs = {

               OsgiBundleXmlApplicationContext.DEFAULT_CONFIG_LOCATION

              };

      ApplicationContext context = new OsgiBundleXmlApplicationContext(configs);

      Configuration config = (Configuration)context.getBean("configuration");

       

      which resulted in a "BeanFactory not initialized or close, use refresh..."

       

      I apologize if this is way off base.  To date, I have been operating at the JBI level when using Fuse.  To make matters worse, I have almost no experience with Spring.

       

      Edited by: crankydillo on Aug 26, 2009 4:39 PM