- 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> S
singleton(ServiceLoader<S> serviceLoader)
static <S> S
singleton(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
- theServiceLoader
that has to be provided from the module declaring the service API and holds theuses
statement 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
- -true
if an exception is thrown if the service is not unique,false
otherwise (allow overriding default).serviceLoader
- theServiceLoader
that has to be provided from the module declaring the service API and holds theuses
statement in itsmodule-info
.- Returns:
- the requested service.
-
-