Search code examples
apache-camelosgiesbjbossfusekaraf

How to use OSGi service reference into whole other classes?


I have one bundle Activator class and some of codes there. I need to use @Autowired inside my bundle activator class. It is not working. Here is my bundle Activator class,

public class ProviderActivator implements BundleActivator {

    @Autowired
    public TestingClass testingClass;

    public void start(final BundleContext bundleContext) throws Exception {
        System.out.println("bundle starter!!!!!!!!!!!!!!" +testingClass );
        }
}

testingClass SOP is null. Spring context scanning added in spring-context.xml.

here my suggestion is,

the bean injected after bundleActivator class loaded.

How to prevent that? why the bean is null when startup bundle class?


Solution

  • Why would you even expect this to work? The activator class is instantiated by the OSGi Framework, and @Autowired is not an OSGi feature.