Class HelidonServiceLoader<T>

Type Parameters:
T - Type of the service to be loaded
All Implemented Interfaces:

public final class HelidonServiceLoader<T> extends Object implements Iterable<T>
Helidon specific support for Java Service Loaders.

This service loader:

Note on weight handling

Service weight is defined by:

 public class MyServiceImpl implements Service, Weighted {
     public double weight() {
         return 6200;
Such a service would have a weight of 6200 as that is more significant than the annotation.

A service with higher weight is returned before a service with a lower weight number. Services with the same weight have order defined by the order they are in the configured services and then as they are loaded from the ServiceLoader. Negative weights are not allowed. A service with weight 2 will be returned before a service with weight 2.

See Also:
  • Field Details


      public static final String SYSTEM_PROPERTY_EXCLUDE
      System property used to exclude some implementation from the list of services that are configured for Java Service loader or services that are registered using HelidonServiceLoader.Builder.
      See Also:
  • Method Details

    • builder

      public static <T> HelidonServiceLoader.Builder<T> builder(ServiceLoader<T> serviceLoader)
      Create a builder for customizable service loader.
      Type Parameters:
      T - type of the service
      serviceLoader - the Java Service loader used to get service implementations
      a new fluent API builder
    • create

      public static <T> HelidonServiceLoader<T> create(ServiceLoader<T> serviceLoader)
      Create a weighted service loader from a Java Service loader.
      Type Parameters:
      T - type of the service
      serviceLoader - the Java service loader
      service loader with exclusions defined by system properties and no custom services
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • forEach

      public void forEach(Consumer<? super T> action)
      Specified by:
      forEach in interface Iterable<T>
    • asList

      public List<T> asList()
      Provides a list of service implementations in weighted order.
      list of service implementations
    • stream

      public Stream<T> stream()
      Provides a stream of service implementations, in weighted order.
      stream os service implementations