I am trying to run one bundle in OSGi and in one class I am using @Inject annotation. Build is succesfull but the variable indexerConfiguration is still null. Why?
@Named
@Singleton
public class IndexerConfiguration
{
private Indexer indexer;
private Scanner scanner;
private Map<String, IndexCreator> indexers;
@Inject
public IndexerConfiguration( Indexer indexer,
Scanner scanner,
Map<String, IndexCreator> indexers ){
this.indexer = indexer;
this.scanner = scanner;
this.indexers = indexers;
}
public Indexer getIndexer(){
return indexer;
}
The second class is in the same package:
public class MyFactory implements ManagedServiceFactory {
public static final String PID = "myPid";
private volatile DependencyManager m_dependencyManager;
private final Map<String, Component> m_components = new HashMap<String, Component>();
@Inject
private IndexerConfiguration indexerConfiguration;
@Override
public String getName() {
return "myBundle";
}
@Override
public void updated(String pid,
@SuppressWarnings("rawtypes") Dictionary properties)
throws ConfigurationException {
if (m_components.containsKey(pid)) {
return;
}
Component component = m_dependencyManager
.createComponent()
.setImplementation(myOwnClass.class)
.add(m_dependencyManager.createConfigurationDependency()
.setPid(pid));
indexerConfiguration.getIndexer(); //this is still null :( why?
m_components.put(pid, component);
m_dependencyManager.add(component);
}
all imports are ok, build is succesfull, but why the injection doesnt work?Thanks