java.lang.Object
io.helidon.common.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, double weight) Add a custom service implementation to the list of services with a custom weight.build()
Build the instance from this builder.defaultWeight
(double defaultWeight) Configure default weight 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"<T> 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, double)
.
-
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"<T> 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, double)
. 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 weight.- Parameters:
service
- a new service instanceweight
- weight 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
-
defaultWeight
Configure default weight for services that do not have any.- Parameters:
defaultWeight
- default weight to use, defaults toWeighted.DEFAULT_WEIGHT
- Returns:
- updated builder instance
-