[cdi-dev] [JBoss JIRA] Commented: (CDI-4) Need a way to provide ordering for Event observers (@Observes)

Christian Sadilek (JIRA) jira-events at lists.jboss.org
Sat May 7 17:35:18 EDT 2011


    [ https://issues.jboss.org/browse/CDI-4?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12600514#comment-12600514 ] 

Christian Sadilek commented on CDI-4:
-------------------------------------

I'd prefer the more expressive approach using @Before and @After over the simpler approach using salience/priority values. 

However, I'd like to suggest having the ordering specified on the observer methods rather than on the event parameters. That is to have a separation of concerns between event qualifiers and observer ordering. I think this would further increase readability:

{code}
public class MyBean

	public void myFirstObserver(@Observes @A @B MyEvent event) {
	   ...
	}

	@After({A.class, B.class})
	public void mySecondObserver(@Observes @A @B @C MyEvent event) {
	   ...
	} 
}
{code}

> Need a way to provide ordering for Event observers (@Observes)
> --------------------------------------------------------------
>
>                 Key: CDI-4
>                 URL: https://issues.jboss.org/browse/CDI-4
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Events, Portable Extensions
>    Affects Versions: 1.0
>         Environment: All
>            Reporter: Lincoln Baxter III
>            Assignee: Christopher Brock
>             Fix For: TBD
>
>
> There needs to be a way to specify some kind of ordering for Event observers. 
> Understandably, this is somewhat counter-intuitive to the general concept of observing an event, but there is going to be need for this in an upcoming JBoss project. While it can be done manually, it might be nice to have a built-in API.

--
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