class BundleContextImpl.ServiceObjectsImpl<S> extends java.lang.Object implements ServiceObjects<S>
| Modifier and Type | Field and Description |
|---|---|
private ServiceReference<S> |
m_ref |
| Constructor and Description |
|---|
ServiceObjectsImpl(ServiceReference<S> ref) |
| Modifier and Type | Method and Description |
|---|---|
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 srvObj)
Releases a service object for the
associated service. |
private final ServiceReference<S> m_ref
public ServiceObjectsImpl(ServiceReference<S> ref)
public S getService()
ServiceObjectsassociated 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.getService in interface ServiceObjects<S>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.ServiceObjects.ungetService(Object)public void ungetService(S srvObj)
ServiceObjectsassociated 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.
ungetService in interface ServiceObjects<S>srvObj - A service object previously provided by this
ServiceObjects object.ServiceObjects.getService()public ServiceReference<S> getServiceReference()
ServiceObjectsServiceReference for the service associated with this
ServiceObjects object.getServiceReference in interface ServiceObjects<S>ServiceReference for the service associated with this
ServiceObjects object.