throw new IllegalArgumentException
(sm.getString("standardSession.setAttribute.iae"));
// Construct an event with the new value
HttpSessionBindingEvent event = null;
// Call the valueBound() method if necessary
if ( value instanceof HttpSessionBindingListener ) {
event = new HttpSessionBindingEvent(this, name, value);
try {
( (HttpSessionBindingListener) value).valueBound(event);
} catch ( Exception x ) {
log.error("Session binding listener throw an exception",x);
}
}
// Replace or add this attribute
Object unbound = attributes.put(name, value);
// Call the valueUnbound() method if necessary
if ((unbound != null) &&
(unbound instanceof HttpSessionBindingListener)) {
try {
( (HttpSessionBindingListener) unbound).valueUnbound
(new HttpSessionBindingEvent( (HttpSession)this, name));
} catch ( Exception x ) {
log.error("Session binding listener throw an exception",x);
}
}
// Notify interested application event listeners
Context context = (Context) manager.getContainer();
Object listeners[] = context.getApplicationEventListeners();
if (listeners == null)
return;
for (int i = 0; i < listeners.length; i++) {
if (!(listeners[i] instanceof HttpSessionAttributeListener))
continue;
HttpSessionAttributeListener listener =
(HttpSessionAttributeListener) listeners[i];
try {
if (unbound != null) {
fireContainerEvent(context,
"beforeSessionAttributeReplaced",
listener);
if ( event == null ) {
event = new HttpSessionBindingEvent
(this,name,unbound);
}
listener.attributeReplaced(event);
fireContainerEvent(context,
"afterSessionAttributeReplaced",
listener);
} else {
fireContainerEvent(context,
"beforeSessionAttributeAdded",
listener);
if (event == null) {
event = new HttpSessionBindingEvent
(this, name, unbound);
}
listener.attributeAdded(event);
fireContainerEvent(context,
"afterSessionAttributeAdded",