Class BundleContextImpl.ServiceObjectsImpl<S>
- All Implemented Interfaces:
ServiceObjects<S>
- Enclosing class:
BundleContextImpl
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a service object for theassociated
service.Returns theServiceReference
for the service associated with thisServiceObjects
object.void
ungetService
(S srvObj) Releases a service object for theassociated
service.
-
Field Details
-
m_ref
-
srvObjects
-
-
Constructor Details
-
ServiceObjectsImpl
-
-
Method Details
-
getService
Description copied from interface:ServiceObjects
Returns a service object for theassociated
service.This
ServiceObjects
object can be used to obtain multiple service objects for the associated service if the service hasprototype
scope.If the associated service has
singleton
orbundle
scope, this method behaves the same as calling theBundleContext.getService(ServiceReference)
method for the associated service. That is, only one, use-counted service object is available from thisServiceObjects
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:
- If the associated service has been unregistered,
null
is returned. - The
PrototypeServiceFactory.getService(Bundle, ServiceRegistration)
method is called to supply a customized service object for the caller. - If the service object returned by the
PrototypeServiceFactory
object isnull
, not aninstanceof
all the classes named when the service was registered or thePrototypeServiceFactory
object throws an exception,null
is returned and a Framework event of typeFrameworkEvent.ERROR
containing aServiceException
describing the error is fired. - The customized service object is returned.
- Specified by:
getService
in interfaceServiceObjects<S>
- Returns:
- A service object for the associated service or
null
if the service is not registered, the customized service object returned by aServiceFactory
does not implement the classes under which it was registered or theServiceFactory
threw an exception. - See Also:
- If the associated service has been unregistered,
-
ungetService
Description copied from interface:ServiceObjects
Releases a service object for theassociated
service.This
ServiceObjects
object can be used to obtain multiple service objects for the associated service if the service hasprototype
scope. If the associated service hassingleton
orbundle
scope, this method behaves the same as calling theBundleContext.ungetService(ServiceReference)
method for the associated service. That is, only one, use-counted service object is available from thisServiceObjects
object.For a prototype scope service, the following steps are required to release a service object:
- If the associated service has been unregistered, this method returns without doing anything.
- The
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.
- Specified by:
ungetService
in interfaceServiceObjects<S>
- Parameters:
srvObj
- A service object previously provided by thisServiceObjects
object.- See Also:
-
getServiceReference
Description copied from interface:ServiceObjects
Returns theServiceReference
for the service associated with thisServiceObjects
object.- Specified by:
getServiceReference
in interfaceServiceObjects<S>
- Returns:
- The
ServiceReference
for the service associated with thisServiceObjects
object.
-