2 Replies Latest reply on Dec 1, 2011 8:53 PM by Andrew Hughes

    Programmatic Lookup with incomplete Qualifiers

    Andrew Hughes Newbie

      Hi Again,

      I'm stuck and need help. If I have the following Qualified bean...

      public class SuperManBean implements SuperHeroAlterEgo<SuperMan> {}


      How can I programmatically lookup SuperManBean with either the String ClarkKent OR superHero.getClass(), which is of course SuperMan.

      My Broken Code...

      I have tried to lookup by NameLiternal only (I can't provide a SuperHeroTypeLiteral here)

      @Inject @Any Instance<SuperHeroAlterEgo<SuperHero>> source;
      source.select(new NamedLiteral("ClarkKent")); //and similar for 

      I have also tried by new SuperHeroTypeLiteral(superHero.getClass()) only - I dont have a NamedLiternal here

      @Inject @Any Instance<SuperHeroAlterEgo<SuperHero>> source;
      source.select(new SuperHeroTypeLiteral(superHero.getClass())); //and similar for 

      But both have unsatisfied dependencies. Seems that you need both qualifiers no @Any and nothing else :'(

      Help would be excellent :)