You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@locus.apache.org on 2000/07/12 06:43:15 UTC
cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session Constants.java StandardManager.java StandardSession.java
craigmcc 00/07/11 21:43:15
Modified: proposals/catalina/src/share/org/apache/tomcat/session
Constants.java StandardManager.java
StandardSession.java
Log:
Enable session persistence across context restarts (automatic or manual)
by default. The active sessions are serialized to a file in the context
temporary work directory, unless configured to a different path in
server.xml.
Revision Changes Path
1.2 +2 -0 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/Constants.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Constants.java 2000/01/20 06:37:30 1.1
+++ Constants.java 2000/07/12 04:43:14 1.2
@@ -73,5 +73,7 @@
public static final String SESSION_COOKIE_NAME = "JSESSIONID";
public static final String SESSION_PARAMETER_NAME = "jsessionid";
+ public static final String WORKDIR_ATTR =
+ "javax.servlet.context.tempdir";
}
1.18 +23 -9 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardManager.java
Index: StandardManager.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardManager.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- StandardManager.java 2000/06/18 22:13:24 1.17
+++ StandardManager.java 2000/07/12 04:43:15 1.18
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardManager.java,v 1.17 2000/06/18 22:13:24 craigmcc Exp $
- * $Revision: 1.17 $
- * $Date: 2000/06/18 22:13:24 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardManager.java,v 1.18 2000/07/12 04:43:15 craigmcc Exp $
+ * $Revision: 1.18 $
+ * $Date: 2000/07/12 04:43:15 $
*
* ====================================================================
*
@@ -81,6 +81,7 @@
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
+import javax.servlet.ServletContext;
import org.apache.tomcat.Container;
import org.apache.tomcat.Context;
import org.apache.tomcat.Lifecycle;
@@ -104,7 +105,7 @@
* <code>stop()</code> methods of this class at the correct times.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.17 $ $Date: 2000/06/18 22:13:24 $
+ * @version $Revision: 1.18 $ $Date: 2000/07/12 04:43:15 $
*/
public final class StandardManager
@@ -124,7 +125,7 @@
/**
* The debugging detail level for this component.
*/
- private int debug = 0;
+ private int debug = 2;
/**
@@ -149,8 +150,11 @@
* Path name of the disk file in which active sessions are saved
* when we stop, and from which these sessions are loaded when we start.
* A <code>null</code> value indicates that no persistence is desired.
+ * If this pathname is relative, it will be resolved against the
+ * temporary working directory provided by our context, available via
+ * the <code>javax.servlet.context.tempdir</code> context attribute.
*/
- private String pathname = null;
+ private String pathname = "sessions.ser";
/**
@@ -479,8 +483,18 @@
if (pathname == null)
return (null);
File file = new File(pathname);
+ if (!file.isAbsolute()) {
+ if (container instanceof Context) {
+ ServletContext servletContext =
+ ((Context) container).getServletContext();
+ File tempdir = (File)
+ servletContext.getAttribute(Constants.WORKDIR_ATTR);
+ if (tempdir != null)
+ file = new File(tempdir, pathname);
+ }
+ }
if (!file.isAbsolute())
- file = new File(System.getProperty("catalina.home"), pathname);
+ return (null);
return (file);
}
@@ -502,7 +516,7 @@
File file = file();
if (file == null)
return;
- if (debug > 0)
+ if (debug >= 1)
log(sm.getString("standardManager.loading", pathname));
FileInputStream fis = null;
ObjectInputStream ois = null;
@@ -612,7 +626,7 @@
File file = file();
if (file == null)
return;
- if (debug > 0)
+ if (debug >= 1)
log(sm.getString("standardManager.unloading", pathname));
FileOutputStream fos = null;
ObjectOutputStream oos = null;
1.10 +5 -5 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardSession.java
Index: StandardSession.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardSession.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- StandardSession.java 2000/06/29 18:08:58 1.9
+++ StandardSession.java 2000/07/12 04:43:15 1.10
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardSession.java,v 1.9 2000/06/29 18:08:58 craigmcc Exp $
- * $Revision: 1.9 $
- * $Date: 2000/06/29 18:08:58 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardSession.java,v 1.10 2000/07/12 04:43:15 craigmcc Exp $
+ * $Revision: 1.10 $
+ * $Date: 2000/07/12 04:43:15 $
*
* ====================================================================
*
@@ -102,11 +102,11 @@
* @author Craig R. McClanahan
* @author Sean Legassick
* @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
- * @version $Revision: 1.9 $ $Date: 2000/06/29 18:08:58 $
+ * @version $Revision: 1.10 $ $Date: 2000/07/12 04:43:15 $
*/
final class StandardSession
- implements HttpSession, Session {
+ implements HttpSession, Session, Serializable {
// ----------------------------------------------------------- Constructors