Dynamically fire CDI event with qualifier with members

前端 未结 2 1711
猫巷女王i
猫巷女王i 2021-01-12 15:29

I\'m trying to use CDI events in my backend services, on JBoss AS6 - ideally with maximum code reuse.

I can see from the docs I can cut down on the qualifier annotat

2条回答
  •  生来不讨喜
    2021-01-12 15:41

    There's a slightly cleaner way to do it based on your post:

    public class TypeQualifier extends AnnotationLiteral implements Type{
    
    private TypeEnum type;
    
    public TypeQualifier(TypeEnum t) {
          this.type = t;
    }
    
    public TypeEnum value() {
        return type;
    }
    
    }
    

    then just fire like this:

    dynamicEventFirer.fireEvent(new TypeQualifier(TypeEnum.TYPEA));
    

提交回复
热议问题