For services with prototype scope, multiple
service objects for the service can be obtained. Since implementations of
PrototypeServiceFactory can return the same service object
repeatedly, the framework must use count the returned service objects to
release the service object only when its use count returns to zero.
For services with singleton or
bundle scope, only one, use-counted service
object is available to a requesting bundle.
Any unreleased service objects obtained from this ServiceObjects
object are automatically released by the framework when the bundle associated
with the BundleContext used to create this ServiceObjects object is
stopped.
BundleContext#getServiceObjects(ServiceReference), PrototypeServiceFactory
| Modifier and Type | Method and Description |
|---|---|
| public S | Returns: A service object for the associated service ornull if
the service is not registered, the customized service object
returned by a ServiceFactory does not implement the
classes under which it was registered or the
ServiceFactory threw an exception.Returns a service object for the |
| public ServiceReference | getServiceReference()
Returns the |
| public void | ungetService(S
A service object previously provided by this
service)ServiceObjects object.Releases a service object for the |
| getService | back to summary |
|---|---|
| public S getService() Returns a service object for the
This
If the associated service has
This method will always return For a prototype scope service, the following steps are required to obtain a service object:
| |
| getServiceReference | back to summary |
|---|---|
| public ServiceReference Returns the
| |
| ungetService | back to summary |
|---|---|
| public void ungetService(S service) Releases a service object for the
This For a prototype scope service, the following steps are required to release a service object:
The specified service object must no longer be used and all references to it should be destroyed after calling this method when the use count has returned to zero.
| |