java - Multiple PIDs for one target service with ds annotations -
i'm wondering if possible leverage explaned @ par.104.7.5 (using multi-locations) of osgi enterprise specs using declarative services annotations. quoting specs:
it possible bundles interested in multiple pids 1 target service, reason can register multiple pids 1 service. [...]
a bundle interested in host configuration register managed service following properties:
service.pid = [ "com.acme.host", "com.acme.system" ]
the bundle called both
com.acme.host
,com.acme.system
pid , must therefore discriminate between these 2 cases. managed service therefore have callback like:
volatile url url; public void updated( dictionary d ) { if ( d.get("service.pid").equals("com.acme.host")) this.url = new url( d.get("host")); if ( d.get("service.pid").equals("com.acme.system")) ... }
i tried following syntax:
@component( immediate = true, configurationpid = "[com.mycompany.ws.rest,com.mycompany.endpoints]", configurationpolicy = configurationpolicy.require ) public class testimpl implements test { // ... }
but fails. of course 1 can reference config admin , browse configuration based on desired pids seems little bit inelegant me since in theory possible delegate ds annotations.
is possible? correct syntax?
thank you!
i don't believe possible using configurationpid
, configurationpolicy
values. following:
- define service factory pid(s) service property.
- implement
managedservice
interface.
example:
@component(property = {constants.service_pid + "=com.acme.host", constants.service_pid + "=com.acme.system"}) public class testcomponent implements managedservice { @override public void updated(dictionary<string, ?> dict) { ... }
of course has disadvantage component activated if there no configuration it, can use 2 pids.
Comments
Post a Comment