-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Synthetic beans / BeanRegistrarBuildItem doesn't support injection of the produces item like CDI producers #3699
Comments
Well, synthetic/custom beans in CDI do not support injection as the extension controls the implementation of In theory, we could try to enhance the |
I think the handling in MyFaces is also bit weird:
i think for this special case, we should avoid to create a synthetic bean again and i will try to refactor MyFaces here However, in generell, i think providing such a mechanism could be a benefit in future |
The addition of beans in Quarkus is designed to be as close to CDI's original means as possible. And even in CDI you cannot really have injectable params for when you add synthetic bean. The approach with |
So we could follow the logic used for normal injection (including producers), i.e. that We could add a default method to the default T create(CreationalContext<T> creationalContext, Map<String, Object> params, Instance<Object> instance) {
return create(creationalContext, params);
} @tandraschko @manovotn WDYT? |
That sounds good. But if you grant user access to the Also, keeping both methods opens up a way to implement both differently and we wouldn't know which one to invoke (well, we'd invoke the new one anyway but still). I know it doesn't make sense to do that, but it introduces another possible user error - if we add this method, we should probably deprecate the previous one and eventually delete it. |
That is not a problem. A destroyed
Yes, we would always call a new one and the default impl would be to call the old one. The only problem I see is that we would have to make the old one also
That's also an option. |
We are relatively close:tm: to supporting CDI 4 Lite extension SPI as means to create synthetic beans in Quarkus 3. With that in mind, can we close this issue @mkouba? |
I don't think so. We don't plan to switch to CDI 4 Lite extension SPI in quarkus extensions, i.e. build items will remain the preffered and idiomatic way of registering synthetic beans in quarkus. That said, it's IMO a minor issue with low priority. |
Sorry, I wasn't clear. I know build items will be there but I assume we'll adapt them in some way so that the Lite extension API actually goes through them. @Ladicek probably knows more as he has a draft stored somewhere. |
My implementation of BCExtensions currently doesn't use the In fact, I could probably change it right away, because I have introduced a special method |
Oh and btw, I personally think that the BCExtensions API is in many ways better than the ArC extension API and the Quarkus build items. It "just" has 2 significant downsides:
The 2nd issue can be partially solved when it comes to CDI concepts (but not when it comes to ArC / Quarkus concepts, obviously) (and probably will, in time), the 1st... not so much. |
IMO the most important downside is that you can't use the build items as "input" and "output", e.g. register a synthetic bean if a build item is produced or produce a build item if a bean with a specific type is present. Pls correct me if I'm wrong and this is possible. Also note that the very same problem was present in CDI portable extensions. Basically, it's a very nice API if an extension is very CDI-centric and does not care much about the other parts of the stack. |
I tried to to say that by the edit to my last sentence, but you're right, it should have been an extra item in the list. I didn't make a proper difference between comparing with the ArC extension API and with the Quarkus extension API. The power of BCExtensions, when implemented in ArC, is limited by the power of ArC extensions. That said, I believe (though I have yet to try it myself) that a lot of CDI-based frameworks can achieve 50% - 90% of their integration needs just with BCExtensions.
Actually I think it might be possible. The design of BCExtensions allows for custom, non-portable extension points. A |
The synthetic injection points API is the preferred solution in Quarkus. |
Description
Syntetic beans / BeanRegistrarBuildItem doesn't support injection of the produces item like CDI producers
e.g. https://github.com/tandraschko/quarkus-myfaces/blob/master/quarkus-myfaces/runtime/src/main/java/io/quarkus/myfaces/runtime/producer/SimpleBeanCreator.java
Implementation ideas
The text was updated successfully, but these errors were encountered: