3 Replies Latest reply on Aug 4, 2011 8:14 AM by Ben Kirby

    How to dynamically qualify a CDI event, when qualifier has members

    Ben Kirby Newbie

      Hi, I'm using Weld 1.1.2.Final and would like to dynamically provide the qualifier on a CDI event to be fired.

      With qualifiers without members, this works as the docs say:

      public void fireEvent(AnnotationLiteral<?> eventQualifier){

      called by

      dynamicEventFirer.fireEvent(new AnnotationLiteral<MyCustomQualifier>() {});

      All good. However, how can I call the method when the qualifier I want to pass has members? I've tried like this:

      // The qualifier
      public @interface MyCustomMemberQualifier {
          MyMemberEnum value();
      // The firing code, elsewhere
      dynamicEventFirer.fireEvent(new AnnotationLiteral<MyCustomMemberQualifier>() {
          public MyMemberEnum value() {
              return MyMemberEnum.VALUE_A;

      but I receive the exception

      java.lang.RuntimeException: class uk.co.jam.concept.events.MemberQualifierEventManager$1 does not implement the annotation type with members uk.co.jam.concept.events.Type
          at javax.enterprise.util.AnnotationLiteral.getMembers(AnnotationLiteral.java:69)
          at javax.enterprise.util.AnnotationLiteral.hashCode(AnnotationLiteral.java:281)
          at java.util.HashMap.getEntry(HashMap.java:344)
          at java.util.HashMap.containsKey(HashMap.java:335)
          at java.util.HashSet.contains(HashSet.java:184)
          at org.jboss.weld.util.Beans.mergeInQualifiers(Beans.java:939)
          at org.jboss.weld.bean.builtin.FacadeInjectionPoint.<init>(FacadeInjectionPoint.java:29)
          at org.jboss.weld.event.EventImpl.selectEvent(EventImpl.java:96)
          at org.jboss.weld.event.EventImpl.select(EventImpl.java:80)
          at uk.co.jam.concept.events.DynamicEventFirer.fireEvent(DynamicEventFirer.java:20)

      MemberQualifierEventManager is the class calling the method. Can anyone shed some light on where my syntax is wrong?