title: Is Spring @autowired not meant for non-singleton containers?
body: <p>I have a <code>MyTask</code> class which implements <code>Runnable</code> and there can be many such objects instantiated at any given moment. There are certain properties that I would like to autowire into <code>MyTask</code> class.</p>
  
  <p>But I <em>think</em> that if I mark <code>MyTask</code> with <code>@Component</code> then it will become a spring-managed singleton correct? That's not what I want, I need many independent instances of this class to be run by a TaskExecutor.</p>
  
  <p>So my question(s):</p>
  
  <ul>
  <li>a) Am I fundamentally wrong in my understanding of <code>@Component</code> annotation? Does it NOT make <code>MyTask</code> into a spring-managed singleton?</li>
  <li>b) Is there some other annotation I should use so that spring detects <code>@Autowired</code> and injects the property?</li>
  <li>c) Is spring autowiring not meant for non-singleton containers/classes like <code>MyTask</code>?</li>
  </ul>
  
  <hr>
  
  <p>Update # 1 - These don't work:</p>
  
  <pre><code>public class MyTask implements Runnable { // I want this class to be non-singleton
      @Autowired
      public SomeSpecialSpringConfiguredConnectionClass blah; // this is the singleton bean that should be injected
      @Override
      public void run() {
          // BLAH IS NULL, this shouldn't be NULL, that is not what I want
          // which makes sense considering Spring never knew it had to work
          // on this class
      }
  }
  
  @Component
  public class MyTask implements Runnable { // I want this class to be non-singleton
      @Autowired
      public SomeSpecialSpringConfiguredConnectionClass blah; // this is the singleton bean that should be injected
      @Override
      public void run() {
          // this works BUT now MyTask is singleton :(
      }
  }
  
  @Component
  @Scope("prototype")
  public class MyTask implements Runnable { // I want this class to be non-singleton
      @Autowired
      public SomeSpecialSpringConfiguredConnectionClass blah; // this is the singleton bean that should be injected
      @Override
      public void run() {
          // BLAH IS NULL, again ... this shouldn't be NULL, that is not what I want
      }
  }
  </code></pre>
  
  <hr>
  
  <p>Update # 2 - While waiting for some more suggestions on how to do it the easy way, I'm looking into: <code>Using AspectJ to dependency inject domain objects with Spring</code> as an alternative.</p>