[cdi-dev] [JBoss JIRA] (CDI-248) Provide means to observe a group of qualified events ("Qualifier Inheritance"?)

Pete Muir (JIRA) jira-events at lists.jboss.org
Thu Aug 2 13:13:07 EDT 2012


     [ https://issues.jboss.org/browse/CDI-248?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pete Muir updated CDI-248:
--------------------------

    Fix Version/s: TBD

    
> Provide means to observe a group of qualified events ("Qualifier Inheritance"?) 
> --------------------------------------------------------------------------------
>
>                 Key: CDI-248
>                 URL: https://issues.jboss.org/browse/CDI-248
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Concepts, Events
>            Reporter: Jens Schumann
>             Fix For: TBD
>
>
> We have been using CDI events for application development quite extensively. For instance we use events to propagate entity lifecycle events (@Created/@Updated/@Deleted Customer customer) or GUI selections (@Selected/@Deselected Customer customer) and implement related business logic in event observers. (e.g. send email for newly created customers, clear cached values on select/deselect/create/update/delete ...).
> This works quite well, however we have noticed that especially our JSF Presentation Tier contains lots of observer methods implementing the same behavior for a group of related CDI events. 
> Example:
> {code}
> public class XyzBean {
>  public void onCustomerCreate(@Observes @Created Customer customer) { reset();} 
>  public void onCustomerUpdate(@Observes @Updated Customer customer) { reset();} 
>  public void onCustomerDelete(@Observes @Deleted Customer customer) { reset();}
>  
> }
> {code}
> Looks ugly, doesn't it? 
> The above example could be improved if CDI would be able to observe a group of qualified events, e.g. public void onCustomerLifeCycleEvent(@Observes @LifeCycleChange Customer customer) { reset(); } - ignore method and qualifier names for now.
> Since Java does not support annotation inheritance grouping could be achieved using "qualified qualifier annotations": 
> {code}
> @Qualifier
> public @interface LifeCycleChange
> @Qualifier
> @LifeCycleChange
> public @interface Created
> @Qualifier
> @LifeCycleChange
> public @interface Updated
> @Qualifier
> @LifeCycleChange
> public @interface Deleted
> @Qualifier
> public @interface SelectionChange
> @Qualifier
> @SelectionChange
> public @interface Selected
> @Qualifier
> @SelectionChange
> public @interface Deselected
> {code}
> WDYT? Side effects? Problems? 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the cdi-dev mailing list