equinox - OSGI Service components With same interface -
i need create service components same interface. mean have different implementations same interface. tried create 2 components same interface either 1 active.
i using equinox declarative. have better design solve problem? please find configuration below.
component1.xml
<?xml version="1.0" encoding="utf-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="comp1"> <implementation class="com.demo.impl.componeimpl"/> <service> <provide interface="com.demo.icomponent"/> </service> </scr:component>
component2.xml
<?xml version="1.0" encoding="utf-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="comp2"> <implementation class="com.demo.impl.comptwoimpl"/> <service> <provide interface="com.demo.icomponent"/> </service> </scr:component>
accessing component consumer
consume component
comp1.xml
<?xml version="1.0" encoding="utf-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="consumecomp1"> <implementation class="com.demo.service.consumecompone"/> <reference bind="setcomp" cardinality="1..1" interface="com.demo.icomponent" name="comp1" policy="static" unbind="unsetcomp"/> </scr:component>
comp2.xml
<?xml version="1.0" encoding="utf-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="consumecomp2"> <implementation class="com.demo.service.consumecomptwo"/> <reference bind="setcomp" cardinality="1..1" interface="com.demo.icomponent" name="comp2" policy="static" unbind="unsetcomp"/> </scr:component>
when try access comp1 , comp2 respectively through consumecompone , consumecomptwo class getting same component both, either comp1 or comp2. please me solve this.
thankyou in advance
gopy
ds working correctly, there nothing solve here.
as said, both consumer components provided instance of icomponent
service, requesting references.
Comments
Post a Comment