Final part of refactoring STRICT_SERVLET_COMPLIANCE so it just changes defaults
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 6 Jun 2010 21:24:09 +0000 (21:24 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 6 Jun 2010 21:24:09 +0000 (21:24 +0000)
New property LAST_ACCESS_AT_START

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

java/org/apache/catalina/session/StandardSession.java
webapps/docs/config/systemprops.xml

index 933d3e7..1de9060 100644 (file)
@@ -88,11 +88,10 @@ public class StandardSession
 
     protected static final boolean ACTIVITY_CHECK;
 
+    protected static final boolean LAST_ACCESS_AT_START;
 
     static {
-        STRICT_SERVLET_COMPLIANCE = Boolean.valueOf(System.getProperty(
-                "org.apache.catalina.STRICT_SERVLET_COMPLIANCE",
-                "false")).booleanValue();
+        STRICT_SERVLET_COMPLIANCE = Globals.STRICT_SERVLET_COMPLIANCE;
         
         String activityCheck = System.getProperty(
                 "org.apache.catalina.session.StandardSession.ACTIVITY_CHECK");
@@ -102,6 +101,15 @@ public class StandardSession
             ACTIVITY_CHECK =
                 Boolean.valueOf(activityCheck).booleanValue();
         }
+
+        String lastAccessAtStart = System.getProperty(
+                "org.apache.catalina.session.StandardSession.LAST_ACCESS_AT_START");
+        if (lastAccessAtStart == null) {
+            LAST_ACCESS_AT_START = STRICT_SERVLET_COMPLIANCE;
+        } else {
+            LAST_ACCESS_AT_START =
+                Boolean.valueOf(lastAccessAtStart).booleanValue();
+        }
     }
     
 
@@ -614,7 +622,7 @@ public class StandardSession
         if (maxInactiveInterval >= 0) { 
             long timeNow = System.currentTimeMillis();
             int timeIdle;
-            if (Globals.STRICT_SERVLET_COMPLIANCE) {
+            if (LAST_ACCESS_AT_START) {
                 timeIdle = (int) ((timeNow - lastAccessedTime) / 1000L);
             } else {
                 timeIdle = (int) ((timeNow - thisAccessedTime) / 1000L);
@@ -668,7 +676,7 @@ public class StandardSession
          * The servlet spec mandates to ignore request handling time
          * in lastAccessedTime.
          */
-        if (Globals.STRICT_SERVLET_COMPLIANCE) {
+        if (LAST_ACCESS_AT_START) {
             this.lastAccessedTime = this.thisAccessedTime;
             this.thisAccessedTime = System.currentTimeMillis();
         } else {
index b671450..344720c 100644 (file)
       <li><code>org.apache.catalina.core.ApplicationDispatcher.WRAP_SAME_OBJECT</code></li>
       <li><code>org.apache.catalina.core.StandardHostValve.ACCESS_SESSION</code></li>
       <li><code>org.apache.catalina.session.StandardSession.ACTIVITY_CHECK</code></li>
+      <li><code>org.apache.catalina.session.StandardSession.LAST_ACCESS_AT_START</code></li>
       <li><code>org.apache.tomcat.util.http.ServerCookie.ALWAYS_ADD_EXPIRES</code>.</li>
       <li><code>org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR</code>.</li>
       <li><code>org.apache.tomcat.util.http.ServerCookie.STRICT_NAMING</code>.</li>
       else the default value will be <code>false</code>.</p>
     </property>
 
+    <property
+    name="org.apache.catalina.session. StandardSession.LAST_ACCESS_AT_START">
+      <p>If this is <code>true</code>, the last accessed time for sessions will
+      be calculated from the beginning of the previous request. If
+      <code>false</code>, the last accessed time for sessions will be calculated
+      from the end of the previous request. This also affects how the idle time
+      is calculated. If
+      <code>org.apache.catalina.STRICT_SERVLET_COMPLIANCE</code> is set to
+      <code>true</code>, the default of this setting will be <code>true</code>,
+      else the default value will be <code>false</code>.</p>
+    </property>
+
   </properties>
 
 </section>