- java.lang.Object
-
- io.github.mmm.base.config.ServiceHelper
-
public final class ServiceHelper extends Object
Helper class forServiceLoader.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <S> Ssingleton(ServiceLoader<S> serviceLoader)static <S> Ssingleton(ServiceLoader<S> serviceLoader, boolean unique)
-
-
-
Method Detail
-
singleton
public static final <S> S singleton(ServiceLoader<S> serviceLoader)
- 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
public static final <S> S singleton(ServiceLoader<S> serviceLoader, boolean unique)
- 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.
-
-