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 typedComponentServiceObjects
.For services with
prototype
scope, multiple service objects for the service can be obtained. For services withsingleton
orbundle
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:
ServiceObjects
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description S
getService()
Returns a service object for theassociated
service.ServiceReference<S>
getServiceReference()
Returns theServiceReference
for the service associated with thisComponentServiceObjects
object.void
ungetService(S service)
Releases a service object for theassociated
service.
-
-
-
Method Detail
-
getService
S getService()
Returns a service object for theassociated
service.This method will always return
null
when the associated service has been become unbound.- Returns:
- A service object for the associated service or
null
if the service is unbound, the customized service object returned by aServiceFactory
does not implement the classes under which it was registered or theServiceFactory
threw an exception. - Throws:
java.lang.IllegalStateException
- If the component instance that received thisComponentServiceObjects
object has been deactivated.- See Also:
ungetService(Object)
-
ungetService
void ungetService(S service)
Releases a service object for theassociated
service.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 thisComponentServiceObjects
object.- Throws:
java.lang.IllegalStateException
- If the component instance that received thisComponentServiceObjects
object has been deactivated.java.lang.IllegalArgumentException
- If the specified service object was not provided by thisComponentServiceObjects
object.- See Also:
getService()
-
getServiceReference
ServiceReference<S> getServiceReference()
Returns theServiceReference
for the service associated with thisComponentServiceObjects
object.- Returns:
- The
ServiceReference
for the service associated with thisComponentServiceObjects
object.
-
-