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

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Major Major
    • 1.1.PFD
    • None
    • Events
    • None

      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();
          ...
      }
      

            arnelim Arne Limburg (Inactive)
            arnelim Arne Limburg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: