title: How to create a single instance of object across entire Spring MVC web application?
body: <p>I have a Spring MVC web application (XML based without annotations). I want to create only one instance of <strong>statsDClient</strong> object on start of my application and use it across my whole application. I am trying something like below:</p>
  <pre><code>import com.timgroup.statsd.NonBlockingStatsDClient;
  import com.timgroup.statsd.StatsDClient;
  
  Public class Helper(){
  
  private static final StatsDClient statsDClient = new NonBlockingStatsDClient(&quot;prefix&quot;, &quot;localhost&quot;, 8125);
  private Helper(){}
   public static StatsDClient getInstance() {
        return statsDClient;
      }
  }
  
  </code></pre>
  <p>Later in my controllers I am getting the <strong>statsDClient</strong> object in the following way:</p>
  <pre><code>public class HelpController extends AbstractController {
  private StatsDClient statsDClient = Helper.getInstance();
  protected ModelAndView handleRequestInternal(
              HttpServletRequest request,
              HttpServletResponse response) throws Exception {
  statsDClient.someMethod();
  }
  </code></pre>
  <p>But, this seems to be creating creating a new <strong>statsDClient</strong> object everything I use it in different controllers. Can you please guide where am I going wrong?</p>