You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@locus.apache.org on 2000/09/24 22:01:50 UTC
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util MessageBytes.java
costin 00/09/24 13:01:49
Modified: src/facade22/org/apache/tomcat/facade
HttpServletRequestFacade.java
HttpSessionFacade.java
src/share/org/apache/tomcat/core Request.java
src/share/org/apache/tomcat/request SessionInterceptor.java
src/share/org/apache/tomcat/session StandardSession.java
StandardSessionInterceptor.java
src/share/org/apache/tomcat/util MessageBytes.java
Added: src/share/org/apache/tomcat/session ServerSession.java
TimeStamp.java
Log:
Start session refactoring.
ServerSession was part of the original Tomcat3.0 design, I replaced it with
StandardSession from Catalina. That created a number of problems, and it's
time to solve that.
We now use the same patterns for session as for the rest of tomcat - 2
layers, the lower layer uses internal objects ( for speed, recycleable,
focused to the core functionality ) and the facade aggregates core
objects and implement servlet-specific behavior.
Note that session is broken today ( I'll finish it this evening !). I try to
get "major" changes done ASAP in order to be able to have a freeze and
spend the beta time fixing all bugs.
Revision Changes Path
1.3 +2 -1 jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java
Index: HttpServletRequestFacade.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HttpServletRequestFacade.java 2000/09/24 18:10:55 1.2
+++ HttpServletRequestFacade.java 2000/09/24 20:01:43 1.3
@@ -64,6 +64,7 @@
import org.apache.tomcat.helper.RequestUtil;
import org.apache.tomcat.core.*;
import org.apache.tomcat.facade.*;
+import org.apache.tomcat.session.*;
import java.io.*;
import java.net.*;
import java.security.*;
@@ -390,7 +391,7 @@
/** Create the Facade for session.
*/
public HttpSession getSession(boolean create) {
- HttpSession realSession = (HttpSession)request.getSession( create );
+ ServerSession realSession = (ServerSession)request.getSession(create);
// No real session, return null
if( realSession == null ) {
if( sessionFacade!= null) sessionFacade.recycle();
1.3 +1 -2 jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpSessionFacade.java
Index: HttpSessionFacade.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpSessionFacade.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HttpSessionFacade.java 2000/09/24 19:22:34 1.2
+++ HttpSessionFacade.java 2000/09/24 20:01:43 1.3
@@ -251,7 +251,6 @@
}
public void setMaxInactiveInterval(int interval) {
- checkValid();
realSession.getTimeStamp().setMaxInactiveInterval( interval );
}
@@ -262,7 +261,7 @@
// duplicated code, private
private void checkValid() {
- if (!realSession.isValid()) {
+ if (!realSession.getTimeStamp().isValid()) {
throw new IllegalStateException
(sm.getString("standardSession.getAttributeNames.ise"));
}
1.60 +1 -0 jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java
Index: Request.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- Request.java 2000/09/24 18:02:05 1.59
+++ Request.java 2000/09/24 20:01:44 1.60
@@ -485,6 +485,7 @@
this.serverSession = serverSession;
}
+
public Object getSession(boolean create) {
if( serverSession!=null ) {
// if not null, it is validated by the session module
1.27 +9 -4 jakarta-tomcat/src/share/org/apache/tomcat/request/SessionInterceptor.java
Index: SessionInterceptor.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/SessionInterceptor.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- SessionInterceptor.java 2000/09/24 18:10:09 1.26
+++ SessionInterceptor.java 2000/09/24 20:01:45 1.27
@@ -70,11 +70,16 @@
/**
* Will process the request and determine the session Id, and set it
- * in the Request.
- * It also marks the session as accessed.
+ * in the Request. It doesn't marks the session as accessed.
*
- * This implementation only handles Cookies sessions, please extend or
- * add new interceptors for other methods.
+ * This interceptor doesn't deal with any of the Session internals -
+ * it just works with the sessionID. A pluggable session manager
+ * ( or user-space manager !) will deal with marking the session
+ * as accessed or setting the session implementation.
+ *
+ * This implementation only handles Cookies and URL rewriting sessions,
+ * please extend or add new interceptors for other methods.
+ *
*
*/
public class SessionInterceptor extends BaseInterceptor
1.19 +1 -6 jakarta-tomcat/src/share/org/apache/tomcat/session/StandardSession.java
Index: StandardSession.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/StandardSession.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- StandardSession.java 2000/09/24 18:10:14 1.18
+++ StandardSession.java 2000/09/24 20:01:46 1.19
@@ -1,8 +1,4 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/StandardSession.java,v 1.18 2000/09/24 18:10:14 costin Exp $
- * $Revision: 1.18 $
- * $Date: 2000/09/24 18:10:14 $
- *
* ====================================================================
*
* The Apache Software License, Version 1.1
@@ -72,7 +68,6 @@
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
@@ -97,7 +92,7 @@
*
* @author Craig R. McClanahan
* @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
- * @version $Revision: 1.18 $ $Date: 2000/09/24 18:10:14 $
+ * @version $Revision: 1.19 $ $Date: 2000/09/24 20:01:46 $
*/
final class StandardSession
1.9 +2 -1 jakarta-tomcat/src/share/org/apache/tomcat/session/StandardSessionInterceptor.java
Index: StandardSessionInterceptor.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/session/StandardSessionInterceptor.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- StandardSessionInterceptor.java 2000/09/24 18:10:14 1.8
+++ StandardSessionInterceptor.java 2000/09/24 20:01:47 1.9
@@ -104,7 +104,8 @@
// -------------------- Tomcat request events --------------------
public void engineInit( ContextManager cm ) throws TomcatException {
// set-up a per/container note for StandardManager
- manager_note = cm.getNoteId( ContextManager.CONTAINER_NOTE, "tomcat.standardManager");
+ manager_note = cm.getNoteId( ContextManager.CONTAINER_NOTE,
+ "tomcat.standardManager");
}
/**
1.4 +131 -123 jakarta-tomcat/src/share/org/apache/tomcat/session/ServerSession.java
1.1 jakarta-tomcat/src/share/org/apache/tomcat/session/TimeStamp.java
Index: TimeStamp.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.tomcat.session;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
/**
* Marks creation and access times, plus validity.
*
* Used for objects that expire - originally Sessions, but
* soon Contexts and Servlets ( scalability issues, large server support ).
*
* @author Costin Manolache
*/
public final class TimeStamp implements Serializable {
private long creationTime = 0L;
private long lastAccessedTime = creationTime;
private long thisAccessedTime = creationTime;
private boolean isNew = true;
private int maxInactiveInterval = -1;
private boolean isValid = false;
Object parent;
public TimeStamp() {
}
// -------------------- Active methods --------------------
/**
* Access notification. This method takes a time parameter in order
* to allow callers to efficiently manage expensive calls to
* System.currentTimeMillis()
*/
public void touch(long time) {
this.lastAccessedTime = this.thisAccessedTime;
this.thisAccessedTime = time;
this.isNew=false;
}
// -------------------- Property access --------------------
/** Returns the owner of this stamp ( the object that is
* time-stamped
*/
public void setParent( Object o ) {
parent=o;
}
public Object getParent() {
return parent;
}
public void setCreationTime(long time) {
this.creationTime = time;
this.lastAccessedTime = time;
this.thisAccessedTime = time;
}
public long getLastAccessedTime() {
return lastAccessedTime;
}
public int getMaxInactiveInterval() {
return maxInactiveInterval;
}
public void setMaxInactiveInterval(int interval) {
maxInactiveInterval = interval;
}
public boolean isValid() {
return isValid;
}
public void setValid(boolean isValid) {
this.isValid = isValid;
}
public boolean isNew() {
return isNew;
}
public void setNew(boolean isNew) {
this.isNew = isNew;
}
public long getCreationTime() {
return creationTime;
}
// -------------------- Maintainance --------------------
public void recycle() {
creationTime = 0L;
lastAccessedTime = 0L;
maxInactiveInterval = -1;
isNew = true;
isValid = false;
}
}
1.9 +2 -1 jakarta-tomcat/src/share/org/apache/tomcat/util/MessageBytes.java
Index: MessageBytes.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/MessageBytes.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- MessageBytes.java 2000/09/24 17:33:44 1.8
+++ MessageBytes.java 2000/09/24 20:01:48 1.9
@@ -61,6 +61,7 @@
import java.text.*;
import java.util.*;
+import java.io.Serializable;
// XXX XXX Need StringBuffer support !
@@ -72,7 +73,7 @@
* @author James Todd [gonzo@eng.sun.com]
* @author Costin Manolache
*/
-public final class MessageBytes implements Cloneable {
+public final class MessageBytes implements Cloneable, Serializable {
public static final String DEFAULT_CHAR_ENCODING="8859_1";
// primary type ( whatever is set as original value )