ConfigBean is another BuilderTrigger that extends the
Builder concept to support the integration to Helidon's configuration sub-system. It basically
provides everything that Builder provides. However, unlike the base
Builder generated classes that can handle any object type, the types used within your target
ConfigBean-annotated interface must have all of its attribute getter method types resolvable by Helidon's configuration
sub-system.
The @code ConfigBean} is therefore a logical grouping for the "pure configuration" set of attributes (and
sub-ConfigBean attributes) that typically originate from an external media store (e.g., property files, config maps,
etc.), and are integrated via Helidon's Config subsystem at runtime.
One should write a ConfigBean-annotated interface in such a way as to group the collection of configurable elements
that logically belong together to then be delivered (and perhaps drive an activation of) one or more java service types that
are said to be ConfiguredBy the given ConfigBean instance.
The builder-config-processor module is required to be on the APT classpath to code-generate the implementation
classes for the ConfigBean.
Example:
@ConfigBean
public interface MyConfigBean {
String getName();
int getPort();
}
When Pico services are incorporated into the application lifecycle at runtime, the configuration
sub-system is scanned at startup and ConfigBean instances are created and fed into the ConfigBeanRegistry.
This mapping occurs based upon the ConfiguredOption.key() on each of
the ConfigBean's attributes. If no such ConfiguredOption is found then the type name is used as the key
(e.g., MyConfigBean would map to "my-config-bean").
Also see ConfiguredBy in Pico's config-driven module.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents the level in the config tree to search for config bean instances. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanAn instance of this bean will be created if there are no instances discovered by the configuration provider(s) post startup, and will use all default values annotated usingConfiguredOptionsfrom the bean interface methods.booleanDetermines whether an instance of this config bean in the bean registry will result in the backing serviceConfiguredBythis bean to be activated.TheConfigBean.LevelTypeof this config bean.booleanDetermines whether there can be more than one bean instance of this type.The overridden key to use.booleanAn instance of this bean will be created if there are no instances discovered by the configuration provider(s) post startup, and will use all default values annotated on the bean interface.
-
Element Details
-
value
String valueThe overridden key to use. If not set this will default to use the expanded name from the config subsystem, (e.g. MyConfig -> "my-config").- Returns:
- the overriding key to use
- Default:
""
-
drivesActivation
boolean drivesActivationDetermines whether an instance of this config bean in the bean registry will result in the backing serviceConfiguredBythis bean to be activated.As of the current release, only
ConfigBean.LevelType.ROOTlevel config beans can drive activation.The default value is
false.- Returns:
- true if this config bean should drive
ConfiguredByservice activation
- Default:
false
-
atLeastOne
boolean atLeastOneAn instance of this bean will be created if there are no instances discovered by the configuration provider(s) post startup, and will use all default values annotated usingConfiguredOptionsfrom the bean interface methods.The default value is
false.- Returns:
- the default config bean instance using defaults
- Default:
false
-
repeatable
boolean repeatableDetermines whether there can be more than one bean instance of this type.If false then only 0..1 behavior will be permissible for active beans in the config registry. If true then
> 1instances will be permitted.Note: this attribute is dynamic in nature, and therefore cannot be validated at compile time. All violations found to this policy will be observed during PicoServices activation.
The default value is
true.- Returns:
- true if repeatable
- Default:
true
-
wantDefaultConfigBean
boolean wantDefaultConfigBeanAn instance of this bean will be created if there are no instances discovered by the configuration provider(s) post startup, and will use all default values annotated on the bean interface.As of the current release, only
ConfigBean.LevelType.ROOTlevel config beans can be defaulted.The default value is
false.- Returns:
- use the default config instance
- Default:
false
-
levelType
ConfigBean.LevelType levelTypeTheConfigBean.LevelTypeof this config bean.The default level type is
ConfigBean.LevelType.ROOT.- Returns:
- the level type of this config bean
- Default:
ROOT
-