geoserver/geoserver — pull request #706 by groldan (2014-09-03 18:06:34+00:00)
Title: [GEOS-6468] (master) Make GWCLifeCycleHandler behave correctly on application shutdown.

GWCLifeCycleHandler is created dynamically when GeoServer requires
it by looking for beans implementing the GeoServerLifecycleHandler
extension point. It used to require a handle to the GWC mediator,
which is fine when the application is running and GeoServer is required
to either reload the configuration or reset its caches, but fails
at application shutdown since the GWC mediator has already been
disposed and can't be re-created at that stage. The collateral damage
is that this failure to instantiate GWCLifeCycleHandler prevents
GeoServer from calling onDispose() in the other extension point
implementations.

This patch makes it so that onReset() and onReload() call a static
tryReset() and tryReload() method in GWC accordingly, which in turn
will perform the required action as long as the GWC mediator instance
is 'alive'. If it's not, it means that it's own destroy() method has
already been called and hence there's no need for GWC.reset()/reload()
to run at all.