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
CDI.current().select(Foo.class).get() does not work if Foo is not injected #2576
Comments
@mkouba can confirm but I'd say it's because the class is being removed because ArC can tell it isn't needed |
I would like to fix this |
A while back I had proposed something in between removing all unused and not removing any unused beans at all. The idea was to keep all beans defined in the application - see this. Perhaps it's something we should reevaluate? If it is something that we think makes sense, then I can redo the PR. Another idea might be to add some kind of nnotation that will ensure that Arc never removes the bean? |
@kenfinnigan I confirm. @Dufgui This optimization can be disabled using @geoand I like both of your ideas. Actually, I've been thinking of the annotation for a long time. It could be just |
@mkouba I can implement both of these two proposals in the following days (probably won't have any spare time today) if you agree. |
@geoand of course! ;-) |
thanks for your reply. Yes i see the remove unused flag (in the code, not in the doc ;o) ) |
This is one part of the solutions discussed in quarkusio#2576
This is one part of the solutions discussed in quarkusio#2576
This is one part of the solutions discussed in quarkusio#2576
This is one part of the solutions discussed in quarkusio#2576
This is one part of the solutions discussed in quarkusio#2576
This is one part of the solutions discussed in quarkusio#2576
This is one part of the solutions discussed in quarkusio#2576
This is one part of the solutions discussed in quarkusio#2576
@mkouba Now for the second part of proposed solution, how would you like to handle the |
Could we just use a string and map it to the following modes?
|
That sounds interesting. It wouldn't break existing applications (unless I am missing something) and we could support all the required modes. Sounds good! I'll take it up soon 😉 |
This is the second part of the solutions discussed in quarkusio#2576
This is the second part of the solutions discussed in quarkusio#2576
This is the second part of the solutions discussed in quarkusio#2576
This is the second part of the solutions discussed in quarkusio#2576
@mkouba should we close this now with that we have a couple related solutions in place? |
@geoand Yes ;-). |
CDI.current().select(...).get()
is useful to get a bean whose type is known dynamically, with quarkus it only works if the type is injected somewhere.For example :
Foo foo = CDI.current().select(Foo.class).get()
causes a javax.enterprise.inject.UnsatisfiedResolutionExceptionProblem solved with
@Inject Foo foo;
even if
foo
is not used.If it is due to build time optimizations, how about an option to flag the classes (here
Foo
) to register theses beans even if not injected anywhere ? Something like a retention policy.The text was updated successfully, but these errors were encountered: