Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-271

Provide a way to inject Event metadata into an observer method

    Details

    • Type: Feature Request
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 1.1.PFD
    • Component/s: Events
    • Labels:
      None

      Description

      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:

      @Inject @MyQualifier
      Event<MyObject> event;
       
      public void fireEvent(MyObject object, MyTypeValue type) {
          event.select(new MyTypeAnnotationLiteral(type)).fire(object);
      }
      

      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:

      public void observeEvent(@Observes @MyType MyObject object, InjectionPoint ip) {
          MyType annotation = ip.getAnnotated().getAnnotation(MyType.class);
          MyTypeValue value = annotation.value();
          ...
      }
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  arnelim Arne Limburg
                  Reporter:
                  arnelim Arne Limburg
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  9 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: