-
Notifications
You must be signed in to change notification settings - Fork 78
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
Instance iterator and stream ordering #824
Comments
The first question is: what priority order should we use? The CDI specification generally orders things in the ascending manner (interceptors, decorators, observers), but there is at least one existing implementation (ahem... :-) ) that already provides an ordering guarantee for |
I think Weld does that as well, so make it two :)
We would also need to define behavior for beans that have no priority which can be majority of them - so either say those are undefined or enforce some secondary level sorting. |
is there a reason why they both choose the descending order ? If there is one, it might be good context to ground a decision here ! Also admitting it is decided to enforce a secondary level sorting based on let's say the bean name in alphabetical order, |
I think it just follows the way you treat
FTR, the way Weld does that is to state that all beans without explicit priority have it set to 0. |
Ah, totally forgot. Thanks!
Yeah, good point. Defaulting to |
FTR there was https://issues.redhat.com/browse/CDI-535.
Both ArC and Weld IMO use this default.
@rmanibus I'm not quite sure I understand this paragraph. In any case, given the fact that the ordering is currently undefined the users should not rely on any ordering at all (unless using a specific implementation). In other words, it's not a breaking change. |
That issue does raise a point that I was thinking about: in some circumstances For example, it applies a priority to an alternative producer method defined in that class. (It also sets the priority of an interceptor, but I don't see that overlapping). I guess I also had a think about how a user might accomplish the task of declaring an order on their beans without adding anything to the specification:
|
In 4.1 we allowed
Fair enough, we should look around.
Similarly to Weld, you could have a method in
If you consume the stream, you can apply any custom filtering (obviously with metadata accessible from the
This sounds familiar; I think we discussed this in the past and decided against it. That'd imply that all beans have some non-null priority. |
Sorry, I didn't word that suggestion very clearly. The use case put forward was that the user is gathering all existing instances (presumably of a particular interface) and processing them in order. I'm suggesting the user adds a |
Yes, but that's the downside of this approach - you need to instantiate all beans before the ordering happens which is not always practical. |
Right, I see. |
Is your feature request related to a problem? Please describe.
The current ordering of both iterator and stream of an Instance is undefined in the CDI specification.
Use case: an extension is gathering all existing instances to apply a side effect (for example to build a message transformation chain), and the ordering matter.
Describe the solution you'd like
A clear and concise description of what you want to happen.
The specification could make sure that the Priority order is respected when iterating over instances
The text was updated successfully, but these errors were encountered: