-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Circular dependencies? #2990
Comments
Not really an answer to your question, but just chiming in... I am not sure if there are plans to support that (@mkouba might know more?) as it is a corner case (not frequently used) and in many cases designing with circular dependencies is simply a fishy design in the first place. |
Matej is right, circular dependencies are not supported ATM. He's also right that users are encouraged to avoid circular dependencies where possible. On the other hand, it's a CDI spec requirement and so we should probably think about how difficult it would be to add the support of circular dependencies. |
To be clear, I totally agree with @manovotn that having circular dependencies is not something to wish for. Sure, there will be exceptions to the rule anyway. In this case I've brought op the issue because it's an external codebase (Krazo) which I obviously cannot easily change. Of course I could mention it there, but they're probably well aware of the fact and I'm not sure if they're willing to change it. |
I fully understand ;-). And I also doubt that Krazo's team is going to try to get rid of circular deps because as I mentioned - every CDI implementation must support it. |
After some discussion with @mkouba - the current implementation operates with It's definitely a feature that we would like to look into sometime in the future but for now it is of lower priority. |
Thanks for all the pointers! I'm willing to give it a try and see if I can implement something like this. I just can't make any promises on the timeframe... |
I've started working on this on a branch in my fork of Quarkus. I've refactored the Now I'm wondering what the dependency graph should look like. The |
If you are talking about validation inside From CDI specification, an unsupported circular dependency is one where all beans are of pseudo-scope. If there is at least one normal scoped bean in the chain, then it should be supported. See this spec bit. So you will need to gather information on scopes. There can be custom scoped added too. For each bean you inspect you can get its |
Hmm, but where should we get the (By the way, if this discussion is better held on Zulip, please say so and we'll take it there) |
Hmm, my understanding was that you do it the same way except that instead of keeping track of injection points for each bean via |
I've changed that place to work with But my question remains. The |
Sorry for the delay, the notification slipped my attention.
EDIT: hold on, I am wrong. The |
Yeah, figured out that you must've meant something like the edit instead of the original comment :-). Having lambdas is indeed quite some overhead but I don't really know if we should have a Collection of Anyway, I think I have the circular dependencies working. I've replaced the Would you like me to create a pull request so we can discuss the implementation and see whether/where it needs improvement? |
That's what we ideally want so that with no circ deps you have no extra lambdas in place.
Sure! Bring up a draft PR and let's go from there. |
I've created the draft PR. I'll see if I can get rid of the many lambda's being created currently. Maybe things can be simpler than I thought at first - we'll see. If so, I'll update the PR. |
I noticed that there had been quite some activity on the master branch since I started my work. I'm rebasing against master first and will create a new PR afterwards. |
I'm trying to see if I can get the MVC specification (JSR 371) and its reference implementation Krazo working in a Quarkus app.
I think the right way to do that is by creating a Quarkus extension.
I've got a skeleton of that, and I have a small MVC-application (in the same repo) on top of Quarkus to see if it actually works.
When I package my app, the quarkus-maven-plugin fails with:
I've been poking around a little bit to understand what's going on.
MvcContextImpl
bean.applicationUris
.UriTemplateParser
class produces a value for that; its@PostConstruct
-annotated init method is responsible for that.MvcContext
to do that.If you follow Krazo's Install Guide for Servlet Containers, you'll get the Weld implementation for CDI.
The same sample app works just fine in that environment.
From what I've seen during debugging, Weld builds a proxy for every injection that you define.
It only resolves that bean when there's an actual interaction with it, say a method invocation.
A few questions here:
The text was updated successfully, but these errors were encountered: