Atmosphere's Shutdown Hook: Executing Tasks during undeploy - Atmosphere/atmosphere Wiki

Sometimes an application needs to execute some task when Atmosphere is undeployed. To achieve such task with Atmosphere, just do:

  AtmosphereResource.getAtmosphereConfig().shutdownHook(new ApplicationConfig.ShutdownHook() {
       public void shutdown() {
            ...
       }  
  });