[cdi-dev] [JBoss JIRA] Commented: (CDI-7) Section 10.2, bullet 3, first paragraph contradicts the rest of the section
Marius Bogoevici (JIRA)
jira-events at lists.jboss.org
Mon May 9 16:37:18 EDT 2011
[ https://issues.jboss.org/browse/CDI-7?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12600815#comment-12600815 ]
Marius Bogoevici commented on CDI-7:
------------------------------------
I think that we should go with "observer qualifiers must be a subset of event qualifiers". We follow the same logic on injection (a bean that has a superset of injection point's qualifiers is a match) and interceptor bindings (an interceptor that has a superset of the interceptor bindings qualifiers is a match), and cannot see why we cannot go with the same logic here.
I tend to think of events being "injected" into observer methods so I find it very easy to reason that a @Red @Plastic Foobar is at the same time a @Red Foobar and a @Plastic Foobar so I can observe both:
void doWith(@Red Foobar) "handle all foobars which are red"
void doWith(@Plastic Foobar), "handle all foobars which are made of plastic"
Incidentally, I believe that this promotes better separation of concerns, as each qualifier may presumably express a different quality of the event being observed (so what I do because the event is @Red may be completely orthogonal to what I do because the event is @Plastic), much better than:
void doWith(@Red @Plastic Foobar) observing both @Red Foobar and @Plastic Foobar
Also, we need to consider what happens when the model gets extended. Suppose that someone adds an additional qualifier to the event model - for example @Price(EXPENSIVE) as opposed to @Price(CHEAP) and adds that to the fired events. If we followed the "observer qualifiers must be a superset of event qualifiers" then all the current observers would have to be changed to adapt to this, and I can't see a reason why they should.
In a nutshell, I believe that "observer qualifiers must be a subset of event qualifiers" is more intuitive and promotes better separation of concerns.
> Section 10.2, bullet 3, first paragraph contradicts the rest of the section
> ---------------------------------------------------------------------------
>
> Key: CDI-7
> URL: https://issues.jboss.org/browse/CDI-7
> Project: CDI Specification Issues
> Issue Type: Bug
> Components: Events
> Affects Versions: 1.0
> Reporter: Pete Muir
> Priority: Blocker
> Fix For: 1.1 (Proposed)
>
>
> "The observer method has all the event qualifiers."
> This contradicts the examples (section 10.2.3) and the use of @Any, all of which indicate that less specific observer methods are also invoked.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the cdi-dev
mailing list