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 reference 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 Predicate<ServiceReference<?>> |
whereActive() |
static Predicate<ServiceReference<?>> |
whereAvailable() |
static Predicate<ServiceReference<?>> |
whereMetaInfoIs(Object metaInfo) |
static Predicate<ServiceReference<?>> |
withId(String anId) |
static Predicate<ServiceReference<?>> |
withTags(String... tags) |
public static Predicate<ServiceReference<?>> withId(String anId)
public static Predicate<ServiceReference<?>> whereMetaInfoIs(Object metaInfo)
public static Predicate<ServiceReference<?>> whereActive()
public static Predicate<ServiceReference<?>> whereAvailable()
public static Predicate<ServiceReference<?>> withTags(String... tags)