-
Notifications
You must be signed in to change notification settings - Fork 566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4.x: Supplier in builder #7402
4.x: Supplier in builder #7402
Conversation
builder/processor/src/main/java/io/helidon/builder/processor/TypeHandlerSupplier.java
Outdated
Show resolved
Hide resolved
@@ -284,4 +284,41 @@ default Stream<T> stream() { | |||
return asOptional().stream(); | |||
} | |||
|
|||
/** | |||
* Returns a supplier of a typed value. The semantics depend on implementation, this may always return the | |||
* same value, or it may provide latest value if changes are enabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
link to something here to support "if changes are enabled".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a clear statement "the semantics depend on implementation" - I cannot link to a type that is an implementation of this interface.
Description
A blueprint can now define a
Supplier<T>
. If this type is@Configured
and the method has@ConfiguredOption
, the supplier will be used directly fromConfig
(if used).This means the supplier will provide the latest value if changes are enabled in config.
Added appropriate test with a mutable configuration.
Resolves #7323
May require rebase after #7400 is merged
Documentation
This enhancement adds support for a typed
Supplier
in prototype blueprints (Helidon builder).The following blueprint:
will work with
io.helidon.config.Config
that has support for changes (using polling, file watcher, or an event based config source) in the following way:SupplierBean
is created with config (such asSupplierBean.create(Config)
orSupplierBean.Builder.config(Config)
is used), the returning supplier will always provide the latest known value from the configuration keystring-supplier
Of course the supplier can also be set explicitly (
SupplierBean.Builder.stringSupplier(() -> "someValue)
) - in this case, the supplier that is provided by user will be used