Class ServiceSelector<T>
- Type Parameters:
T- - The type of the service to be served up by this implementation of ServiceSelectorServiceSelectionStrategyServiceSelectorConverterServiceComparator
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 Summary
ConstructorsConstructorDescriptionThis default constructor is equivalent to calling: new ServiceSelector(new ddf.catalog.util.impl.ServiceComparator(), new FirstElementServiceSelectionStrategy())ServiceSelector(ServiceSelectionStrategy serviceSelectionStrategy) 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) -
Method Summary
Modifier and TypeMethodDescriptionvoidbindService(org.osgi.framework.ServiceReference serviceReference) voidunbindService(org.osgi.framework.ServiceReference serviceReference)
-
Constructor Details
-
ServiceSelector
public ServiceSelector()This default constructor is equivalent to calling: new ServiceSelector(new ddf.catalog.util.impl.ServiceComparator(), new FirstElementServiceSelectionStrategy()) -
ServiceSelector
This constructor allows the user to set the comparator to be used by this ServiceSelector which allows them to set the internal set order. It uses a FirstElementServiceSelectionStrategy.- Parameters:
serviceComparator- - The comparator used to determine the internal set order.
-
ServiceSelector
-
ServiceSelector
public ServiceSelector(Comparator serviceComparator, ServiceSelectionStrategy serviceSelectionStrategy)
-
-
Method Details
-
getService
-
getAllServices
-
bindService
public void bindService(org.osgi.framework.ServiceReference serviceReference) -
unbindService
public void unbindService(org.osgi.framework.ServiceReference serviceReference)
-