Search in sources :

Example 16 with HttpSessionBindingListener

use of javax.servlet.http.HttpSessionBindingListener in project spring-framework by spring-projects.

the class MockHttpSession method clearAttributes.

/**
	 * Clear all of this session's attributes.
	 */
public void clearAttributes() {
    for (Iterator<Map.Entry<String, Object>> it = this.attributes.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry<String, Object> entry = it.next();
        String name = entry.getKey();
        Object value = entry.getValue();
        it.remove();
        if (value instanceof HttpSessionBindingListener) {
            ((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value));
        }
    }
}
Also used : HttpSessionBindingEvent(javax.servlet.http.HttpSessionBindingEvent) HttpSessionBindingListener(javax.servlet.http.HttpSessionBindingListener) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 17 with HttpSessionBindingListener

use of javax.servlet.http.HttpSessionBindingListener in project gocd by gocd.

the class MockHttpSession method removeAttribute.

@Override
public void removeAttribute(String name) {
    assertIsValid();
    Assert.notNull(name, "Attribute name must not be null");
    Object value = this.attributes.remove(name);
    if (value instanceof HttpSessionBindingListener) {
        ((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value));
    }
}
Also used : HttpSessionBindingEvent(javax.servlet.http.HttpSessionBindingEvent) HttpSessionBindingListener(javax.servlet.http.HttpSessionBindingListener)

Example 18 with HttpSessionBindingListener

use of javax.servlet.http.HttpSessionBindingListener in project gocd by gocd.

the class MockHttpSession method setAttribute.

@Override
public void setAttribute(String name, Object value) {
    assertIsValid();
    Assert.notNull(name, "Attribute name must not be null");
    if (value != null) {
        this.attributes.put(name, value);
        if (value instanceof HttpSessionBindingListener) {
            ((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(this, name, value));
        }
    } else {
        removeAttribute(name);
    }
}
Also used : HttpSessionBindingEvent(javax.servlet.http.HttpSessionBindingEvent) HttpSessionBindingListener(javax.servlet.http.HttpSessionBindingListener)

Example 19 with HttpSessionBindingListener

use of javax.servlet.http.HttpSessionBindingListener in project gocd by gocd.

the class MockHttpSession method clearAttributes.

/**
 * Clear all of this session's attributes.
 */
public void clearAttributes() {
    for (Iterator<Map.Entry<String, Object>> it = this.attributes.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry<String, Object> entry = it.next();
        String name = entry.getKey();
        Object value = entry.getValue();
        it.remove();
        if (value instanceof HttpSessionBindingListener) {
            ((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value));
        }
    }
}
Also used : HttpSessionBindingEvent(javax.servlet.http.HttpSessionBindingEvent) HttpSessionBindingListener(javax.servlet.http.HttpSessionBindingListener)

Example 20 with HttpSessionBindingListener

use of javax.servlet.http.HttpSessionBindingListener in project qpid-broker-j by apache.

the class HttpManagementUtil method scheduleAbsoluteSessionTimeout.

private static void scheduleAbsoluteSessionTimeout(final HttpServletRequest request, final HttpSession session, final Broker<?> broker, final long absoluteSessionTimeout) {
    ScheduledFuture<?> invalidateFuture = broker.scheduleTask(absoluteSessionTimeout, TimeUnit.MILLISECONDS, () -> invalidateSession(session));
    setSessionAttribute(ATTR_INVALIDATE_FUTURE, new HttpSessionBindingListener() {

        @Override
        public void valueBound(final HttpSessionBindingEvent event) {
        }

        @Override
        public void valueUnbound(final HttpSessionBindingEvent event) {
            invalidateFuture.cancel(false);
        }
    }, session, request);
}
Also used : HttpSessionBindingEvent(javax.servlet.http.HttpSessionBindingEvent) HttpSessionBindingListener(javax.servlet.http.HttpSessionBindingListener)

Aggregations

HttpSessionBindingEvent (javax.servlet.http.HttpSessionBindingEvent)24 HttpSessionBindingListener (javax.servlet.http.HttpSessionBindingListener)24 IOException (java.io.IOException)5 NotSerializableException (java.io.NotSerializableException)4 WriteAbortedException (java.io.WriteAbortedException)4 ServletContext (javax.servlet.ServletContext)4 HttpSessionAttributeListener (javax.servlet.http.HttpSessionAttributeListener)4 Context (org.apache.catalina.Context)4 Serializable (java.io.Serializable)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 StandardContext (org.apache.catalina.core.StandardContext)2 HttpSessionImpl (io.undertow.servlet.spec.HttpSessionImpl)1 Locale (java.util.Locale)1 ServletException (javax.servlet.ServletException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpSession (javax.servlet.http.HttpSession)1 ISessionListener (org.polymap.core.runtime.session.ISessionListener)1 SessionContext (org.polymap.core.runtime.session.SessionContext)1