public void stop() {
   ClassLoader old = getTccl();
   try {
     setTccl(servletContext.getClassLoader());
     this.started = false;
     final Map<String, SessionPersistenceManager.PersistentSession> objectData = new HashMap<>();
     for (String sessionId : sessionManager.getTransientSessions()) {
       Session session = sessionManager.getSession(sessionId);
       if (session != null) {
         final HttpSessionEvent event =
             new HttpSessionEvent(SecurityActions.forSession(session, servletContext, false));
         final Map<String, Object> sessionData = new HashMap<>();
         for (String attr : session.getAttributeNames()) {
           final Object attribute = session.getAttribute(attr);
           sessionData.put(attr, attribute);
           if (attribute instanceof HttpSessionActivationListener) {
             ((HttpSessionActivationListener) attribute).sessionWillPassivate(event);
           }
         }
         objectData.put(
             sessionId,
             new PersistentSession(
                 new Date(
                     session.getLastAccessedTime() + (session.getMaxInactiveInterval() * 1000)),
                 sessionData));
       }
     }
     sessionPersistenceManager.persistSessions(deploymentName, objectData);
     this.data.clear();
   } finally {
     setTccl(old);
   }
 }
  @Override
  public void sessionWillPassivate(HttpSessionEvent httpSessionEvent) {
    if (_httpSessionActivationListeners == null) {
      return;
    }

    for (HttpSessionActivationListener httpSessionActivationListener :
        _httpSessionActivationListeners) {

      httpSessionActivationListener.sessionWillPassivate(httpSessionEvent);
    }
  }