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

Mark Struberg (JIRA) jira-events at lists.jboss.org
Sun May 8 06:31:18 EDT 2011


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

Mark Struberg edited comment on CDI-4 at 5/8/11 6:31 AM:
---------------------------------------------------------

huh, just realized that I could do the 2nd code block even more elegantly:

{code}
public void checkSecurity(@Observes MyEvent me, @Secured Event<MyEvent> securedEventSource) {
  checkSecurity();
  securedEventSource.fire(me);
}
{code}

The trick here is that any observer method can have additional injection points as parameters which will get resolved by the container automatically ...

      was (Author: struberg):
    huh, just realized that I could to the 2nd code block even more elegantly:

{code}
public void checkSecurity(@Observes MyEvent me, @Secured Event<MyEvent> securedEventSource) {
  checkSecurity();
  securedEventSource.fire(me);
}
{code}

The trick here is that any observer method can have additional injection points as parameters which will get resolved by the container automatically ...
  
> 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: Mike 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