Class HelidonServiceLoader.Builder<T>

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 Details

    • build

      public HelidonServiceLoader<T> build()
      Description copied from interface: Builder
      Build the instance from this builder.
      Specified by:
      build in interface Builder<HelidonServiceLoader.Builder<T>,HelidonServiceLoader<T>>
      Returns:
      instance of the built type
    • useSystemExcludes

      public HelidonServiceLoader.Builder<T> 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.

      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 by addService(Object) or addService(Object, double). When set to false 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 through addService(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, double weight)
      Add a custom service implementation to the list of services with a custom weight.
      Parameters:
      service - a new service instance
      weight - weight 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 through addService(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 through addService(Object)), it would be ignored.
      Parameters:
      excludeName - excluded implementation class name
      Returns:
      updated builder instance
    • defaultWeight

      public HelidonServiceLoader.Builder<T> defaultWeight(double defaultWeight)
      Configure default weight for services that do not have any.
      Parameters:
      defaultWeight - default weight to use, defaults to Weighted.DEFAULT_WEIGHT
      Returns:
      updated builder instance