|
OSGi™ Core Release 6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
S
- Type of Service@ProviderType public interface ServiceObjects<S>
Allows multiple service objects for a service to be obtained.
For services with prototype
scope, multiple
service objects for the service can be obtained. 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
Method Summary | |
---|---|
S |
getService()
Returns a service object for the associated service. |
ServiceReference<S> |
getServiceReference()
Returns the ServiceReference for the service associated with this
ServiceObjects object. |
void |
ungetService(S service)
Releases a service object for the associated service. |
Method Detail |
---|
S getService()
associated
service.
This ServiceObjects
object can be used to obtain multiple service
objects for the associated service if the service has
prototype
scope.
If the associated service has singleton
or bundle
scope, this method behaves the
same as calling the BundleContext.getService(ServiceReference)
method for the associated service. That is, only one, use-counted service
object is available from this ServiceObjects
object.
This method will always return null
when the associated service
has been unregistered.
For a prototype scope service, the following steps are required to obtain a service object:
null
is
returned.PrototypeServiceFactory.getService(Bundle, ServiceRegistration)
method is called to supply a customized service object for the caller.PrototypeServiceFactory
object is null
, not an instanceof
all the classes named
when the service was registered or the PrototypeServiceFactory
object throws an exception, null
is returned and a Framework
event of type FrameworkEvent.ERROR
containing a
ServiceException
describing the error is fired.
null
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.
IllegalStateException
- If the BundleContext used to create this
ServiceObjects
object is no longer valid.ungetService(Object)
void ungetService(S service)
associated
service.
This ServiceObjects
object can be used to obtain multiple service
objects for the associated service if the service has
prototype
scope. If the associated
service has singleton
or
bundle
scope, this method behaves the same
as calling the BundleContext.ungetService(ServiceReference)
method for the associated service. That is, only one, use-counted service
object is available from this ServiceObjects
object.
For a prototype scope service, the following steps are required to release a service object:
PrototypeServiceFactory.ungetService(Bundle, ServiceRegistration, Object)
method is called to release the specified service object.The specified service object must no longer be used and all references to it should be destroyed after calling this method.
service
- A service object previously provided by this
ServiceObjects
object.
IllegalStateException
- If the BundleContext used to create this
ServiceObjects
object is no longer valid.
IllegalArgumentException
- If the specified service object was not
provided by this ServiceObjects
object.getService()
ServiceReference<S> getServiceReference()
ServiceReference
for the service associated with this
ServiceObjects
object.
ServiceReference
for the service associated with this
ServiceObjects
object.
|
OSGi™ Core Release 6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |