title: Spring Injection & Globally initialized objects
body: <p>I have a spring injected service </p>
  
  <pre><code> class A{
        List l = new ArrayList();
  
        public m1(){
             //do some additions in list 
        }
  
        public m2(){
             //do some new additions in list
        }
   }
  </code></pre>
  
  <p>Now because creating of objects of <code>A</code>, is in the hands of spring the behavior of program is not what is expected. (I expect list to be available empty always but not initialized by methods for some wired reason)</p>
  
  <p>Will Spring always create only one instance of <code>A</code>, so that list <code>l</code> will keep on growing, I have configured bean as singleton in application context.</p>
  
  <p>If yes, naturally I must initialize the list inside the functions <code>m1</code> &amp; <code>m2</code> or callee must past the reference, and in my case callee being struts2 actions they are not singleton so this issue can be solved?</p>
  
  <p>Or </p>
  
  <p>Does spring provide any support in configuration to initialize member variables at every call or something else?</p>
  
  <p>More generally what are best practices to have in writing services injected by spring about using member variables/ local variables for performance &amp; efficiency.</p>