From: rjung Date: Sun, 18 Sep 2011 09:20:00 +0000 (+0000) Subject: Allow to overwrite check for distributability X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=e3b9af3d30db0be9cb54330b29288c714dff409f;p=tomcat7.0 Allow to overwrite check for distributability of session attributes by session implementations. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1172233 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/session/StandardSession.java b/java/org/apache/catalina/session/StandardSession.java index 2b99fd478..aa6ac6f0a 100644 --- a/java/org/apache/catalina/session/StandardSession.java +++ b/java/org/apache/catalina/session/StandardSession.java @@ -1449,7 +1449,7 @@ public class StandardSession implements HttpSession, Session, Serializable { throw new IllegalStateException(sm.getString( "standardSession.setAttribute.ise", getIdInternal())); if ((manager != null) && manager.getDistributable() && - !(value instanceof Serializable)) + !isAttributeDistributable(name, value)) throw new IllegalArgumentException (sm.getString("standardSession.setAttribute.iae", name)); // Construct an event with the new value @@ -1558,6 +1558,19 @@ public class StandardSession implements HttpSession, Session, Serializable { return (this.isValid || this.expiring); } + /** + * Check whether the Object can be distributed. This implementation + * simply checks for serializability. Derived classes might use other + * distribution technology not based on serialization and can extend + * this check. + * @param name The name of the attribute to check + * @param value The value of the attribute to check + * @return true if the attribute is distributable, false otherwise + */ + protected boolean isAttributeDistributable(String name, Object value) { + return value instanceof Serializable; + } + /** * Read a serialized version of this session object from the specified @@ -1694,7 +1707,7 @@ public class StandardSession implements HttpSession, Session, Serializable { /** - * Exclude attribute that cannot be serialized. + * Exclude standard attributes that cannot be serialized. * @param name the attribute's name */ protected boolean exclude(String name){