Package org.operaton.commons.utils
Class ServiceLoaderUtil
java.lang.Object
org.operaton.commons.utils.ServiceLoaderUtil
Utility class for loading services via ServiceLoader.
- Since:
- 1.1
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TloadSingleService(Class<T> serviceClass) Loads a single service implementation usingServiceLoader.
-
Method Details
-
loadSingleService
Loads a single service implementation usingServiceLoader.This method first attempts to load the service using the thread context classloader. If no implementation is found, it tries again using the classloader of the service class itself.
- Type Parameters:
T- the type of the service- Parameters:
serviceClass- the service class to load- Returns:
- the first found implementation of the service
- Throws:
IllegalStateException- if no implementation is found
-