-
Hello, I need to implement a custom ConfigSource to fetch the value of a property dynamically at runtime in my REST service. Currently to know the hostname I read the injected UriInfo in my REST service:
I need to access this host (either by getting the RequestHostBean instance or UriInfo) in the implementation of my custom ConfigSource (or ConfigSourceFactory) How is this possible as a ConfigSource/ConfigSourceFactory is not a managed CDI bean. Is there any easy way ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
/cc @Ladicek (arc), @manovotn (arc), @mkouba (arc), @radcortez (config) |
Beta Was this translation helpful? Give feedback.
-
If you want to resolve a CDI from an arbitrary non-CDI location you can use programmatic lookup. RequestHostBean myBean = Arc.container().instance(RequestHostBean.class).get(); The CDI spec way is through Either way, the bean is only really "ready" in runtime, attempting to access it earlier will result in an error. |
Beta Was this translation helpful? Give feedback.
If you want to resolve a CDI from an arbitrary non-CDI location you can use programmatic lookup.
The Quarkus way of doing this is as follows:
The CDI spec way is through
CDI.current().select(...).get()
.Either way, the bean is only really "ready" in runtime, attempting to access it earlier will result in an error.
Therefore, I am not sure this is what you are looking for with config source?