4 Replies Latest reply: Jun 26, 2012 4:34 PM by Michael Anstis RSS

    Look up beans with qualifier with value members

    Jervis Liu Apprentice

      Hi, I have a use case in which I need to look up beans on the client side using qualifier. The qualifier has value members. I defined qualifier annotation like below:




      @Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})

      public @interface NameToken {

          String value();



      Then I have NameToken on several Activity classes, for example:




      public class MyAdminAreaActivity implements Activity {




      When I use following code to look up Activity, I got a "

      Caused by: org.jboss.errai.ioc.client.container.IOCResolutionException: multiple matching bean instances for: org.drools.guvnor.client.mvp.Activity" exception.



              NameToken qual = new NameToken() {

                  public Class annotationType() {

                    return NameToken.class;




                  public String value() {

                      // TODO Auto-generated method stub

                      return placeRequest.getNameToken();






          for (Annotation a :qualifiers) {




          for (Annotation a : annotations) {




          return matchFrom.containsAll(matchTo);



      The matches method only checks if the IOCBean has same annotation name as the qualifier, but does not check the member value of the qualifier.

      I wonder if I am missing anything here or if there is alternative way to get this working? Thanks.