title: How can I inject a bean into an ApplicationContext before it loads from a file?
body: <p>I have a <code>FileSystemXmlApplicationContext</code> and I would like the beans defined in the XML to take as a constructor argument a bean which is not declared in Spring</p>
  
  <p>For example, I would like to do:</p>
  
  <pre><code>&lt;bean class="some.MyClass"&gt;
      &lt;constructor-arg ref="myBean" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>So I could imagine doing this via something like:</p>
  
  <pre><code>Object myBean = ...
  context = new FileSystemXmlApplicationContext(xmlFile);
  context.addBean("myBean", myBean); //add myBean before processing
  context.refresh();
  </code></pre>
  
  <p>Except that there is no such method :-( does anyone know how I can achieve this?</p>