I am writing OSGI services .After Starting the service,I got Below Message.Kindly suggest to overcome this Issue.
@Component (service = Service.class, immediate = true)
public class ServiceImpl implements Service{
@Reference (name = "CounterService", policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MANDATORY,
bind = "bindCounter", unbind = "unbindCounter", service = CounterService.class)
public static final AtomicReference<CounterService> myCounterService = new AtomicReference<>();
public void bindCService(CounterService counterService)
{
this.cacheService= cacheService;
}
public void unbindService(CounterService cacheService)
{
this.cacheService= null;
}
}
And i got this Message after Starting Service
-!MESSAGE [com.xxx.xxx.xxx.CounterImpl(29)] Field counterService in component class com.xxx.xxx.xxx.CounterImpl has unsupported type java.util.concurrent.atomic.AtomicReference
Well, why the AtomicReference? You also don't need bind and unbind services. You seem confused :-) You might want to take a look at the videos or the OSGi starter
For the dynamic case, this is what would work:
If the
CounterServiceis not dynamic, this is a very nice pattern: