title: Strategy Pattern and Dependency Injection in Spring
body: <p>I have an <em>Strategy</em> interface, that is implemented by <em>StrategyA</em> and <em>StrategyB</em>, both of them are defined as <strong>@Component</strong>'s and they have an <strong>@Autowired</strong> attribute as well, how can I do to obtain an instance of one of them based on an String value?</p>
  
  <p>This is my Controller's action, that should perform the strategy:</p>
  
  <pre><code>@RequestMapping("/blabla")
  public void perform (@RequestParam String strategyName) {
      Strategy strategy = (Strategy) /* Get the concrete Strategy based on strategyName */;
      strategy.doStuff ();
  }
  </code></pre>
  
  <p>Thanks!</p>