Package org.osgi.service.component
Interface ComponentServiceObjects<S>
- Type Parameters:
S- Type of Service
@ProviderType
public interface ComponentServiceObjects<S>
Allows multiple service objects for a service to be obtained.
A component instance can receive a ComponentServiceObjects object via
a reference that is typed ComponentServiceObjects.
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.
Any unreleased service objects obtained from this
ComponentServiceObjects object are automatically released by Service
Component Runtime when the service becomes unbound.
- Since:
- 1.3
- See Also:
- "ThreadSafe"
-
Method Summary
Modifier and TypeMethodDescriptionReturns a service object for theassociatedservice.Returns theServiceReferencefor the service associated with thisComponentServiceObjectsobject.voidungetService(S service) Releases a service object for theassociatedservice.
-
Method Details
-
getService
S getService()Returns a service object for theassociatedservice.This method will always return
nullwhen the associated service has been become unbound.- Returns:
- A service object for the associated service or
nullif the service is unbound, the customized service object returned by aServiceFactorydoes not implement the classes under which it was registered or theServiceFactorythrew an exception. - Throws:
IllegalStateException- If the component instance that received thisComponentServiceObjectsobject has been deactivated.- See Also:
-
ungetService
Releases a service object for theassociatedservice.The specified service object must no longer be used and all references to it should be destroyed after calling this method.
- Parameters:
service- A service object previously provided by thisComponentServiceObjectsobject.- Throws:
IllegalStateException- If the component instance that received thisComponentServiceObjectsobject has been deactivated.IllegalArgumentException- If the specified service object was not provided by thisComponentServiceObjectsobject.- See Also:
-
getServiceReference
ServiceReference<S> getServiceReference()Returns theServiceReferencefor the service associated with thisComponentServiceObjectsobject.- Returns:
- The
ServiceReferencefor the service associated with thisComponentServiceObjectsobject.
-