Hello all
I'm trying Felix Dependency Manager and have come across the following case.
For each registered service of type A, I want to create a component,
only when the corresponding service B is also present. The corresponding
service is determined by a property of A.
Example:
I have a services of type "Device" which each have a unique property
"device.id".
objectClass=com.example.Device
device.id=device_0001
I have another service DeviceParameter, which uses the same id to
indicate, it is corresponding to the above device
objectClass=com.example.DeviceParameter
device.id=device_0001
Now I want to start a consuming component, which uses both. That is for
each Device service which appears, create the consumer as soon as the
corresponding DeviceParameter also appears.
// component, not registered as a service
class Consumer {
// injected by DM. Both are required for Consumer to be built
private volatile Device d;
private volatile DeviceParameter p;
...
}
How can this be done in DM?
For the record, my attempt so far:
mgr.add(createComponent()
.setImplementation(Consumer.class)
.add(createServiceDependency()
.setRequired(true)
.setService(Device.class.getName()))
.add(createServiceDependency()
.setRequired(true)
.setService(DeviceParameter.class.getName(),
"(device.id=" + ... +")")));
How to fill the filter "..."?
Thanks Philipp
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]