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(org.qi4j.functional.Specification<ServiceReference<?>> qualifier,
Iterable<ServiceReference<T>> services) |
static org.qi4j.functional.Specification<ServiceReference<?>> |
whereActive() |
static org.qi4j.functional.Specification<ServiceReference<?>> |
whereAvailable() |
static org.qi4j.functional.Specification<ServiceReference<?>> |
whereMetaInfoIs(Object metaInfo) |
static org.qi4j.functional.Specification<ServiceReference<?>> |
withId(String anId) |
static org.qi4j.functional.Specification<ServiceReference<?>> |
withTags(String... tags) |
public static <T> T firstService(org.qi4j.functional.Specification<ServiceReference<?>> qualifier, Iterable<ServiceReference<T>> services)
public static org.qi4j.functional.Specification<ServiceReference<?>> withId(String anId)
public static org.qi4j.functional.Specification<ServiceReference<?>> whereMetaInfoIs(Object metaInfo)
public static org.qi4j.functional.Specification<ServiceReference<?>> whereActive()
public static org.qi4j.functional.Specification<ServiceReference<?>> whereAvailable()
public static org.qi4j.functional.Specification<ServiceReference<?>> withTags(String... tags)