1 Reply Latest reply on Oct 10, 2011 4:45 PM by Mylos Kathos

    Beginner first steps with Qualifier

    Mylos Kathos Master

      Hi all,
      I'm studying a tutorial which covers CDI qualifier. In such a case where I have 2 ItemDao and 1 ItemProcessor:




      ItemDao Interface
      |              |
      ItemDao1     ItemDao2
                   @Demo
      
      
      ItemProcessor
      @Inject @Demo





      What's the advantage of using CDI qualifiers over standard Java Polymorphism ?
      For example I could simply have (without Qualifiers)




      public class ItemProcessor {
          
         ItemDao dao;
      
         if (condition1) dao=new ItemDao1();
         if (condition2) dao = new ItemDao2();
      }





      So the main benefit of using qualifiers if to push the polymorphism outside of the business class (ItemProcessor)? Forgive me if the question is too basic!
      Thanks
      Mylos