[cdi-dev] [JBoss JIRA] (CDI-271) Provide a way to inject Event metadata into an observer method

Arne Limburg (JIRA) jira-events at lists.jboss.org
Sun Jan 13 05:59:22 EST 2013


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

Arne Limburg edited comment on CDI-271 at 1/13/13 5:59 AM:
-----------------------------------------------------------

Just saw, that the second part is already clarified :)
So we only have to add a bullet point to 5.5.7 like
{quote}An instance of InjectionPoint may represent:
...
- An Event obtained dynamically using Event.select(...).{quote}

and this issue can be closed.
                
      was (Author: arnelim):
    Just saw, that the second part is already clarified :)
So we only have to add a bullet point to 5.5.7 like
"An instance of InjectionPoint may represent:
...
- An Event obtained dynamically using Event.select(...)."

and this issue can be closed.
                  
> Provide a way to inject Event metadata into an observer method
> --------------------------------------------------------------
>
>                 Key: CDI-271
>                 URL: https://issues.jboss.org/browse/CDI-271
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Events
>            Reporter: Arne Limburg
>             Fix For: 1.1 (Proposed)
>
>
> Currently there is no way for observer methods to access the qualifiers of the fired event (i.e. to access @Nonbinding members).
> Consider the following example:
> {code}
> @Inject @MyQualifier
> Event<MyObject> event;
> public void fireEvent(MyObject object, MyTypeValue type) {
>     event.select(new MyTypeAnnotationLiteral(type)).fire(object);
> }
> {code}
> Currently no observer can receive the value of MyTypeValue. I suggest to introduce an interface AnnotatedEvent that extends Annotated and contains this information. It then could be injected via the InjectionPoint like this:
> {code}
> public void observeEvent(@Observes @MyType MyObject object, InjectionPoint ip) {
>     MyType annotation = ip.getAnnotated().getAnnotation(MyType.class);
>     MyTypeValue value = annotation.value();
>     ...
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the cdi-dev mailing list