Skip to content

How can I inject a CDI bean in a custom ConfigSource or access Http request context in a custom ConfigSource ? #41904

Closed Answered by manovotn
omasseau asked this question in Q&A
Discussion options

You must be logged in to vote

How is this possible as a ConfigSource/ConfigSourceFactory is not a managed CDI bean. Is there any easy way ?

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:

RequestHostBean myBean = Arc.container().instance(RequestHostBean.class).get();

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?

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@omasseau
Comment options

@radcortez
Comment options

Answer selected by omasseau
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area/config area/arc Issue related to ARC (dependency injection)
3 participants