title: Can I force a grails dev server to reload when any code recompiles?
body: <p>The short question is: can I force the Grails 2.2 dev server to reload (reinitializing all singleton services, etc) whenever new code is hot-compiled and swapped in?</p>
  
  <p>Let me make the question clear with an example. Let's say that </p>
  
  <ol>
  <li><p>I have a singleton-scoped service called <code>MyService</code>. In its <code>@PostConstruct</code> function, it initializes a new object of type <code>Helper</code> (and holds on to the reference).</p></li>
  <li><p>I <code>run-app</code> in dev mode, test things out, and then...</p></li>
  <li><p>I edit the source code for <code>Helper.groovy</code></p></li>
  </ol>
  
  <p>What happens next is:</p>
  
  <ul>
  <li>Grails automatically recompiles <code>Helper.groovy</code></li>
  <li>Grails swaps the new code into the running dev server</li>
  <li>But the new <code>Helper</code> code isn't <strong>called</strong> because the already-instantiated <code>MyService</code> object already has a handle on an instance of the old kind.</li>
  </ul>
  
  <p>My current workaround  is to <em>keep a <strong>dependency graph in my head</strong>, and <code>touch</code> or trivially modify <code>MyService</code> every time I change one of its dependencies</em>.  But I'd much rather force the dev server to reload completely whenever new code is swapped in.</p>
  
  <p>So... <strong>is it possible to force the dev server to reload whenever any code changes</strong>?</p>
  
  <p>And a <strong>bonus question</strong>: when I change a Domain Object, the only way I can force the dev server to "follow" those changes is to <code>stop-app</code>, <code>clean</code>, and <code>run-app</code> manually.  Can I automate this to happen whenever it's required?</p>
  
  <p>Thanks!</p>