Search in sources :

Example 1 with HttpSessionActivationListener

use of jakarta.servlet.http.HttpSessionActivationListener in project tomcat by apache.

the class StandardSession method activate.

/**
 * Perform internal processing required to activate this
 * session.
 */
public void activate() {
    // Initialize access count
    if (activityCheck) {
        accessCount = new AtomicInteger();
    }
    // Notify interested session event listeners
    fireSessionEvent(Session.SESSION_ACTIVATED_EVENT, null);
    // Notify ActivationListeners
    HttpSessionEvent event = null;
    String[] keys = keys();
    for (String key : keys) {
        Object attribute = attributes.get(key);
        if (attribute instanceof HttpSessionActivationListener) {
            if (event == null) {
                event = new HttpSessionEvent(getSession());
            }
            try {
                ((HttpSessionActivationListener) attribute).sessionDidActivate(event);
            } catch (Throwable t) {
                ExceptionUtils.handleThrowable(t);
                manager.getContext().getLogger().error(sm.getString("standardSession.attributeEvent"), t);
            }
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HttpSessionEvent(jakarta.servlet.http.HttpSessionEvent) HttpSessionActivationListener(jakarta.servlet.http.HttpSessionActivationListener)

Example 2 with HttpSessionActivationListener

use of jakarta.servlet.http.HttpSessionActivationListener in project tomcat by apache.

the class StandardSession method passivate.

/**
 * Perform the internal processing required to passivate
 * this session.
 */
public void passivate() {
    // Notify interested session event listeners
    fireSessionEvent(Session.SESSION_PASSIVATED_EVENT, null);
    // Notify ActivationListeners
    HttpSessionEvent event = null;
    String[] keys = keys();
    for (String key : keys) {
        Object attribute = attributes.get(key);
        if (attribute instanceof HttpSessionActivationListener) {
            if (event == null) {
                event = new HttpSessionEvent(getSession());
            }
            try {
                ((HttpSessionActivationListener) attribute).sessionWillPassivate(event);
            } catch (Throwable t) {
                ExceptionUtils.handleThrowable(t);
                manager.getContext().getLogger().error(sm.getString("standardSession.attributeEvent"), t);
            }
        }
    }
}
Also used : HttpSessionEvent(jakarta.servlet.http.HttpSessionEvent) HttpSessionActivationListener(jakarta.servlet.http.HttpSessionActivationListener)

Aggregations

HttpSessionActivationListener (jakarta.servlet.http.HttpSessionActivationListener)2 HttpSessionEvent (jakarta.servlet.http.HttpSessionEvent)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1