- Enclosing class:
Option
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
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
Whether to discover all services using a service loader by default.
-
Element Details
-
value
Class<?> valueThe 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 discoverServicesWhether to discover all services using a service loader by default. When set totrue
, all services discovered by the service loader will be added (even if no configuration node exists for them). When set tofalse
, only services that have a configuration node will be added. This can be overridden bydiscover-services
configuration option under this option's key.- Returns:
- whether to discover services by default for a provider
- Default:
true
-