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

Christopher Brock (JIRA) jira-events at lists.jboss.org
Sat May 7 13:48:18 EDT 2011


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

Christopher Brock edited comment on CDI-4 at 5/7/11 1:46 PM:
-------------------------------------------------------------

_This solution might introduce cycles in more complex scenarios_

True. But they're also extremely easy to detect by the container at bootstrap time. 

This solution has the same basic effect as a magic number solution to define salience. But the problem with magic numbers is that it suffers from an even worse readability problem than this. Especially if you have salience values for common events being declared in dynamically loaded modules -- say, like Seam Forge.

So in a Forge plugin, the plugin author would need to know the basal value, and then if coordinating with other plugins (a likely possibility in Forge) know _their_ basal values as well.

When you look at this solution in that scenario, it's much easier to resolve the issue.  

All you need to do is provide qualifiers that can then be referenced with {{@Before}} and {{@After}} from the plugins.

So, {{@After(BeanLoading.class) @Before(BeanDeploy.class)}} is a heck of a lot easier to document for and read than say something like {{@Salience(1.30f)}}.

 

      was (Author: cbrock):
    _This solution might introduce cycles in more complex scenarios_

True. But they're also extremely easy to detect by the container at bootstrap time. 

This solution has the same basic effect as a magic number solution to define salience. But the problem with magic numbers is that it suffers from an even worse readability problem than this. Especially if you have salience values for common events being declared in dynamically loaded modules -- say, like Seam Forge.

So in a Forge plugin, the plugin author would need to know the basal value, and then if coordinating with other plugins (a likely possibility in Forge) know _their_ basal values as well.

When you look at this solution in that scenario, it's much easier to resolve the issue.  

All you need to do is provide qualifiers that can then be referenced with @Before and @After from the plugins.

So, {{@After(BeanLoading.class) @Before(BeanDeploy.class)}} is a heck of a lot easier to document for and read than say something like {{@Salience(1.30f)}}.

 
  
> 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