Annotation Interface Option.Provider

Enclosing class:
Option

@Target(METHOD) @Inherited @Retention(CLASS) public static @interface Option.Provider
Mark option as sourced from a ServiceLoader. Use if the configuration may be provided by another module not known to us.

To control whether to discover services or not, you can specify a key config-key-discover-services on the same level as the section for the provider based property. This is aligned with the generated methods on the builder, and allows for the shallowest possible configuration tree (this would override discoverServices() defined on this annotation).

Also there is no difference regardless whether we return a single value, or a list of values. If the method returns a list, the provider configuration must be under config key providers under the configured option. On the same level as providers, there can be discover-services boolean

Option called myProvider that returns a single provider, or an Optional provider example in configuration:

 my-type:
   my-provider:
     provider-id:
       provider-key1: "providerValue"
       provider-key2: "providerValue"
 

Option called myProviders that returns a list of providers in configuration:

 my-type:
   my-providers-discover-services: true # default of this value is controlled by annotation
   my-providers:
     provider-id:
       provider-key1: "providerValue"
       provider-key2: "providerValue"
     provider2-id:
       provider2-key1: "provider2Value"
 
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The service provider interface that is used to discover implementations.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether to discover all services using a service loader by default.
  • Element Details

    • value

      Class<?> value
      The service provider interface that is used to discover implementations. The type of the property is the service provided by that provider.
      Returns:
      type of the provider
    • discoverServices

      boolean discoverServices
      Whether to discover all services using a service loader by default. When set to true, all services discovered by the service loader will be added (even if no configuration node exists for them). When set to false, only services that have a configuration node will be added. This can be overridden by discover-services configuration option under this option's key.
      Returns:
      whether to discover services by default for a provider
      Default:
      true