- Port patches.
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 14 Apr 2006 21:30:28 +0000 (21:30 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 14 Apr 2006 21:30:28 +0000 (21:30 +0000)
- Change to session: it doesn't make sense to me that getAttribute is a good place to
  synchronously make a check for session expiration (of course, with accessCount, this is
  not going to happen anyway, but still).

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

java/org/apache/catalina/realm/DataSourceRealm.java
java/org/apache/catalina/session/StandardSession.java
java/org/apache/catalina/valves/JDBCAccessLogValve.java
java/org/apache/jasper/compiler/Generator.java

index f346126..7cfcf17 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright 1999,2004 The Apache Software Foundation.\r
+ * Copyright 1999,2004-2006 The Apache Software Foundation.\r
  * \r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -44,7 +44,7 @@ import org.apache.catalina.util.StringManager;
 * @author Craig R. McClanahan\r
 * @author Carson McDonald\r
 * @author Ignacio Ortega\r
-* @version $Revision: 373023 $\r
+* @version $Revision: 394121 $\r
 */\r
 \r
 public class DataSourceRealm\r
@@ -57,13 +57,13 @@ public class DataSourceRealm
     /**\r
      * The generated string for the roles PreparedStatement\r
      */\r
-    private StringBuffer preparedRoles = null;\r
+    private String preparedRoles = null;\r
 \r
 \r
     /**\r
      * The generated string for the credentials PreparedStatement\r
      */\r
-    private StringBuffer preparedCredentials = null;\r
+    private String preparedCredentials = null;\r
 \r
 \r
     /**\r
@@ -581,7 +581,7 @@ public class DataSourceRealm
         throws SQLException {\r
 \r
         PreparedStatement credentials =\r
-            dbConnection.prepareStatement(preparedCredentials.toString());\r
+            dbConnection.prepareStatement(preparedCredentials);\r
 \r
         credentials.setString(1, username);\r
         return (credentials);\r
@@ -601,7 +601,7 @@ public class DataSourceRealm
         throws SQLException {\r
 \r
         PreparedStatement roles = \r
-            dbConnection.prepareStatement(preparedRoles.toString());\r
+            dbConnection.prepareStatement(preparedRoles);\r
 \r
         roles.setString(1, username);\r
         return (roles);\r
@@ -624,23 +624,24 @@ public class DataSourceRealm
         super.start();\r
 \r
         // Create the roles PreparedStatement string\r
-        preparedRoles = new StringBuffer("SELECT ");\r
-        preparedRoles.append(roleNameCol);\r
-        preparedRoles.append(" FROM ");\r
-        preparedRoles.append(userRoleTable);\r
-        preparedRoles.append(" WHERE ");\r
-        preparedRoles.append(userNameCol);\r
-        preparedRoles.append(" = ?");\r
+        StringBuffer temp = new StringBuffer("SELECT ");\r
+        temp.append(roleNameCol);\r
+        temp.append(" FROM ");\r
+        temp.append(userRoleTable);\r
+        temp.append(" WHERE ");\r
+        temp.append(userNameCol);\r
+        temp.append(" = ?");\r
+        preparedRoles = temp.toString();\r
 \r
         // Create the credentials PreparedStatement string\r
-        preparedCredentials = new StringBuffer("SELECT ");\r
-        preparedCredentials.append(userCredCol);\r
-        preparedCredentials.append(" FROM ");\r
-        preparedCredentials.append(userTable);\r
-        preparedCredentials.append(" WHERE ");\r
-        preparedCredentials.append(userNameCol);\r
-        preparedCredentials.append(" = ?");\r
-\r
+        temp = new StringBuffer("SELECT ");\r
+        temp.append(userCredCol);\r
+        temp.append(" FROM ");\r
+        temp.append(userTable);\r
+        temp.append(" WHERE ");\r
+        temp.append(userNameCol);\r
+        temp.append(" = ?");\r
+        preparedCredentials = temp.toString();\r
     }\r
 \r
 \r
index 1a5088e..19d7506 100644 (file)
@@ -156,7 +156,7 @@ public class StandardSession
     /**\r
      * Set of attribute names which are not allowed to be persisted.\r
      */\r
-    private static final String[] excludedAttributes = {\r
+    protected static final String[] excludedAttributes = {\r
         Globals.SUBJECT_ATTR\r
     };\r
 \r
@@ -422,9 +422,9 @@ public class StandardSession
      */\r
     public long getLastAccessedTime() {\r
 \r
-        if ( !isValid() ) {\r
+        if (!isValidInternal()) {\r
             throw new IllegalStateException\r
-            (sm.getString("standardSession.getId.ise"));\r
+                (sm.getString("standardSession.getId.ise"));\r
         }\r
 \r
         return (this.lastAccessedTime);\r
@@ -564,7 +564,7 @@ public class StandardSession
             return true;\r
         }\r
 \r
-        if (!this.isValid ) {\r
+        if (!this.isValid) {\r
             return false;\r
         }\r
 \r
@@ -948,7 +948,7 @@ public class StandardSession
      */\r
     public long getCreationTime() {\r
 \r
-        if (!isValid())\r
+        if (!isValidInternal())\r
             throw new IllegalStateException\r
                 (sm.getString("standardSession.getCreationTime.ise"));\r
 \r
@@ -1003,7 +1003,7 @@ public class StandardSession
      */\r
     public Object getAttribute(String name) {\r
 \r
-        if (!isValid())\r
+        if (!isValidInternal())\r
             throw new IllegalStateException\r
                 (sm.getString("standardSession.getAttribute.ise"));\r
 \r
@@ -1021,7 +1021,7 @@ public class StandardSession
      */\r
     public Enumeration getAttributeNames() {\r
 \r
-        if (!isValid())\r
+        if (!isValidInternal())\r
             throw new IllegalStateException\r
                 (sm.getString("standardSession.getAttributeNames.ise"));\r
 \r
@@ -1061,7 +1061,7 @@ public class StandardSession
      */\r
     public String[] getValueNames() {\r
 \r
-        if (!isValid())\r
+        if (!isValidInternal())\r
             throw new IllegalStateException\r
                 (sm.getString("standardSession.getValueNames.ise"));\r
 \r
@@ -1078,7 +1078,7 @@ public class StandardSession
      */\r
     public void invalidate() {\r
 \r
-        if (!isValid())\r
+        if (!isValidInternal())\r
             throw new IllegalStateException\r
                 (sm.getString("standardSession.invalidate.ise"));\r
 \r
@@ -1100,7 +1100,7 @@ public class StandardSession
      */\r
     public boolean isNew() {\r
 \r
-        if (!isValid())\r
+        if (!isValidInternal())\r
             throw new IllegalStateException\r
                 (sm.getString("standardSession.isNew.ise"));\r
 \r
@@ -1175,7 +1175,7 @@ public class StandardSession
     public void removeAttribute(String name, boolean notify) {\r
 \r
         // Validate our current state\r
-        if (!isValid())\r
+        if (!isValidInternal())\r
             throw new IllegalStateException\r
                 (sm.getString("standardSession.removeAttribute.ise"));\r
 \r
@@ -1239,7 +1239,7 @@ public class StandardSession
         }\r
 \r
         // Validate our current state\r
-        if (!isValid())\r
+        if (!isValidInternal())\r
             throw new IllegalStateException\r
                 (sm.getString("standardSession.setAttribute.ise"));\r
         if ((manager != null) && manager.getDistributable() &&\r
@@ -1342,6 +1342,15 @@ public class StandardSession
 \r
 \r
     /**\r
+     * Return the <code>isValid</code> flag for this session without any expiration\r
+     * check.\r
+     */\r
+    protected boolean isValidInternal() {\r
+        return (this.isValid || this.expiring);\r
+    }\r
+\r
+\r
+    /**\r
      * Read a serialized version of this session object from the specified\r
      * object input stream.\r
      * <p>\r
@@ -1353,7 +1362,7 @@ public class StandardSession
      * @exception ClassNotFoundException if an unknown class is specified\r
      * @exception IOException if an input/output error occurs\r
      */\r
-    private void readObject(ObjectInputStream stream)\r
+    protected void readObject(ObjectInputStream stream)\r
         throws ClassNotFoundException, IOException {\r
 \r
         // Deserialize the scalar instance variables (except Manager)\r
@@ -1418,7 +1427,7 @@ public class StandardSession
      *\r
      * @exception IOException if an input/output error occurs\r
      */\r
-    private void writeObject(ObjectOutputStream stream) throws IOException {\r
+    protected void writeObject(ObjectOutputStream stream) throws IOException {\r
 \r
         // Write the scalar instance variables (except Manager)\r
         stream.writeObject(new Long(creationTime));\r
index adb9783..228e4cc 100644 (file)
@@ -44,7 +44,7 @@ import org.apache.catalina.util.StringManager;
  * To use, copy into the server/classes directory of the Tomcat installation\r
  * and configure in server.xml as:\r
  * <pre>\r
- *             &lt;Valve className="AccessLogDBValve"\r
+ *             &lt;Valve className="org.apache.catalina.valves.JDBCAccessLogValve"\r
  *             driverName="<i>your_jdbc_driver</i>"\r
  *             connectionURL="<i>your_jdbc_url</i>"\r
  *             pattern="combined" resolveHosts="false"\r
@@ -76,7 +76,7 @@ import org.apache.catalina.util.StringManager;
  * id INT UNSIGNED AUTO_INCREMENT NOT NULL,\r
  * ts TIMESTAMP NOT NULL,\r
  * remoteHost CHAR(15) NOT NULL,\r
- * user CHAR(15),\r
+ * userName CHAR(15),\r
  * timestamp TIMESTAMP NOT NULL,\r
  * virtualHost VARCHAR(64) NOT NULL,\r
  * method VARCHAR(8) NOT NULL,\r
@@ -124,7 +124,7 @@ public final class JDBCAccessLogValve
      *                 connectionURL = null;\r
      *                 tableName = "access";\r
      *                 remoteHostField = "remoteHost";\r
-     *                 userField = "user";\r
+     *                 userField = "userName";\r
      *                 timestampField = "timestamp";\r
      *                 virtualHostField = "virtualHost";\r
      *                 methodField = "method";\r
@@ -143,7 +143,7 @@ public final class JDBCAccessLogValve
         connectionURL = null;\r
         tableName = "access";\r
         remoteHostField = "remoteHost";\r
-        userField = "user";\r
+        userField = "userName";\r
         timestampField = "timestamp";\r
         virtualHostField = "virtualHost";\r
         methodField = "method";\r
@@ -208,7 +208,7 @@ public final class JDBCAccessLogValve
      * The descriptive information about this implementation.\r
      */\r
     protected static String info = \r
-        "org.apache.catalina.valves.JDBCAccessLogValve/1.0";\r
+        "org.apache.catalina.valves.JDBCAccessLogValve/1.1";\r
 \r
 \r
     /**\r
index 61687c3..ddf0af5 100644 (file)
@@ -2255,7 +2255,7 @@ class Generator {
                     out.printin("if (");\r
                     out.print(tagEvalVar);\r
                     out\r
-                            .println(" != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE)");\r
+                            .println(" != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {");\r
                     out.pushIndent();\r
                     out.printil("out = _jspx_page_context.popBody();");\r
                     if (n.implementsTryCatchFinally()) {\r
@@ -2266,6 +2266,7 @@ class Generator {
                         out.println("[0]--;");\r
                     }\r
                     out.popIndent();\r
+                    out.printil("}");\r
                 }\r
 \r
                 out.popIndent(); // EVAL_BODY\r