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.Builder<T>,
,HelidonServiceLoader<T>> Supplier<HelidonServiceLoader<T>>
- Enclosing class:
- HelidonServiceLoader<T>
public static final class HelidonServiceLoader.Builder<T>
extends Object
implements Builder<HelidonServiceLoader.Builder<T>,HelidonServiceLoader<T>>
Fluent api builder for
HelidonServiceLoader
.-
Method Summary
Modifier and TypeMethodDescriptionaddExcludedClass
(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.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.addService
(T service) Add a custom service implementation to the list of services.addService
(T service, int priority) Add a custom service implementation to the list of services with a custom priority.build()
Build the instance from this builder.defaultPriority
(int defaultPriority) Configure default priority for services that do not have any.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).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.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 Details
-
build
Description copied from interface:Builder
Build the instance from this builder.- Specified by:
build
in interfaceBuilder<HelidonServiceLoader.Builder<T>,
HelidonServiceLoader<T>> - Returns:
- instance of the built type
-
useSystemExcludes
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
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
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
Add a custom service implementation to the list of services.- Parameters:
service
- a new service instance- Returns:
- updated builder instance
-
addService
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
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
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
-
defaultPriority
Configure default priority for services that do not have any.- Parameters:
defaultPriority
- default priority to use, defaults toPrioritized.DEFAULT_PRIORITY
- Returns:
- updated builder instance
-