Package dev.langchain4j.spi
Class ServiceHelper
java.lang.Object
dev.langchain4j.spi.ServiceHelper
Utility wrapper around
ServiceLoader.load()
.-
Method Summary
Modifier and TypeMethodDescriptionstatic <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 Details
-
loadFactories
Load all the services of a given type.- Type Parameters:
T
- the type of service- Parameters:
clazz
- the type of service- Returns:
- the list of services, empty if none
-
loadFactories
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$)
- Type Parameters:
T
- the type of service- Parameters:
clazz
- the type of serviceclassLoader
- the classloader to use, may be null- Returns:
- the list of services, empty if none
- If classloader is
-