Search code examples
javaosgiapache-karafosgi-bundleblueprint-osgi

Find a way to call Blueprint Container for prototype bean


I'm moving from a Spring context to a blueprint bean manager on OSGi Karaf, and I cannot find way to call blueprint "context". For example, in Java Spring, I call ApplicationContext with method context.getBean(MyBean.class) and get a prototype instance of MyBean.

Now I have a blueprint.xml with my prototype bean configuration, and can't work with that in Java code. Is there something like that in blueprint?


Solution

  • You can create a class that accepts the blueprint container as an argument:

        <bean class="com.acme.FooImpl">
          <property name="container" ref="blueprintContainer"/>
        </bean>