No problem! Actually, that is the whole idea. Read the documentation for
BundleContext.getServiceReference() to see what happens when there are
multiple services registered under the same name.

This is a very common use case. The OSGi has the whiteboard pattern
that assumes many bundles use the same service interface to register a
service under. The Service Tracker was made to track those services.

http://www.osgi.org/documents/osgi_technology/whiteboard.pdf

There are many use cases where it is very applicable to register
multiple providers for the same service.

Kind regards,

     Peter Kriens

jald> Hi everybody!

jald>    Greetings!

jald>   I have a doubt with service registration in OSGi R4. Can two
jald> diff bundles register two similar services, meaning with the
jald> same classname and properties, but with a different service impl object.

jald>  For e.g., 
jald> Class MyClass implements BundleActivator
jald> {
jald>   pulic void start()
jald>   {
jald>      // construct a map with a property holding this classname.
jald>      sReg = bundlecontext.registerService(this.getClass  ().getName(), 
this, map);
jald>   }

jald>   public void stop()
jald>   {
jald>     sReg.unregister();
jald>   }
jald> }

jald>    Now, can I have the same class as part of two of my bundles,
jald> install and start them sucessfully. Will two services be
jald> registered in the framework under the same classname? 
jald> Please note that the package in which this class resides is the same in 
both the bundles.

jald> -- 
jald> Cheers
jald> Joe
jald> ----------------
jald> Visit my blog at  http://djlolly.blogspot.com 
jald> * Believing in yourself is an endless destination;
jald>   But, believing your have failed is the end of the journey.
jald> * A pound a fret cant pay an ounce a debt. 




-- 
Peter Kriens                              Tel +33467542167
9C, Avenue St. Drézéry                    AOL,Yahoo: pkriens
34160 Beaulieu, France                    ICQ 255570717
Skype pkriens                             Fax +1 8153772599

_______________________________________________
osgi-dev mailing list
osgi-dev@bundles.osgi.org
http://bundles.osgi.org/mailman/listinfo/osgi-dev

Reply via email to