class HttpSessionNotifier implements SessionNotifier {

  @Override
  public void sessionDestroyed(RepositoryBackedSession session, boolean shutdown) {
    if (session instanceof HttpSession) {
      // We notify all session attribute listeners that each attribute is removed
      for (String key : session.getAttributeNamesWithValues()) {
        HttpSessionBindingEvent event = new HttpSessionBindingEvent((HttpSession)session, key);
        Object value = session.getAttribute(key);
        if (value instanceof HttpSessionBindingListener) {
          ((HttpSessionBindingListener)value).valueUnbound(event);
        }
        for (HttpSessionAttributeListener listener : descriptor.getHttpSessionAttributeListeners()) {
          listener.attributeRemoved(event);
        }
      }
      // Notifying HttpSessionListeners. If we are doing shutdown, as per
      // Servlet specification, we notify listeners in reverse order
      HttpSessionEvent event = new HttpSessionEvent((HttpSession)session);
      if (shutdown) {
        List<HttpSessionListener> listeners = descriptor.getHttpSessionListeners();
        for (int i = listeners.size() - 1; i >= 0; i--) {
          listeners.get(i).sessionDestroyed(event);
        }
      } else {
        for (HttpSessionListener listener : descriptor.getHttpSessionListeners()) {
          listener.sessionDestroyed(event);
        }
      }
    }
  }

    HttpSessionNotifier(ServletContextDescriptor descriptor);

}