public abstract class ServiceQualifier extends Object
Provide a Selector which does the actual selection from the list. A common case is to select based on identity of the service, which you can do this way:
new ServiceQualifier<MyService>(services, ServiceQualifier.withId("someId"))
Many selectors can be combined by using firstOf. Example:
new ServiceQualifier<MyService>(services, firstOf(withTags("sometag"), firstActive(), first()))
This will pick a service that has the tag "sometag", or if none is found take the first active one. If no service is active, then the first service will be picked.
Constructor and Description |
---|
ServiceQualifier() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
firstService(Specification<ServiceReference<?>> qualifier,
Iterable<ServiceReference<T>> services) |
static Specification<ServiceReference<?>> |
whereActive() |
static Specification<ServiceReference<?>> |
whereAvailable() |
static Specification<ServiceReference<?>> |
whereMetaInfoIs(Object metaInfo) |
static Specification<ServiceReference<?>> |
withId(String anId) |
static Specification<ServiceReference<?>> |
withTags(String... tags) |
public static <T> T firstService(Specification<ServiceReference<?>> qualifier, Iterable<ServiceReference<T>> services)
public static Specification<ServiceReference<?>> withId(String anId)
public static Specification<ServiceReference<?>> whereMetaInfoIs(Object metaInfo)
public static Specification<ServiceReference<?>> whereActive()
public static Specification<ServiceReference<?>> whereAvailable()
public static Specification<ServiceReference<?>> withTags(String... tags)