Add API for programmatic access to assignability rules for observer methods and typesafe resolution.#700
Conversation
api/src/main/java/jakarta/enterprise/inject/spi/BeanContainer.java
Outdated
Show resolved
Hide resolved
|
I think the current state is decent. I tried to improve it a little here: https://github.com/Ladicek/cdi-spec/commits/programmatic-assignability-access It's mainly about consistency and using terms defined by the CDI specification. |
I've added them here and, as the commit suggested, squashed them into my commit. |
|
Thanks! The only remaining question from me is: should we really expect users to correctly add implied qualifiers ( If I understand correctly, the rules for that are fairly simple. To all sets of qualifiers, the CDI implementation would:
That should be it I think? |
Right, that crossed my mind as well. |
|
Ah yeah, I always forget that the Looking at it more thoroughly, here are some additional thoughts.
|
a1c1c3f to
083c308
Compare
|
@Ladicek I have reworded the text so that it no longer requires users to specify all qualifiers explicitly. |
api/src/main/java/jakarta/enterprise/inject/spi/BeanContainer.java
Outdated
Show resolved
Hide resolved
api/src/main/java/jakarta/enterprise/inject/spi/BeanContainer.java
Outdated
Show resolved
Hide resolved
|
And could you please change the commit message? "Draft an API for ..." -> "Add API for ..." |
All of the comments should be addressed now. |
|
Commit message, not [just] PR title :-) |
|
Ah and we should mention these methods in the spec text, chapter Programmatic access to container ( |
|
I think something like this should be enough: ==== Assignability of beans and observers
The methods `BeanContainer.isMatchingBean()` and `isMatchingObserver()` provide access to assignability rules defined in <<typesafe_resolution>> and <<observer_resolution>>.
[source, java]
----
public boolean isMatchingBean(Set<Type> beanTypes, Set<Annotation> beanQualifiers, Type requiredType, Set<Annotation> requiredQualifiers);
public boolean isMatchingEvent(Type eventType, Set<Annotation> eventQualifiers, Type observedEventType, Set<Annotation> observedEventQualifiers);
---- |
Eeh, yea. Apparently it helps to save the changes when you perform them locally 🤦
That's good point. Will do! |
…r methods and typesafe resolution.
|
@Ladicek I've added the text to |
|
Since we agreed to include this feature in during last meeting, I am going to merge it. |
Fixes #498
There was a request to have access to CDI assignability rules programmatically so this is the first thing coming to my mind.
I am not 100% convinced that this feature is very useful (in that it can find some audience) so I would appreciate some feedback on whether we want to add it or not.
Few notes:
@Default- at least not the way it's worded right now as users are expected to list all required qualifiers.TypesAndQualifiersto also represent the event payload/qualifiers and injection point type/qualifiers but I somehow found it cleaner this way as the required type would always be a singleton set.