title: How to use CDI qualifiers with multiple class implementations?
body: <p>I'm new in Java EE/JSF and now read about CDI qualifiers - the possibility to change class implementation. This is great but I have got one question. As far as I understand I can change class implementation using qualifier but I need to change it everywhere I use this implementation. What is the best solution to do it in one place? With my small knowledge about Java EE I figured out this one.</p>
  
  <p>Lets imagine that we are creating simple Calculator application. We need to create few classes:</p>
  
  <ol>
  <li><code>Calculator</code> (basic implementation of calculator)</li>
  <li><code>ScientificCalculator</code> (scientific implementation of calculator)</li>
  <li><code>MiniCalculator</code> (with minimum potentiality)</li>
  <li><code>MockCalculator</code> (for unit tests)</li>
  <li>Qualifier <code>@Calculator</code> (will indicate to the actual implementation of calculator; should I create qualifier for each implementation?)</li>
  </ol>
  
  <p>Here is the question. I've got four implementations of calculator and I want to use one of them in few places but only one at time (in the initial project phase I will use <code>MiniCalculator</code>, then <code>Calculator</code> and so on). How can I change implementation without change code in every place where object is injected? Should I create factory which will be responsible for injecting and will work as <code>method injector</code>? Is my solution correct and meaningful?</p>
  
  <p>Factory</p>
  
  <pre><code>@ApplicationScoped
  public class CalculatorFctory implements Serializable {
      private Calculator calc;
  
      @Produces @Calculator Calculator getCalculator() {
          return new Calculator();
      }
  }
  </code></pre>
  
  <p>Class which uses Calculator</p>
  
  <pre><code>public class CalculateUserAge {
      @Calculator
      @Inject
      private Calculator calc;
  }
  </code></pre>
  
  <p>Is this the correct solution? Please correct me if I'm wrong or if there is a better solution. Thanks!.</p>