tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shac...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core SessionManager.java Context.java
Date Wed, 01 Mar 2000 07:51:42 GMT
shachor     00/02/29 23:51:41

  Modified:    src/share/org/apache/tomcat/core SessionManager.java
                        Context.java
  Log:
  Make the session configuration in web.xml (meaning session timeout)
  work.
  
  We can now use the conf/web.xml for default session timeout settings
  and WEB-INF/web.xml for per application timeout
  
  Revision  Changes    Path
  1.3       +25 -12    jakarta-tomcat/src/share/org/apache/tomcat/core/SessionManager.java
  
  Index: SessionManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/SessionManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SessionManager.java	2000/01/09 22:32:42	1.2
  +++ SessionManager.java	2000/03/01 07:51:41	1.3
  @@ -3,7 +3,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -11,7 +11,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    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
  @@ -19,15 +19,15 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:  
  - *       "This product includes software developed by the 
  + *    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 
  + *    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"
  @@ -55,7 +55,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   
   package org.apache.tomcat.core;
  @@ -67,9 +67,10 @@
   import javax.servlet.http.*;
   
   /**
  - * 
  + *
    * @author Craig R. McClanahan
    * @author costin@dnt.ro
  + * @author Gal Shachor shachor@il.ibm.com
    */
   public interface SessionManager {
   
  @@ -95,19 +96,19 @@
        *
        * @param ctx the context where the request belong
        * @param req the request having the id
  -     * @param id 
  +     * @param id
        */
       public void accessed(Context ctx, Request req, String id);
       //  we can pass only Request, as it contains both, but it's better to
  -    // show explicitely what this method uses. 
  -    
  +    // show explicitely what this method uses.
  +
   
       /**
        * Return the active Session, associated with this Manager, with the
        * specified session id (if any); otherwise return <code>null</code>.
        *
        * @param id The session id for the session to be returned
  -     * @param ctx The session needs to belong to the context 
  +     * @param ctx The session needs to belong to the context
        *
        * @exception ClassNotFoundException if a deserialization error occurs
        *  while processing this request
  @@ -116,8 +117,20 @@
        */
       public HttpSession findSession(Context ctx, String id);
   
  -    
  +
       /** Used by context when stoped, need to remove all sessions used by that context
        */
       public void removeSessions( Context ctx );
  +
  +    /**
  +     * Used by context to configure the session manager's inactivity timeout.
  +     *
  +     * The SessionManager may have some default session time out, the
  +     * Context on the other hand has it's timeout set by the deployment
  +     * descriptor (web.xml). This method lets the Context conforgure the
  +     * session manager according to this value.
  +     *
  +     * @param minutes The session inactivity timeout in minutes.
  +     */
  +    public void setSessionTimeOut(int minutes);
   }
  
  
  
  1.65      +66 -59    jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- Context.java	2000/02/29 22:42:44	1.64
  +++ Context.java	2000/03/01 07:51:41	1.65
  @@ -3,7 +3,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -11,7 +11,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    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
  @@ -19,15 +19,15 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:  
  - *       "This product includes software developed by the 
  + *    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 
  + *    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"
  @@ -55,7 +55,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   
   package org.apache.tomcat.core;
  @@ -74,12 +74,13 @@
    * The implementation is a repository for all the properties
    * defined in web.xml and tomcat specific properties, with all the
    * functionality delegated to interceptors.
  - * 
  + *
    * @author James Duncan Davidson [duncan@eng.sun.com]
    * @author James Todd [gonzo@eng.sun.com]
    * @author Jason Hunter [jch@eng.sun.com]
    * @author Harish Prabandham
    * @author costin@dnt.ro
  + * @author Gal Shachor shachor@il.ibm.com
    */
   public class Context {
       private static StringManager sm =StringManager.getManager("org.apache.tomcat.core");
  @@ -100,12 +101,12 @@
       private Hashtable attributes = new Hashtable();
   
       private File workDir;
  -    
  +
       private RequestSecurityProvider rsProvider;
   
       private Vector contextInterceptors = new Vector();
       private Vector requestInterceptors = new Vector();
  -    
  +
       // Servlets loaded by this context( String->ServletWrapper )
       private Hashtable servlets = new Hashtable();
   
  @@ -127,11 +128,11 @@
       // Maps specified in web.xml ( String url -> ServletWrapper  )
       private Hashtable mappings = new Hashtable();
       Hashtable constraints=new Hashtable();
  -    
  +
       Hashtable containers=new Hashtable();
  -    
  +
       private ServletWrapper defaultServlet = null;
  -    
  +
       // Authentication properties
       String authMethod;
       String realmName;
  @@ -139,12 +140,12 @@
       String formErrorPage;
   
       int debug=0;
  -    
  +
       public Context() {
   	//	System.out.println("New Context ");
   	// XXX  customize it per context
       }
  -	
  +
       ServletContextFacade getFacade() {
           if(contextFacade==null )
   	    contextFacade = new ServletContextFacade(contextM, this);
  @@ -161,14 +162,14 @@
       public void setContextManager(ContextManager cm) {
   	contextM=cm;
       }
  -    
  +
       public String getPath() {
   	return path;
       }
   
       public void setPath(String path) {
   	// config believes that the root path is called "/",
  -	// 
  +	//
   	if( "/".equals(path) )
   	    path="";
   	this.path = path;
  @@ -178,14 +179,14 @@
          the context and unpack it. It is _very_ inefficient to serve
          files from a remote location ( at least 2x slower )
       */
  -    
  +
       /** DocBase points to the web application files.
        *
        *  There is no restriction on the syntax and content of DocBase,
        *  it's up to the various modules to interpret this and use it.
        *  For example, to server from a war file you can use war: protocol,
        *  and set up War interceptors.
  -     * 
  +     *
        *  "Basic" tomcat treats it is a file ( either absolute or relative to
        *  the CM home ). XXX Make it absolute ??
        *
  @@ -203,7 +204,7 @@
       public void setReloadable( String s ) {
   	reloadable=new Boolean( s ).booleanValue();
       }
  -    
  +
       public void setReloadable( boolean b ) {
   	reloadable=b;
       }
  @@ -213,7 +214,7 @@
       public boolean getReloadable() {
   	return reloadable;
       }
  -    
  +
       // -------------------- Web.xml properties --------------------
       public Enumeration getWelcomeFiles() {
   	return welcomeFiles.elements();
  @@ -268,8 +269,8 @@
       public Enumeration getEnvEntries() {
   	return envEntryTypes.keys();
       }
  -    
  -    
  +
  +
       public String getInitParameter(String name) {
           return (String)initializationParameters.get(name);
       }
  @@ -283,7 +284,7 @@
       public void addInitParameter( String name, String value ) {
   	initializationParameters.put(name, value );
       }
  -    
  +
       public Enumeration getInitParameterNames() {
           return initializationParameters.keys();
       }
  @@ -314,7 +315,7 @@
       public void removeAttribute(String name) {
           attributes.remove(name);
       }
  -    
  +
       public String getDescription() {
           return this.description;
       }
  @@ -342,8 +343,11 @@
   
       public void setSessionTimeOut(int sessionTimeOut) {
           this.sessionTimeOut = sessionTimeOut;
  +        if(null != sessionManager) {
  +            sessionManager.setSessionTimeOut(sessionTimeOut);
  +        }
       }
  -    
  +
       public FileNameMap getMimeMap() {
           return mimeTypes;
       }
  @@ -394,10 +398,10 @@
   	this.realmName=realmName;
   	this.formLoginPage=formLoginPage;
   	this.formErrorPage=formErrorPage;
  -    }   
  -    
  +    }
  +
       // -------------------- Mappings --------------------
  -    
  +
       /**
        * Maps a named servlet to a particular path or extension.
        * If the named servlet is unregistered, it will be added
  @@ -425,8 +429,8 @@
   	    //	    System.out.println("Servlet not registered " + servletName );
   	    // Workaround for frequent "bug" in web.xmls
   	    // Declare a mapping for a JSP or servlet that is not
  -	    // declared as servlet. 
  -	    
  +	    // declared as servlet.
  +
   	    sw = new ServletWrapper(this);
   
   	    sw.setServletName(servletName);
  @@ -443,7 +447,7 @@
   	    defaultServlet = sw;
   
   	mappings.put( path, sw );
  -	
  +
   	Container map=new Container();
   	map.setContext( this );
   	map.setHandler( sw );
  @@ -462,7 +466,7 @@
   	    ct.setTransport( transport );
   	    ct.setRoles( roles );
   	    ct.setPath( path[i] );
  -	    
  +
   	    // XXX check if exists, merge if true.
   	    constraints.put( path[i], ct );
   	    //contextM.addSecurityConstraint( this, path[i], ct);
  @@ -473,7 +477,7 @@
       public Enumeration getContainers() {
   	return containers.elements();
       }
  -    
  +
       public Enumeration getContainerLocations() {
   	return containers.keys();
       }
  @@ -481,11 +485,11 @@
       public Container getContainer( String path ) {
   	return (Container)containers.get(path);
       }
  -    
  +
       public void removeContainer( Container ct ) {
   	containers.remove(ct.getPath());
       }
  -    
  +
       public ServletWrapper getDefaultServlet() {
   	if( defaultServlet==null)
   	    defaultServlet=getServletByName(Constants.DEFAULT_SERVLET_NAME );
  @@ -494,7 +498,7 @@
   
       // -------------------- Servlets management --------------------
   
  -    // XXX do we need that ?? 
  +    // XXX do we need that ??
       /** Remove the servlet with a specific name
        */
       public void removeServletByName(String servletName)
  @@ -539,14 +543,17 @@
       }
   
       public void setSessionManager( SessionManager manager ) {
  -	sessionManager= manager;
  +    	sessionManager= manager;
  +        if(null != sessionManager) {
  +            sessionManager.setSessionTimeOut(sessionTimeOut);
  +        }
       }
   
   
       public void setServletLoader(ServletLoader loader ) {
   	this.servletL=loader;
       }
  -    
  +
       public ServletLoader getServletLoader() {
   	return servletL;
       }
  @@ -592,7 +599,7 @@
   	    System.out.println("<l:context path=\"" + path  + "\" >" + msg + "</l:context>");
   	}
       }
  -    
  +
       public String toString() {
   	return "Ctx(" + path + "," + getDocBase() + ")";
       }
  @@ -613,7 +620,7 @@
           if (name == null)
   	    return null;
   
  -	// We need to do the checks 
  +	// We need to do the checks
   	ServletWrapper wrapper = getServletByName( name );
   	if (wrapper == null)
   	    return null;
  @@ -628,9 +635,9 @@
       public URL getResource(String rpath) throws MalformedURLException {
           URL url = null;
   
  -	if ("".equals(rpath)) 
  +	if ("".equals(rpath))
   	    return getDocumentBase();
  -	
  +
           if (rpath == null)
   	    return null;
   
  @@ -651,7 +658,7 @@
   	}
   	if(mappedPath == null )
   	    mappedPath=lr.getLookupPath();
  -	
  +
           URL docBase = getDocumentBase();
   
   	url=new URL(docBase.getProtocol(), docBase.getHost(),
  @@ -659,8 +666,8 @@
   	if( debug>9) log( "getResourceURL=" + url + " request=" + lr );
   	return url;
       }
  +
   
  -    
       Context getContext(String path) {
   	if (! path.startsWith("/")) {
   	    return null; // according to spec, null is returned
  @@ -678,23 +685,23 @@
       }
   
       /**
  -     * 
  +     *
        */
       String getRealPath( String path) {
   	//	Real Path is the same as PathTranslated for a new request
  -	
  +
   	Context base=this; // contextM.getContext("");
   	Request req=contextM.createRequest( base , FileUtil.normPath(path) );
   	contextM.processRequest(req);
  -	
  +
   	String mappedPath = req.getMappedPath();
   
   	// XXX workaround - need to fix mapper to return mapped path
  -	if( mappedPath == null ) 
  +	if( mappedPath == null )
   	    mappedPath=req.getPathInfo();
   	if(mappedPath == null )
   	    mappedPath=req.getLookupPath();
  -	
  +
   	String realPath= this.getDocBase() + mappedPath;
   
           // evaluate relative paths relative to the context's home
  @@ -714,7 +721,7 @@
       private URL documentBase;
       private URL servletBase = null;
       private boolean isInvokerEnabled = false;
  -    // for serving WARs directly 
  +    // for serving WARs directly
       private File warDir = null;
       private boolean isWARExpanded = false;
       private boolean isWARValidated = false;
  @@ -726,7 +733,7 @@
       public boolean isInvokerEnabled() {
           return isInvokerEnabled;
       }
  -    
  +
       /**  @deprecated
        */
       public void setInvokerEnabled(boolean isInvokerEnabled) {
  @@ -744,7 +751,7 @@
       public void setWorkDirPersistent( boolean b ) {
   	isWorkDirPersistent=b;
       }
  -    
  +
       /**  @deprecated
        */
       public File getWorkDir() {
  @@ -823,7 +830,7 @@
       public void setIsWARValidated(boolean isWARValidated) {
           this.isWARValidated = isWARValidated;
       }
  -    
  +
       /**  @deprecated
        */
       public void addContextInterceptor( ContextInterceptor ci) {
  @@ -856,13 +863,13 @@
       }
   
       RequestInterceptor rInterceptors[];
  -    
  +
       /** Return the context interceptors as an array.
   	For performance reasons we use an array instead of
   	returning the vector - the interceptors will not change at
   	runtime and array access is faster and easier than vector
   	access
  -	@deprecated 
  +	@deprecated
       */
       public RequestInterceptor[] getRequestInterceptors() {
   	if( rInterceptors == null || rInterceptors.length != requestInterceptors.size()) {
  @@ -882,7 +889,7 @@
   		return null;
   	    try {
   		String absPath=docBase;
  -		
  +
   		// detect absolute path
   		if (docBase.startsWith(File.separator) ||
   		    docBase.startsWith("/") ||
  @@ -894,14 +901,14 @@
   		} else {
   		    absPath = contextM.getHome() + File.separator + docBase;
   		}
  -		
  +
   		try {
   		    absPath = new File(absPath).getCanonicalPath();
   		} catch (IOException npe) {
   		}
  -		
  +
   		documentBase = new URL("file", "", absPath);
  -		
  +
   	    } catch( MalformedURLException ex ) {
   		ex.printStackTrace();
   	    }
  
  
  

Mime
View raw message