title: How to run method within controller from external controller
body: <p>I have a controller class : </p>
  
  <pre><code>@Controller
  public class MyController {
  
  @AutoWired
  Service myservice
  
  @RenderMapping
  public display(){
      //do work with myservice
  }
  
  }
  </code></pre>
  
  <p>I want to invoke the method display() from an external class but I am a null pointer exception.</p>
  
  <p>Here is how I am invoking the display method from an external class :</p>
  
  <pre><code>new MyController.display()
  </code></pre>
  
  <p>But the instance myservice is being set to null.</p>
  
  <p>How can I invoke MyController.display() and ensure the instance of myservice is not set to null ?</p>
  
  <p>I think the problem is since I am creating a new instance of the controller the service is then not autowired ? But since the Spring controllers are singletons perhaps I can get access to the current instance of the controller ?</p>
  
  <p>Update : </p>
  
  <p>The reason I am trying this is I'm adding a config option to determine which controller display method should be implemented. Perhaps I should be using a super controller to determine which controller should be implemented ?</p>