Hi guys, hopefully this it the right forum for this question about Weld and CDI... It's runing on AS6 with Weld 1.1.2.Final.
I want to dynamically provide the qualifier on a CDI event to be fired. With qualifiers without members, this works as the docs say:
{code}
public void fireEvent(AnnotationLiteral<?> eventQualifier){
event.select(eventQualifier).fire("FIRED");
}
{code}
called by
{code}
dynamicEventFirer.fireEvent(new AnnotationLiteral<MyCustomQualifier>() {});
{code}
All good. However, how can I call the method when the qualifier I want to pass has members? I've tried like this:
{code}
// The qualifier
@Qualifier
@Retention(RUNTIME)
@Target({METHOD, FIELD, PARAMETER, TYPE})
public @interface Type {
TypeEnum value();
}
...
// The firing code, elsewhere
dynamicEventFirer.fireEvent(new AnnotationLiteral<
MyCustomMemberQualifier
>() {
public MyMemberEnum value() {
return
MyMemberEnum
.VALUE_A;
}
});
{code}
but I receive the exception
{code}
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)
{code}
MemberQualifierEventManager is the class calling the method.
Can anyone shed some light on where my syntax is wrong?
Thanks,
Ben