Package dev.langchain4j.spi
Class ServiceHelper
-
- All Implemented Interfaces:
public class ServiceHelperUtility wrapper around
ServiceLoader.load().
-
-
Method Summary
Modifier and Type Method Description static <T> Collection<T>loadFactories(Class<T> clazz)Load all the services of a given type. static <T> Collection<T>loadFactories(Class<T> clazz, ClassLoader classLoader)Load all the services of a given type. -
-
Method Detail
-
loadFactories
static <T> Collection<T> loadFactories(Class<T> clazz)
Load all the services of a given type.
- Parameters:
clazz- the type of service- Returns:
the list of services, empty if none
-
loadFactories
static <T> Collection<T> loadFactories(Class<T> clazz, ClassLoader classLoader)
Load all the services of a given type.
Utility mechanism around
ServiceLoader.load()- If classloader is
null, will tryServiceLoader.load(clazz) - If classloader is not
null, will tryServiceLoader.load(clazz, classloader)
If the above return nothing, will fall back to
ServiceLoader.load(clazz, $this class loader$)- Parameters:
clazz- the type of serviceclassLoader- the classloader to use, may be null- Returns:
the list of services, empty if none
- If classloader is
-
-
-
-