java.lang.Object
io.github.mmm.base.config.ServiceHelper
Helper class for
ServiceLoader.- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic final <S> voidadd(ServiceLoader<S> serviceLoader, Collection<S> services) static final <S> voidadd(ServiceLoader<S> serviceLoader, Collection<S> services, 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:
unique- -trueif an exception is thrown if the service is not unique,falseotherwise (allow overriding default).serviceLoader- theServiceLoaderthat has to be provided from the module declaring the service API and holds theusesstatement in itsmodule-info.- Returns:
- the requested service.
-
add
- 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.
-
add
- 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.
-