title: What's the best pattern for injecting a bean with arguments?
body: <p>I have a number of cases in my app where client code wants to create a bean on-demand. In each case, the bean has 1 or 2 constructor arguments which are specified by the client method, and the rest are autowired.</p>
  
  <p>Ex:</p>
  
  <pre><code>//client code
  MyQuery createQuery() {
      new MyQuery(getSession())
  }
  
  //bean class I want to create
  //prototype scoped
  class MyQuery {
      PersistenceSession session
      OtherBeanA a
      OtherBeanB b
      OtherBeanC c
  }
  </code></pre>
  
  <p>I want A, B, and C to be autowired, but I have the requirement that 'session' has to be specified by the calling code. I want a factory interface like this:</p>
  
  <pre><code>interface QueryFactory {
      MyQuery getObject(PersistenceSession session)
  }
  </code></pre>
  
  <p>What's the most efficient way to wire up the factory? Is it possible to avoid writing a custom factory class that does <code>new MyQuery(...)</code>? Can ServiceLocatorFactoryBean be used for something like this? </p>