Allow to overwrite check for distributability
authorrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 18 Sep 2011 09:20:00 +0000 (09:20 +0000)
committerrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 18 Sep 2011 09:20:00 +0000 (09:20 +0000)
of session attributes by session implementations.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1172233 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/session/StandardSession.java

index 2b99fd4..aa6ac6f 100644 (file)
@@ -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){