title: How do you inject an object into a singleton?
body: <p>I've got a singleton class:</p>
  
  <pre><code>public class Widget
  {
      private Mapper mapper;
  
      private static Widget SINGLETON;
  
      private Widget(Mapper map)
      {
          setMapper(map);
      }
  
      public Widget getInstance()
      {
          if(SINGLETON == null)
              SINGLETON = new Widget(???);
  
          return SINGLETON;
      }
  }
  </code></pre>
  
  <p>Not only do I not understand how to pass <code>SINGLETON</code> a <code>Mapper</code> in its private constructor, I'm not seeing how I can use dependency injection to properly set the singleton up. Say <code>Mapper</code> is an interface. Perhaps under "normal" execution I want to pass <code>SINGLETON</code> a <code>StandardMapper</code> instance, but while unit testing, I want to pass it a <code>MockMapper</code>.</p>
  
  <p>Thanks in advance for any pointers!</p>