I have defined a service:
public interface TimeProvider {
int getCurrentTime();
}
And an implementation:
@Component
@Provides
@Instantiate
public class FooTimeProvider implements TimeProvider {
...
}
In another class (actually an Activator
class), I refer to the service like this:
@Component
@Provides
public class Activator implements BundleActivator {
@Requires
private TimeProvider timeProvider;
...
@Override
public void start(BundleContext bundleContext) throws Exception {
...
timeProvider.getCurrentTime();
}
...
}
But I get a NullPointerException
at package.Activator.__M_start(Activator.java:60)
I installed Arch Gogo and these are the results:
ipojo:instances
Instance org.apache.felix.ipojo.IPOJOURLHandler-0 -> valid
Instance org.apache.felix.ipojo.arch.gogo.Arch-0 -> valid
Instance package.FooTimeProvider-0 -> valid
ipojo:handlers
Handler org.apache.felix.ipojo:controller (VALID)
Handler org.apache.felix.ipojo:provides (VALID)
Handler org.apache.felix.ipojo:properties (VALID)
Handler org.apache.felix.ipojo:callback (VALID)
Handler org.apache.felix.ipojo:requires (VALID)
Handler org.apache.felix.ipojo:architecture (VALID)
ipojo:instance package.FooTimeProvider-0
instance name="package.FooTimeProvider-0" state="valid" bundle="16" component.type="package.FooTimeProvider"
handler name="org.apache.felix.ipojo:provides" state="valid"
provides specifications="[anotherPackage.TimeProvider]" state="registered" service.id="44"
property name="factory.name" value="package.FooTimeProvider"
property name="instance.name" value="package.FooTimeProvider-0"
handler name="org.apache.felix.ipojo:architecture" state="valid"
object name="package.FooTimeProvider@6c7e1f14"
What am I missing?
(The byte code manipulation is done by an Ant task, btw)