Top Description Methods
org.osgi.service.component

public Interface ComponentServiceObjects<S>

Annotations
@ProviderType
Type Parameters
<S>
Type of Service
Imports
org.osgi.annotation.versioning.ProviderType, org.osgi.framework.Constants, .ServiceObjects, .ServiceReference

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.

Author
$Id: de9c6da9627ed560f3d03877070bc0fd08f05032 $
Since
1.3
See Also
ServiceObjects

Method Summary

Modifier and TypeMethod and Description
public S

Returns:

A service object for the associated service or null if the service is unbound, the customized service object returned by a ServiceFactory does not implement the classes under which it was registered or the ServiceFactory threw an exception.
getService
()

Returns a service object for the associated service.

public ServiceReference<S>

Returns:

The ServiceReference for the service associated with this ComponentServiceObjects object.
getServiceReference
()

Returns the ServiceReference for the service associated with this ComponentServiceObjects object.

public void
ungetService(S
A service object previously provided by this ComponentServiceObjects object.
service
)

Releases a service object for the associated service.

Method Detail

getServiceback to summary
public S getService()

Returns a service object for the associated service.

This method will always return null when the associated service has been become unbound.

Returns:S

A service object for the associated service or null if the service is unbound, the customized service object returned by a ServiceFactory does not implement the classes under which it was registered or the ServiceFactory threw an exception.

Exceptions
IllegalStateException:
If the component instance that received this ComponentServiceObjects object has been deactivated.
See Also
ungetService(Object)
getServiceReferenceback to summary
public ServiceReference<S> getServiceReference()

Returns the ServiceReference for the service associated with this ComponentServiceObjects object.

Returns:ServiceReference<S>

The ServiceReference for the service associated with this ComponentServiceObjects object.

ungetServiceback to summary
public void ungetService(S service)

Releases a service object for the associated service.

The specified service object must no longer be used and all references to it should be destroyed after calling this method.

Parameters
service:S

A service object previously provided by this ComponentServiceObjects object.

Exceptions
IllegalStateException:
If the component instance that received this ComponentServiceObjects object has been deactivated.
IllegalArgumentException:
If the specified service object was not provided by this ComponentServiceObjects object.
See Also
getService()