title: Getting Spring IOC to work with the MVP pattern
body: <p>I'm attempting to use the <a href="http://en.wikipedia.org/wiki/Model-view-presenter" rel="nofollow noreferrer">MVP</a> design pattern with a Swing application in conjunction with Spring IOC. In MVP the View needs to pass itself into the Presenter, and I can't work out how to do this with Spring.</p>
  
  <pre><code>public class MainView  implements IMainView {
  
      private MainPresenter _presenter;
  
      public MainView() {
  
          _presenter = new MainPresenter(this,new MyService());
  
         //I want something more like this
         // _presenter = BeanFactory.GetBean(MainPresenter.class);
  
      }
  
  }
  </code></pre>
  
  <p>This is my config xml (incorrect)</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;bean id="MainView" class="Foo.MainView"/&gt;
  &lt;bean id="MyService" class="Foo.MyService"/&gt;
  
  &lt;bean id="MainPresenter" class="Foo.MainPresenter"&gt;
      &lt;!--I want something like this, but this is creating a new instance of View, which is no good--&gt;
     &lt;constructor-arg type="IMainView"&gt;
          &lt;ref bean="MainView"/&gt;
      &lt;/constructor-arg&gt;
      &lt;constructor-arg  type="Foo.IMyService"&gt;
          &lt;ref bean="MyService"/&gt;
       &lt;/constructor-arg&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>How do I get the View into the Presenter?</p>