List of usage examples for javax.servlet.http HttpSessionBindingListener valueBound
default public void valueBound(HttpSessionBindingEvent event)
From source file:org.ireland.jnetty.server.session.HttpSessionImpl.java
/** * Sets a session attribute. If the value is a listener, notify it of the objectModified. If the value has changed * mark the session as changed for persistent sessions. * /*from w ww . j a va2s .co m*/ * @param name * the name of the attribute * @param value * the value of the attribute */ @Override public void setAttribute(String name, Object value) { if (!_isValid) throw new IllegalStateException( this + ": can't call setAttribute(String, Object) when session is no longer valid."); Object oldValue; if (value != null && !(value instanceof Serializable) && debug) { log.debug(this + " attribute '" + name + "' value is non-serializable type '" + value.getClass().getName() + "'"); } synchronized (_values) { if (value != null) oldValue = _values.put(name, value); else oldValue = _values.remove(name); } if (oldValue instanceof HttpSessionBindingListener) { HttpSessionBindingListener listener; listener = (HttpSessionBindingListener) oldValue; listener.valueUnbound(new HttpSessionBindingEvent(HttpSessionImpl.this, name, oldValue)); } if (value instanceof HttpSessionBindingListener) { HttpSessionBindingListener listener; listener = (HttpSessionBindingListener) value; listener.valueBound(new HttpSessionBindingEvent(HttpSessionImpl.this, name, value)); } // Notify the attribute listeners ArrayList listeners = _manager.getAttributeListeners(); if (listeners != null && listeners.size() > 0) { HttpSessionBindingEvent event; if (oldValue != null) event = new HttpSessionBindingEvent(this, name, oldValue); else event = new HttpSessionBindingEvent(this, name, value); for (int i = 0; i < listeners.size(); i++) { HttpSessionAttributeListener listener; listener = (HttpSessionAttributeListener) listeners.get(i); if (oldValue != null) listener.attributeReplaced(event); else listener.attributeAdded(event); } } }