From c8606508294e387fad8bc10a2bd34415e8df9a8c Mon Sep 17 00:00:00 2001 From: fhanik Date: Tue, 22 Aug 2006 16:52:29 +0000 Subject: [PATCH] Prepare for cluster integration git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@433689 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/catalina/core/ApplicationContext.java | 2 +- .../apache/catalina/session/StandardSession.java | 29 +++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationContext.java b/java/org/apache/catalina/core/ApplicationContext.java index 6cff488e7..fba8cd25a 100644 --- a/java/org/apache/catalina/core/ApplicationContext.java +++ b/java/org/apache/catalina/core/ApplicationContext.java @@ -88,7 +88,7 @@ public class ApplicationContext /** * The context attributes for this context. */ - private Map attributes = new ConcurrentHashMap(); + protected Map attributes = new ConcurrentHashMap(); /** diff --git a/java/org/apache/catalina/session/StandardSession.java b/java/org/apache/catalina/session/StandardSession.java index 55e03c1cb..27443a2e7 100644 --- a/java/org/apache/catalina/session/StandardSession.java +++ b/java/org/apache/catalina/session/StandardSession.java @@ -1243,6 +1243,27 @@ public class StandardSession * invalidated session */ public void setAttribute(String name, Object value) { + setAttribute(name,value,true); + } + /** + * Bind an object to this session, using the specified name. If an object + * of the same name is already bound to this session, the object is + * replaced. + *

+ * After this method executes, and if the object implements + * HttpSessionBindingListener, the container calls + * valueBound() on the object. + * + * @param name Name to which the object is bound, cannot be null + * @param value Object to be bound, cannot be null + * @param notify whether to notify session listeners + * @exception IllegalArgumentException if an attempt is made to add a + * non-serializable object in an environment marked distributable. + * @exception IllegalStateException if this method is called on an + * invalidated session + */ + + public void setAttribute(String name, Object value, boolean notify) { // Name cannot be null if (name == null) @@ -1268,7 +1289,7 @@ public class StandardSession HttpSessionBindingEvent event = null; // Call the valueBound() method if necessary - if (value instanceof HttpSessionBindingListener) { + if (notify && value instanceof HttpSessionBindingListener) { // Don't call any notification if replacing with the same value Object oldValue = attributes.get(name); if (value != oldValue) { @@ -1286,7 +1307,7 @@ public class StandardSession Object unbound = attributes.put(name, value); // Call the valueUnbound() method if necessary - if ((unbound != null) && (unbound != value) && + if (notify && (unbound != null) && (unbound != value) && (unbound instanceof HttpSessionBindingListener)) { try { ((HttpSessionBindingListener) unbound).valueUnbound @@ -1296,7 +1317,9 @@ public class StandardSession (sm.getString("standardSession.bindingEvent"), t); } } - + + if ( !notify ) return; + // Notify interested application event listeners Context context = (Context) manager.getContainer(); Object listeners[] = context.getApplicationEventListeners(); -- 2.11.0