title: When is contextDestroyed called?
body: <p>Having implemented a <code>ContextListener</code> I can now happily deal with <code>contextDestroyed</code> events by closing down my connection pools and flushing my caches etc.</p>
  
  <p>I was surprised recently when <code>contextDestroyed</code> was called at a time when my server was not being shut down - it seemed to be at some arbitrary time which I have not been able to track down.</p>
  
  <p>Is there any defined event or set of circumstances that trigger <code>contextDestroyed</code>?</p>
  
  <p>Should I ensure that everything I do when <code>contextDestroyed</code> is called is reversible? Do I need to make all my pools survive a <code>destroyed/initialized</code> cycle? Was I wrong to assume I would only get a <code>contextDestroyed</code> when Tomcat was being shut down or my <code>war</code> was being replaced?</p>