Class BundleContextImpl.ServiceObjectsImpl<S>
- java.lang.Object
-
- org.apache.felix.framework.BundleContextImpl.ServiceObjectsImpl<S>
-
- All Implemented Interfaces:
ServiceObjects<S>
- Enclosing class:
- BundleContextImpl
class BundleContextImpl.ServiceObjectsImpl<S> extends java.lang.Object implements ServiceObjects<S>
-
-
Field Summary
Fields Modifier and Type Field Description private ServiceReference<S>m_refprivate java.util.List<S>srvObjects
-
Constructor Summary
Constructors Constructor Description ServiceObjectsImpl(ServiceReference<S> ref)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SgetService()Returns a service object for theassociatedservice.ServiceReference<S>getServiceReference()Returns theServiceReferencefor the service associated with thisServiceObjectsobject.voidungetService(S srvObj)Releases a service object for theassociatedservice.
-
-
-
Field Detail
-
m_ref
private final ServiceReference<S> m_ref
-
srvObjects
private final java.util.List<S> srvObjects
-
-
Constructor Detail
-
ServiceObjectsImpl
public ServiceObjectsImpl(ServiceReference<S> ref)
-
-
Method Detail
-
getService
public S getService()
Description copied from interface:ServiceObjectsReturns a service object for theassociatedservice.This
ServiceObjectsobject can be used to obtain multiple service objects for the associated service if the service hasprototypescope.If the associated service has
singletonorbundlescope, 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 thisServiceObjectsobject.This method will always return
nullwhen 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,
nullis 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
PrototypeServiceFactoryobject isnull, not aninstanceofall the classes named when the service was registered or thePrototypeServiceFactoryobject throws an exception,nullis returned and a Framework event of typeFrameworkEvent.ERRORcontaining aServiceExceptiondescribing the error is fired. - The customized service object is returned.
- Specified by:
getServicein interfaceServiceObjects<S>- Returns:
- A service object for the associated service or
nullif the service is not registered, the customized service object returned by aServiceFactorydoes not implement the classes under which it was registered or theServiceFactorythrew an exception. - See Also:
ServiceObjects.ungetService(Object)
- If the associated service has been unregistered,
-
ungetService
public void ungetService(S srvObj)
Description copied from interface:ServiceObjectsReleases a service object for theassociatedservice.This
ServiceObjectsobject can be used to obtain multiple service objects for the associated service if the service hasprototypescope. If the associated service hassingletonorbundlescope, 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 thisServiceObjectsobject.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:
ungetServicein interfaceServiceObjects<S>- Parameters:
srvObj- A service object previously provided by thisServiceObjectsobject.- See Also:
ServiceObjects.getService()
-
getServiceReference
public ServiceReference<S> getServiceReference()
Description copied from interface:ServiceObjectsReturns theServiceReferencefor the service associated with thisServiceObjectsobject.- Specified by:
getServiceReferencein interfaceServiceObjects<S>- Returns:
- The
ServiceReferencefor the service associated with thisServiceObjectsobject.
-
-