Package io.ultreia.java4all.util
Class ServiceLoaders
- java.lang.Object
-
- io.ultreia.java4all.util.ServiceLoaders
-
public class ServiceLoaders extends Object
Created by tchemit on 30/05/2018.- Author:
- Tony Chemit - dev@tchemit.fr
-
-
Constructor Summary
Constructors Constructor Description ServiceLoaders()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <O> List<Class<O>>loadTypes(Class<O> serviceType)Load of classes of the givenserviceTypeusingServiceLoadermecanism, but without loading any of those services.static <S> SloadUniqueService(Class<S> serviceType)Load the unique implementation of the givenserviceType.static <S> ServiceLoader<S>reload(Class<S> serviceType)Get service loader for givenserviceType, applying aServiceLoader.reload()before returns.
-
-
-
Method Detail
-
reload
public static <S> ServiceLoader<S> reload(Class<S> serviceType)
Get service loader for givenserviceType, applying aServiceLoader.reload()before returns.- Type Parameters:
S- generic type of service to load- Parameters:
serviceType- type of service to load- Returns:
- the service loader
reloaded. - Since:
- 1.0.10
-
loadUniqueService
public static <S> S loadUniqueService(Class<S> serviceType)
Load the unique implementation of the givenserviceType.- Type Parameters:
S- generic type of service to load- Parameters:
serviceType- type of service to load- Returns:
- the unique service found
- Throws:
IllegalStateException- if could not find the servcie, or if there is more than one implementations found.
-
loadTypes
public static <O> List<Class<O>> loadTypes(Class<O> serviceType)
Load of classes of the givenserviceTypeusingServiceLoadermecanism, but without loading any of those services.- Type Parameters:
O- type of service to seek- Parameters:
serviceType- type of service to seek- Returns:
- list of all implementation found via
ServiceLoadermechanism for given type
-
-