Package io.helidon.common.serviceloader
Class HelidonServiceLoader.Builder<T>
- java.lang.Object
-
- io.helidon.common.serviceloader.HelidonServiceLoader.Builder<T>
-
- Type Parameters:
T
- type of the service to be loaded
- All Implemented Interfaces:
Builder<HelidonServiceLoader<T>>
,Supplier<HelidonServiceLoader<T>>
- Enclosing class:
- HelidonServiceLoader<T>
public static final class HelidonServiceLoader.Builder<T> extends Object implements Builder<HelidonServiceLoader<T>>
Fluent api builder forHelidonServiceLoader
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HelidonServiceLoader.Builder<T>
addExcludedClass(Class<? extends T> excluded)
Add an excluded implementation class - if such a service implementation is configured (either through Java Service loader or throughaddService(Object)
), it would be ignored.HelidonServiceLoader.Builder<T>
addExcludedClassName(String excludeName)
Add an excluded implementation class - if such a service implementation is configured (either through Java Service loader or throughaddService(Object)
), it would be ignored.HelidonServiceLoader.Builder<T>
addService(T service)
Add a custom service implementation to the list of services.HelidonServiceLoader.Builder<T>
addService(T service, int priority)
Add a custom service implementation to the list of services with a custom priority.HelidonServiceLoader<T>
build()
Build the instance from this builder.HelidonServiceLoader.Builder<T>
replaceImplementations(boolean replace)
When configured to replace implementations, then a service implementation configured throughaddService(Object)
will replace the same implementation loaded from the Java Service loader (compared by fully qualified class name).HelidonServiceLoader.Builder<T>
useSystemExcludes(boolean useSysPropExclude)
When configured to use system excludes, system property "io.helidon.common.serviceloader.exclude" is used to get the comma separated list of service implementations to exclude them from the loaded list.HelidonServiceLoader.Builder<T>
useSystemServiceLoader(boolean useServiceLoader)
When configured to use Java Service loader, then the result is a combination of all service implementations loaded from the Java Service loader and those added byaddService(Object)
oraddService(Object, int)
.
-
-
-
Method Detail
-
build
public HelidonServiceLoader<T> build()
Description copied from interface:Builder
Build the instance from this builder.
-
useSystemExcludes
public HelidonServiceLoader.Builder<T> useSystemExcludes(boolean useSysPropExclude)
When configured to use system excludes, system property "io.helidon.common.serviceloader.exclude" is used to get the comma separated list of service implementations to exclude them from the loaded list.This defaults to
true
.- Parameters:
useSysPropExclude
- whether to use a system property to exclude service implementations- Returns:
- updated builder instance
-
useSystemServiceLoader
public HelidonServiceLoader.Builder<T> useSystemServiceLoader(boolean useServiceLoader)
When configured to use Java Service loader, then the result is a combination of all service implementations loaded from the Java Service loader and those added byaddService(Object)
oraddService(Object, int)
. When set tofalse
the Java Service loader is ignored.This defaults to
true
.- Parameters:
useServiceLoader
- whether to use the Java Service loader- Returns:
- updated builder instance
-
replaceImplementations
public HelidonServiceLoader.Builder<T> replaceImplementations(boolean replace)
When configured to replace implementations, then a service implementation configured throughaddService(Object)
will replace the same implementation loaded from the Java Service loader (compared by fully qualified class name).This defaults to
true
.- Parameters:
replace
- whether to replace service instances loaded by java service loader with the ones provided through builder methods- Returns:
- updated builder instance
-
addService
public HelidonServiceLoader.Builder<T> addService(T service)
Add a custom service implementation to the list of services.- Parameters:
service
- a new service instance- Returns:
- updated builder instance
-
addService
public HelidonServiceLoader.Builder<T> addService(T service, int priority)
Add a custom service implementation to the list of services with a custom priority.- Parameters:
service
- a new service instancepriority
- priority to use when ordering service instances- Returns:
- updated builder instance
-
addExcludedClass
public HelidonServiceLoader.Builder<T> addExcludedClass(Class<? extends T> excluded)
Add an excluded implementation class - if such a service implementation is configured (either through Java Service loader or throughaddService(Object)
), it would be ignored.- Parameters:
excluded
- excluded implementation class- Returns:
- updated builder instance
-
addExcludedClassName
public HelidonServiceLoader.Builder<T> addExcludedClassName(String excludeName)
Add an excluded implementation class - if such a service implementation is configured (either through Java Service loader or throughaddService(Object)
), it would be ignored.- Parameters:
excludeName
- excluded implementation class name- Returns:
- updated builder instance
-
-