T
- - The type of the service to be served up by this implementation of ServiceSelector
ServiceSelectionStrategy
ServiceSelectorConverter
ServiceComparator
public class ServiceSelector<T> extends Object
In the point-to-point scenario a user needs to select a single service from the set of available services. The appropriate service to select is determined by the ServiceSelectionStrategy implementation that is provided to the ServiceSelector constructor. It can be retrieved by calling the 'getService()' method.
In the pub-sub scenario, the user needs to access all of the service implementations in the internal set. An unmodifiable view of the internal set can be retrieved by a call to 'getAllServices()'.
In both scenarios, the set order is determined by the Comparator object supplied to the ServiceSelector at creation.
OSGi requires a type converter to be registered for this class. Typically, it will also be used a reference-listener.
Example:
Constructor and Description |
---|
ServiceSelector()
This default constructor is equivalent to calling: new ServiceSelector(new
ddf.catalog.util.impl.ServiceComparator(), new FirstElementServiceSelectionStrategy())
|
ServiceSelector(Comparator serviceComparator)
This constructor allows the user to set the comparator to be used by this ServiceSelector which
allows them to set the internal set order.
|
ServiceSelector(Comparator serviceComparator,
ServiceSelectionStrategy serviceSelectionStrategy) |
ServiceSelector(ServiceSelectionStrategy serviceSelectionStrategy) |
Modifier and Type | Method and Description |
---|---|
void |
bindService(org.osgi.framework.ServiceReference serviceReference) |
SortedSet<org.osgi.framework.ServiceReference<T>> |
getAllServices() |
T |
getService() |
void |
unbindService(org.osgi.framework.ServiceReference serviceReference) |
public ServiceSelector()
public ServiceSelector(Comparator serviceComparator)
serviceComparator
- - The comparator used to determine the internal set order.public ServiceSelector(ServiceSelectionStrategy serviceSelectionStrategy)
public ServiceSelector(Comparator serviceComparator, ServiceSelectionStrategy serviceSelectionStrategy)
public T getService()
public void bindService(org.osgi.framework.ServiceReference serviceReference)
public void unbindService(org.osgi.framework.ServiceReference serviceReference)
This work is licensed under a Creative Commons Attribution 4.0 International License.