java.lang.Object
io.github.mmm.base.service.ServiceHelper
Helper class for
ServiceLoader.- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic final <S> voidall(ServiceLoader<S> serviceLoader, Collection<S> services) static final <S> voidall(ServiceLoader<S> serviceLoader, Collection<S> services, int min) static final <S,K> void all(ServiceLoader<S> serviceLoader, Map<K, S> services, Function<S, K> keyFunction) static final <S,K> void all(ServiceLoader<S> serviceLoader, Map<K, S> services, Function<S, K> keyFunction, int min) static final <S> Ssingleton(ServiceLoader<S> serviceLoader) static final <S> Ssingleton(ServiceLoader<S> serviceLoader, boolean unique)
-
Method Details
-
singleton
- Type Parameters:
S- type of the service.- Parameters:
serviceLoader- theServiceLoaderthat has to be provided from the module declaring the service API and holds theusesstatement in itsmodule-info.- Returns:
- the requested service.
-
singleton
- Type Parameters:
S- type of the service.- Parameters:
serviceLoader- theServiceLoaderthat has to be provided from the module declaring the service API and holds theusesstatement in itsmodule-info.unique- -trueif an exception is thrown if the service is not unique,falseotherwise (allow overriding default).- Returns:
- the requested service.
-
all
- Type Parameters:
S- type of the service.- Parameters:
serviceLoader- theServiceLoaderthat has to be provided from the module declaring the service API and holds theusesstatement in itsmodule-info.services- theCollectionwhere to add the services from the givenServiceLoader.
-
all
- Type Parameters:
S- type of the service.- Parameters:
serviceLoader- theServiceLoaderthat has to be provided from the module declaring the service API and holds theusesstatement in itsmodule-info.services- theCollectionwhere to add the services from the givenServiceLoader.min- the minimum number of services required.
-
all
public static final <S,K> void all(ServiceLoader<S> serviceLoader, Map<K, S> services, Function<S, K> keyFunction) - Type Parameters:
S- type of the service.K- type of theMapkey.- Parameters:
serviceLoader- theServiceLoaderthat has to be provided from the module declaring the service API and holds theusesstatement in itsmodule-info.services- theCollectionwhere to add the services from the givenServiceLoader.keyFunction- theFunctionto get theMapkey from the service.
-
all
public static final <S,K> void all(ServiceLoader<S> serviceLoader, Map<K, S> services, Function<S, K> keyFunction, int min) - Type Parameters:
S- type of the service.K- type of theMapkey.- Parameters:
serviceLoader- theServiceLoaderthat has to be provided from the module declaring the service API and holds theusesstatement in itsmodule-info.services- theCollectionwhere to add the services from the givenServiceLoader.keyFunction- theFunctionto get theMapkey from the service.min- the minimum number of services required.
-