public void removeAttribute(@Nonnull final String sName) { ValueEnforcer.notNull(sName, "Name"); final Object aValue = m_aAttributes.remove(sName); if (aValue instanceof HttpSessionBindingListener) ((HttpSessionBindingListener) aValue) .valueUnbound(new HttpSessionBindingEvent(this, sName, aValue)); }
/** Clear all of this session's attributes. */ public void clearAttributes() { for (final Map.Entry<String, Object> entry : m_aAttributes.entrySet()) { final String sName = entry.getKey(); final Object aValue = entry.getValue(); if (aValue instanceof HttpSessionBindingListener) ((HttpSessionBindingListener) aValue) .valueUnbound(new HttpSessionBindingEvent(this, sName, aValue)); } m_aAttributes.clear(); }
public void invokeDestructionCallback() { LogFactory.getLog(getClass()) .info( "#### invokeDestructionCallback() " + getBeanName() + " " + scope.getConversationId()); HttpSessionBindingListener listener = (HttpSessionBindingListener) scope.getDestructionCallback(getBeanName()); listener.valueUnbound(null); // cause unbound }
@Override public void valueUnbound(HttpSessionBindingEvent httpSessionBindingEvent) { if (_httpSessionBindingListeners == null) { return; } for (HttpSessionBindingListener httpSessionBindingListener : _httpSessionBindingListeners) { httpSessionBindingListener.valueUnbound(httpSessionBindingEvent); } }
/** * 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 */ @Nonnull public Serializable serializeState() { final HashMap<String, Object> aState = new HashMap<String, Object>(); for (final Map.Entry<String, Object> entry : m_aAttributes.entrySet()) { final String sName = entry.getKey(); final Object aValue = entry.getValue(); if (aValue instanceof Serializable) { aState.put(sName, aValue); } else { // Not serializable... Servlet containers usually automatically // unbind the attribute in this case. if (aValue instanceof HttpSessionBindingListener) { ((HttpSessionBindingListener) aValue) .valueUnbound(new HttpSessionBindingEvent(this, sName, aValue)); } } } m_aAttributes.clear(); return aState; }
private synchronized void callValueUnboundMethod(String key, Object value) { if (value instanceof HttpSessionBindingListener) { HttpSessionBindingEvent event = new HttpSessionBindingEvent(this, key, value); ((HttpSessionBindingListener) value).valueUnbound(event); } }