-
Notifications
You must be signed in to change notification settings - Fork 81
specification of reserves #874
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
Conversation
I'm not marking this as a draft, because I went through the entire specification and I believe I updated all relevant places. Reviewing that would of course be very much welcome :-) Similarly, any opinions on the open questions in the commit message (copied into the PR description) would also be very much welcome. |
Namingwise, "standby" really grates, not just because it's clumsy, but mostly because it is an adjective that is used here as a noun, where its counterparts, "stereotype" and "alternative", are both nouns. I understand why we can't use "default" and I understand that names are hard. Nevertheless, getting them right in specifications is really important. Maybe "backstop" (it's a noun, like alternative and stereotype; among its definitions is "something that bolsters")? "Exemplar" ("one that is typical or representative"; mild yuck)? "Template" (not quite right, overloaded meaning, but captures the "starting point" nature of the issue)? |
Standby is also a noun, see https://en.wiktionary.org/wiki/standby and many other places. I'm not saying I like it a lot, but I like it a lot more than all other things I could come up with, including "default bean". |
I am aware we have As for proposed names - "Template" I agree is too overloaded to convey clear meaning and "Exemplar" is too close to saying its an "example bean" which is IMO not the case. |
If we didn't have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the draft @Ladicek!
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanBuilder.java
Outdated
Show resolved
Hide resolved
(Still hung up on naming.) What if they were called "backing beans"? |
That's kind of what I tried suggesting with |
I'll keep thinking. Another problem I have with "standby" is that it sounds like something that could be energized or activated or enabled or switched on at any point for any reason, which isn't really what this is. This is a default—something that is used when other options don't exist or can't work—but we just can't use that word. Another requirement the name has, if we're trying to keep the spirit of the specification, is something that answers the question, "What kind of bean is this?" (A managed bean, a producer bean, an alternative bean, a synthetic bean….) So I agree with you that in general |
What about "failsafe" (as a noun)? Something that keeps the system from breaking when (in this case) nobody else supplied The Thing That Was Supposed To Be There? Then you can talk about failsafes and alternatives in the same sorts of sentences. |
Failsafe is way too close to fallback (fault tolerance) IMO; it is another "overloaded" term. BTW is there a reason why you don't like |
OK; I think we agree to disagree on this particular one.
Understood. Backfill has connotations of uselessness. It is the stuff—usually material unsuitable for any other purpose—you put back in a hole you just dug. |
Fair enough,
That's the noun meaning, but as a verb it should mean:
Which is what brought my attention to it. |
Right; I understand. You asked if there was something wrong with it and the noun version is definitely problematic and its bad connotations would occur to native speakers relatively quickly. Put as slang: it leaves a slightly bad taste in the mouth. |
Two words that fit that definition fairly closely are "prototype" and "archetype". ("Archetype" feels more like "example", but something that is a "prototype" can be a thing that makes copies of itself (not how it would be used here), or a default that could be used or extended.) Example: an archetypal frob is a frob that stands on its own and serves as a worthy example to emulate or override if you wanted, but it's by definition good on its own. Seems pretty close. Another example: a prototypical frob is a frob that represents an average frob distilled from other frobs out in the world that might impose variations on the prototype. Also sounds pretty close. A prototype is also something that typically could benefit (and maybe should benefit) from some improvement (i.e. users could supply their own) but could be relied on as-is if there's nothing better. That sounds pretty close. |
I'd personally not use prototype, because it is a Spring scope that is very similar to (but not exactly the same as) Overall, it is my opinion that the best words (default or fallback) cannot be used, so we gotta settle with something slightly awkward. To me, standby or backfill sound reasonable, as well as spare or reserve. I might also be fine with last resort, but with the ability to use priorities, certain "last resorts" wouldn't really be "last" :-) |
How about |
I would prefer a single word that goes well with "bean". If you have to add "bean" to the term itself, you declare defeat :-) |
How about |
|
I really like "Reserve" - something kept back unless it is needed. In some ways it's better than "Default" because having more than one reserve makes sense whereas having more than one default doesn't. The typesafe resolution steps would then be:
Reading that back, it makes intuitive sense to me. I'm ok with "Standby" but it has a bit more of a connotation of something ready and waiting to take over a responsibility if something goes wrong, which isn't quite how this feature would work. |
Ooh, I very much like reserve. Certainly much, much better than standby. Well done. |
@manovotn any thoughts about reserve? :-) |
I think there were better options but reserve is good enough for me. |
@manovotn raised an interesting question on the call today: what about alternative beans declaring reserve producers / reserve beans declaring alternative producers? Have to think more about it, but it feels wrong on the first sight and should probably be a definition error. |
Certainly I am not defending the practice, but my immediate thought was: well, this is ugly and asking for trouble, but it probably should be permitted in some way. What leads you to think it would have to be illegal? |
I'm not saying it has to be illegal. I'm saying it should be illegal, because it's probably a user error. |
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/StereotypeInfo.java
Outdated
Show resolved
Hide resolved
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanBuilder.java
Outdated
Show resolved
Hide resolved
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanBuilder.java
Show resolved
Hide resolved
api/src/main/java/jakarta/enterprise/inject/spi/Prioritized.java
Outdated
Show resolved
Hide resolved
. The container eliminates all eligible beans that are reserves. | ||
. If there is exactly one bean remaining, the container selects this bean, and the ambiguous dependency is called resolvable. | ||
. Otherwise, if there is no bean remaining and all eligible beans are reserves, then: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weld doesn't have this concept yet.
However, when a container deals with ambig. dependency, you have a view of all eligible beans and you can shuffle them freely to figure it out. So technically speaking there is no issue with the algorithm, it's more a matter of a reformulating it to remove the "wait...what?!" effect when you first read it :)
Perhaps it would be enough to not talk about eliminating the beans? So the first sentence would be something like this:
The container first considers all eligible beans that are not reserves.
api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/BeanInfo.java
Outdated
Show resolved
Hide resolved
Added an extra commit (to be squashed if agreed upon) that makes it impossible for alternatives (resp. reserves) to declare reserve (resp. alternative) producers. |
cf27d41
to
126f11b
Compare
Just FYI, my force-pushes recently didn't change anything in this PR, I just rebased on latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the PR is in a good shape and I am +1 for merging it (after squashing the two commits OFC).
I think it's safe to say we have agreed of the concept, naming and general way of functioning by now.
We can still polish it later if there are any suggestions/objections as there is time until full release. It would be neat to have this in time for M1 though.
I agree, so I squashed the two commits. It is my firm belief that alternatives declaring reserve producers and reserves declaring alternative producers is meaningless and should be forbidden. If someone ever comes with a meaningful, well, meaning, we can reconsider. |
One more thing: if we allowed alternatives to declare reserve producers (this doesn't apply to reserves declaring alternative producers, but we probably want these to be symmetric), we would have to adjust the ambiguity resolution algorithm, because currently, the algorithm has to remove all beans except alternatives and producers declared by alternatives. These producers currently cannot be reserves, but if they could be, the algorithm would have to eliminate those as well. |
Moved back to draft because we need #902 merged first. |
Done. |
Last call for comments :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One grammar thing that bothers me but isn't important. I'm otherwise happy with it.
Thanks.
Reserves are the opposite of alternatives: where alternatives take precedence over non-alternatives, non-reserves take precedence over reserves. This pattern has classically been known as "default beans", but that is a bad name (consists of two words, both of them being used in the specification already). In this commit, reserves can only be selected for application, they cannot be selected just for a bean archive (in `beans.xml`). Perhaps this will have to change, but present state should be good enough for now. Similarly, reserve producers currently do not inherit priority from their declaring beans, which perhaps will have to change (for the sake of consistency), but present state should be good enough for now.
Reserves are the opposite of alternatives: where alternatives take precedence over non-alternatives, non-reserves take precedence over reserves. This pattern has classically been known as "default beans", but that is a bad name (consists of two words, both of them being used in the specification already).
In this commit, reserves can only be selected for application, they cannot be selected just for a bean archive (in
beans.xml
). Perhaps this will have to change, but present state should be good enough for now. Similarly, reserve producers currently do not inherit priority from their declaring beans, which perhaps will have to change (for the sake of consistency), but present state should be good enough for now.Resolves #871