use of javax.servlet.http.HttpSessionBindingEvent in project jetty.project by eclipse.
the class SessionHandler method doSessionAttributeListeners.
public void doSessionAttributeListeners(Session session, String name, Object old, Object value) {
if (!_sessionAttributeListeners.isEmpty()) {
HttpSessionBindingEvent event = new HttpSessionBindingEvent(session, name, old == null ? value : old);
for (HttpSessionAttributeListener l : _sessionAttributeListeners) {
if (old == null)
l.attributeAdded(event);
else if (value == null)
l.attributeRemoved(event);
else
l.attributeReplaced(event);
}
}
}
use of javax.servlet.http.HttpSessionBindingEvent in project undertow by undertow-io.
the class SessionListenerBridge method attributeAdded.
@Override
public void attributeAdded(final Session session, final String name, final Object value) {
if (name.startsWith(IO_UNDERTOW)) {
return;
}
final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, false);
applicationListeners.httpSessionAttributeAdded(httpSession, name, value);
if (value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(httpSession, name, value));
}
}
use of javax.servlet.http.HttpSessionBindingEvent 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));
}
}
}
use of javax.servlet.http.HttpSessionBindingEvent in project spring-framework by spring-projects.
the class MockHttpSession method serializeState.
/**
* Serialize the attributes of this session into an object that can be
* turned into a byte array with standard Java serialization.
* @return a representation of this session's serialized state
*/
public Serializable serializeState() {
HashMap<String, Serializable> state = new HashMap<>();
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 Serializable) {
state.put(name, (Serializable) value);
} else {
// unbind the attribute in this case.
if (value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value));
}
}
}
return state;
}
use of javax.servlet.http.HttpSessionBindingEvent in project spring-framework by spring-projects.
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));
}
}
Aggregations