The ServiceRegistration is a singleton for the registered service object.
In this case your service object is a ServiceFactory.  If you unregister
the ServiceRegistration is is unregistering the original service object
(your ServiceFactory) from the service registry.  All instances of the
service your service factory created should be released by all consumers.

If I understand your scenario correctly you want to force particular
consumers to release their service instance at some particular point in
time.  The only way to force a consumer to release your service instances
is to unregister your service, but that results in all consumers having to
release their reference to your service instances.  The consumers
themselves are able to release service instances any time they see fit.  To
do what you suggest would require multiple service registrations, one for
each group of bundles you want to be able to force the release of your
service insteances.

Tom





From:   Chetan Mehrotra <[email protected]>
To:     OSGi Developer Mail List <[email protected]>,
Date:   01/10/2014 04:13 AM
Subject:        [osgi-dev] Unregistering specific instances of ServiceFactory
Sent by:        [email protected]



In our system we have a ServiceFactory SF1 which creates instances of
service S1. The service instance is bound to bundles which have asked
for service from service factory. If I unregister the SF1 then it
leads to unregistrations of all the service instances created from SF1

Now in some case we need to unregister the service instance of S1 for
some specific bundles only.

For example

- Bundle B1 has S1A
- Bundle B2 has S1B
- Bundle B3 has S1C

Where S1X is an instance of S1 produced from SF1

Now a SF interface [1] is as below

Object getService(Bundle bundle, ServiceRegistration registration)

Provides the calling bundle reference and also the ServiceRegistration
object. Would it be fine if Bundle of SF1 invokes the
registration.unregister() method. This would allow us to unregister
services for specific bundle like S1A, S1B but leave service
registered for B3 i.e. S1C

Chetan Mehrotra

[1]
http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/ServiceFactory.html

_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

<<inline: graycol.gif>>

_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to