class ShutdownListener implements ServletContextListener {

  @Override
  public void contextDestroyed(ServletContextEvent event) {
    // If we have session manager we need to close it
    SessionManager sessionManager = (SessionManager)event.getServletContext().getAttribute(Attributes.SESSION_MANAGER);
    if (sessionManager != null) {
      sessionManager.close();
    }
  }

}