title: Autowiring based on method argument
body: <p>I have various protocols that my system is using. I mark an interface and provide appropriate implementations. For example <code>SSHprotocol</code> and <code>HttpProtocol</code> both implements <code>Protocol</code>. There may be multiple which I add in the future. Now I have a class as follows:-</p>
  
  <pre><code>class Test {
    @Autowired
    private Protocol protocol;
  
    public void getProtocol(String name) {
      return protocol;
    }
  }
  </code></pre>
  
  <p>The <code>getProtocol</code> should return a <code>Protocol</code> object based on the <code>Protocol</code> name. In short I want Spring to Autowire the specific bean based on name parameter.
  Does spring support this? I can have multiple <code>@Autowired</code> with corresponding Qualifiers. But that may make me to write 10-15 variables with corresponding Autowiring annotations. But that is too much of code making it difficult to manage. Factory may be an alternative but how will that solve my problem?</p>