title: Spring: how to instantiate a Spring bean that takes a runtime parameter?
body: <p>I've got a singleton Spring bean that creates a couple of tasks (<code>java.util.concurrent.Callable</code>'s) at runtime to do its work in parallel. Right now, the <code>Callable</code>'s are defined as inner classes in the singleton bean, and the singleton bean creates them simply by instantiating them with <code>new Task(in)</code>, where <code>in</code> is a parameter known only at runtime.</p>
  
  <p>Now I want to extract the inner Task class to a regular top-level class because I want to make the Task's <code>call()</code> method transactional, so I need it to be a Spring bean.</p>
  
  <p>I guess I need to give my singleton some kind of factory of <code>Task</code>s, but the tasks have to be prototype Spring beans that take a runtime value as a constructor parameter. How can I accomplish this?</p>