Java – iPOJO – @ reference does not inject services
There is an interface iservice in a package, which is implemented by serviceimpl class:
public interface IService
{
void doSomething();
}
@Component
@Provides
@Instantiate
public class ServiceImpl implements IService
{
public void doSomething()
{
}
}
In the second package, I use the services provided in the first package. There is another class serviceconsumer (a gogo shell command; excluding specific comments):
@Component
@Provides
@Instantiate
public class ServiceConsumer
{
@Requires
private IService service;
public doIt()
{
service.doSomething();
}
}
When I import and start two bundles in Felix, I can see that all my services are instantiated correctly using iPOJO: instance, and serviceimpl provides iservice However, when doit () is executed, the service is null
Since iservice seems to be available, I want @ requires to inject a good instance, but I don't seem to do so
I think I have something very obvious, but I don't know what it is
Solution
You also created metadata XML?
AFAIK you can also use the Maven plug-in to generate it, as shown here http://felix.apache.org/site/ipojo-hello-word-maven-based-tutorial.html
