I am working on a OSGi application(with felix scr annotations) which exposes a service. The Service registers with external api's by passing String values.
listener.addSchemaChangeListener(new ChangeListener()
{
@Override
public void schemaChange(ChangeEvent changeEvent)
{
String schemaName = changeEvent.getSchemaName();
if (null != myBuilder && schemaList.contains(schemaName))
{
initVariables();
}
}
}, "SCHEMA1");
Service uses the above piece of code to register the listeners for mulitple values "SCHEMA1", "SCHEMA1", "SCHEMA3" ... I am planning to reuse this service in various bundles. But i want to listen only for SCHEMA1 changes instead of all.
@Reference (name = "ServiceListener"", policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MANDATORY_UNARY, bind = "bind", unbind = "unbind", referenceInterface = ServiceListener.class) private AtomicReference myServiceListener = new AtomicReference<>();
If i try to use it in another service with @Reference then there is no provision to pass values to service to listen only for particular schema changes so that the service can be resued across my bundle by only passing the list of schema to listen instead of all. Because activate method will be called once the service is binded properly in the usage class(component). Is there any provision in OSGi to acheive this functionality ?