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/02/03 08:11:55 UTC

cvs commit: jakarta-tomcat/src/shell watchdog.sh tomcat.sh

costin      00/02/02 23:11:55

  Modified:    src/share/org/apache/tomcat/context
                        DefaultContextSetter.java
                        LoadOnStartupInterceptor.java
                        WarWebXmlInterceptor.java WebXmlInterceptor.java
                        WorkDirInterceptor.java
               src/share/org/apache/tomcat/core
                        BufferedServletInputStream.java
                        BufferedServletOutputStream.java Context.java
                        ContextInterceptor.java ContextManager.java
                        Request.java RequestDispatcherImpl.java
                        RequestImpl.java RequestInterceptor.java
                        Response.java ResponseImpl.java ServletWrapper.java
               src/share/org/apache/tomcat/deployment
                        WebApplicationReader.java
               src/share/org/apache/tomcat/loader
                        ServletClassLoaderImpl.java
               src/share/org/apache/tomcat/request FixHeaders.java
                        SessionInterceptor.java SimpleMapper.java
               src/share/org/apache/tomcat/service/http
                        HttpResponseAdapter.java
               src/shell tomcat.sh
  Added:       src/share/org/apache/tomcat/context
                        BaseContextInterceptor.java
               src/share/org/apache/tomcat/request BaseInterceptor.java
               src/shell watchdog.sh
  Log:
  - Changed the names of handler methods in request and context interceptors ( removed the
  handle* prefix )
  
  - Added a base class for request/context interceptors
  
  - Major change in loadOnStartup - Context is no longer involved, all the code
  is in LoadOnStartupInterceptor. The "loadOnStartup" property is part of
  ServletWrapper, instead of keeping a hashtable mapping SW to loadOnStartup.
  
  - Fixed Request.getPathTranslated() - it used to return the path for the current request instead
  of the translated pathInfo
  
  - removed read() and write() methods from Request/Response - they belong to Stream.
  Request/ResponseImpl still have the methods (overriden by adapters), in order to simplify
  adapters ( they just have to extend Request/ResponseImpl, no need to deal with Streams if
  they don't need to)
  
  - getRealPath() - code was redundant, and no need for URLs ( since real path works only
  for "normal" file-system based contexts)
  
  - removed getServletsByPath(), and fixed containsJSP ( the only method using it) to
  return when the first JSP is found.
  
  - removed getServletsByClassName. It was a private and un-used method. Can be implemented
  outside context if anyone needs it.
  
  - removed empty ( and unused ) methods from ContextManager
  
  - removed Request.getParametersCopy(), replaced it with equivalent code in RDispatcher
  
  - removed ResolvedServlet from Request - not used anywhere, can be added if we find a user
  ( and if we find what it does :-). Same for ResourceName. Same for ServletBase
  
  - Added few more comments ( surprise !)
  
  - Fixed HttpResponseAdapter to send multiple headers.
  
  - Changed tomcat.sh to load all jars in tomcat/lib
  
  Sorry for the number/length of the changes, but I was offline and most
  of them are related ( cleanup, reorg ). The target is to document/clean Request, Response,
  Context and ContextManager.
  
  Revision  Changes    Path
  1.5       +3 -3      jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultContextSetter.java
  
  Index: DefaultContextSetter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultContextSetter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultContextSetter.java	2000/01/13 18:20:31	1.4
  +++ DefaultContextSetter.java	2000/02/03 07:11:50	1.5
  @@ -75,13 +75,13 @@
    *
    * @author costin@dnt.ro
    */
  -public class DefaultContextSetter implements ContextInterceptor {
  +public class DefaultContextSetter extends BaseContextInterceptor implements ContextInterceptor {
   
       public DefaultContextSetter() {
       }
   
       // sets: engineHeader, requestSecurityProvider, workDir, sessionManager, classPath, libPath
  -    public int handleContextInit(Context ctx) {
  +    public int contextInit(Context ctx) {
   	setEngineHeader( ctx );
   
   	if( ctx.getWorkDir() == null)
  @@ -101,7 +101,7 @@
   	return OK;
       }
   
  -    public int handleContextShutdown(Context ctx) {
  +    public int contextShutdown(Context ctx) {
   	return OK;
       }
       // -------------------- implementation
  
  
  
  1.3       +44 -7     jakarta-tomcat/src/share/org/apache/tomcat/context/LoadOnStartupInterceptor.java
  
  Index: LoadOnStartupInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/LoadOnStartupInterceptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LoadOnStartupInterceptor.java	2000/01/13 18:20:31	1.2
  +++ LoadOnStartupInterceptor.java	2000/02/03 07:11:50	1.3
  @@ -75,15 +75,16 @@
    *
    * @author costin@dnt.ro
    */
  -public class LoadOnStartupInterceptor implements ContextInterceptor {
  +public class LoadOnStartupInterceptor extends BaseContextInterceptor  implements ContextInterceptor {
       private static StringManager sm =StringManager.getManager("org.apache.tomcat.context");
       
       public LoadOnStartupInterceptor() {
       }
   	
  -    public int handleContextInit(Context ctx) {
  +    public int contextInit(Context ctx) {
  +	init(ctx);
   	Vector orderedKeys = new Vector();
  -	Enumeration e=ctx.getInitLevels();
  +	Enumeration e=getInitLevels();
   		
   	// order keys
   	while (e.hasMoreElements()) {
  @@ -114,12 +115,13 @@
   	for (int i = 0; i < orderedKeys.size(); i ++) {
   	    Integer key = (Integer)orderedKeys.elementAt(i);
   
  -	    Enumeration sOnLevel = ctx.getLoadableServlets( key );
  +	    Enumeration sOnLevel = getLoadableServlets( key );
   
   	    while (sOnLevel.hasMoreElements()) {
   		String servletName = (String)sOnLevel.nextElement();
   		ServletWrapper  result = ctx.getServletByName(servletName);
  -		
  +
  +		ctx.log("Loading " + key + " "  + servletName );
   		if(result==null)
   		    System.out.println("Warning: we try to load an undefined servlet " + servletName);
   		else {
  @@ -136,9 +138,44 @@
   	return OK;
       }
   
  -    public int handleContextShutdown(Context ctx) {
  -	return OK;
  +    // -------------------- 
  +    // Old logic from Context - probably something cleaner can replace it.
  +
  +    private Hashtable loadableServlets = new Hashtable();
  +
  +    void init(Context ctx) {
  +	Enumeration enum=ctx.getServletNames();
  +	while(enum.hasMoreElements()) {
  +	    String name=(String)enum.nextElement();
  +	    ServletWrapper sw=ctx.getServletByName( name );
  +	    int i=sw.getLoadOnStartUp();
  +	    if( i!= 0)
  +		addLoadableServlet( new Integer(i), name );
  +	}
  +    }
  +    
  +    Enumeration getInitLevels() {
  +	return loadableServlets.keys();
       }
   
  +    Enumeration getLoadableServlets( Integer level ) {
  +	return ((Vector)loadableServlets.get( level )).elements();
  +    }
  +
  +    void setLoadableServlets( Integer level, Vector servlets ) {
  +	loadableServlets.put( level, servlets );
  +    }
  +
  +    void addLoadableServlet( Integer level,String name ) {
  +	Vector v;
  +	if( loadableServlets.get(level) != null ) 
  +	    v=(Vector)loadableServlets.get(level);
  +	else
  +	    v=new Vector();
  +	
  +	v.addElement(name);
  +	loadableServlets.put(level, v);
  +    }
  +    
   
   }
  
  
  
  1.2       +2 -8      jakarta-tomcat/src/share/org/apache/tomcat/context/WarWebXmlInterceptor.java
  
  Index: WarWebXmlInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/WarWebXmlInterceptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WarWebXmlInterceptor.java	2000/01/30 04:22:45	1.1
  +++ WarWebXmlInterceptor.java	2000/02/03 07:11:50	1.2
  @@ -77,13 +77,13 @@
    *
    * @author costin@dnt.ro
    */
  -public class WarWebXmlInterceptor implements ContextInterceptor {
  +public class WarWebXmlInterceptor extends BaseContextInterceptor implements ContextInterceptor {
       private static StringManager sm =StringManager.getManager("org.apache.tomcat.core");
       
       public WarWebXmlInterceptor() {
       }
   	
  -    public int handleContextInit(Context ctx) {
  +    public int contextInit(Context ctx) {
   	if (! ctx.getDocumentBase().getProtocol().equalsIgnoreCase("war")) {
   	    return 0;
   	}
  @@ -114,10 +114,4 @@
   	}
   	return 0;
       }
  -
  -    public int handleContextShutdown(Context ctx) {
  -	return OK;
  -    }
  -
  -    
   }
  
  
  
  1.7       +2 -7      jakarta-tomcat/src/share/org/apache/tomcat/context/WebXmlInterceptor.java
  
  Index: WebXmlInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/WebXmlInterceptor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- WebXmlInterceptor.java	2000/01/30 04:22:45	1.6
  +++ WebXmlInterceptor.java	2000/02/03 07:11:50	1.7
  @@ -75,13 +75,13 @@
    *
    * @author costin@dnt.ro
    */
  -public class WebXmlInterceptor implements ContextInterceptor {
  +public class WebXmlInterceptor extends BaseContextInterceptor  implements ContextInterceptor {
       private static StringManager sm =StringManager.getManager("org.apache.tomcat.core");
       
       public WebXmlInterceptor() {
       }
   	
  -    public int handleContextInit(Context ctx) {
  +    public int contextInit(Context ctx) {
   	System.out.println("Context(" + ctx.getPath() + "): " + ctx.getDocBase());
   	    
   	// process base configuration
  @@ -99,10 +99,5 @@
   	}
   	return 0;
       }
  -
  -    public int handleContextShutdown(Context ctx) {
  -	return OK;
  -    }
  -
       
   }
  
  
  
  1.3       +3 -3      jakarta-tomcat/src/share/org/apache/tomcat/context/WorkDirInterceptor.java
  
  Index: WorkDirInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/WorkDirInterceptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WorkDirInterceptor.java	2000/01/13 18:20:31	1.2
  +++ WorkDirInterceptor.java	2000/02/03 07:11:50	1.3
  @@ -75,12 +75,12 @@
    *
    * @author costin@dnt.ro
    */
  -public class WorkDirInterceptor implements ContextInterceptor {
  +public class WorkDirInterceptor extends BaseContextInterceptor  implements ContextInterceptor {
   
       public WorkDirInterceptor() {
       }
   	
  -    public int handleContextInit(Context ctx) {
  +    public int contextInit(Context ctx) {
   	// never null !! ( it is set by default to ./work ! )
   	//log	System.out.println("Preparing work dir " + ctx.getWorkDir() );
   
  @@ -98,7 +98,7 @@
   	return 0;
       }
   
  -    public int handleContextShutdown( Context ctx ) {
  +    public int contextShutdown( Context ctx ) {
   	
   	if (! ctx.isWorkDirPersistent()) {
               clearDir(ctx.getWorkDir());
  
  
  
  1.1                  jakarta-tomcat/src/share/org/apache/tomcat/context/BaseContextInterceptor.java
  
  Index: BaseContextInterceptor.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.context;
  
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.core.Constants;
  import org.apache.tomcat.util.*;
  import org.apache.tomcat.deployment.*;
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import javax.servlet.http.*;
  
  
  /**
   * @author costin@dnt.ro
   */
  public class BaseContextInterceptor implements ContextInterceptor {
  
      public BaseContextInterceptor() {
      }
  	
      public int contextInit(Context ctx) {
  	return 0;
      }
  
      public int contextShutdown(Context ctx) {
  	return 0;
      }
  
      /** Notify when a new servlet is added
       */
      public int addServlet( Context ctx, ServletWrapper sw) {
  	return 0;
      }
      
      /** Notify when a servlet is removed from context
       */
      public int removeServlet( Context ctx, ServletWrapper sw) {
  	return 0;
      }
  
  
      
  }
  
  
  
  1.5       +8 -6      jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletInputStream.java
  
  Index: BufferedServletInputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletInputStream.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BufferedServletInputStream.java	2000/01/15 23:30:19	1.4
  +++ BufferedServletInputStream.java	2000/02/03 07:11:51	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletInputStream.java,v 1.4 2000/01/15 23:30:19 costin Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/01/15 23:30:19 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletInputStream.java,v 1.5 2000/02/03 07:11:51 costin Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/02/03 07:11:51 $
    *
    * ====================================================================
    * 
  @@ -73,6 +73,8 @@
   
   /**
    * Default implementation use RequestAdapter to read data.
  + * Works only if you extend RequestImpl and override doRead() -
  + * all other implementations of Request should provide their own Stream
    *
    * @author James Duncan Davidson <du...@eng.sun.com>
    * @author Jason Hunter <jc...@eng.sun.com>
  @@ -87,17 +89,17 @@
       
       private int bytesRead = 0;
       private int limit = -1;
  -    private Request reqA;
  +    private RequestImpl reqA;
       
       public BufferedServletInputStream() {
       }
   
       public BufferedServletInputStream( Request reqA ) {
  -	this.reqA=reqA;
  +	setRequest(reqA);
       }
       
       public void setRequest(Request reqA ) {
  -	this.reqA=reqA;
  +	this.reqA=(RequestImpl)reqA;
       }
       
       public int doRead() throws IOException {
  
  
  
  1.9       +8 -7      jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletOutputStream.java
  
  Index: BufferedServletOutputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletOutputStream.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BufferedServletOutputStream.java	2000/02/01 07:37:36	1.8
  +++ BufferedServletOutputStream.java	2000/02/03 07:11:51	1.9
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletOutputStream.java,v 1.8 2000/02/01 07:37:36 costin Exp $
  - * $Revision: 1.8 $
  - * $Date: 2000/02/01 07:37:36 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletOutputStream.java,v 1.9 2000/02/03 07:11:51 costin Exp $
  + * $Revision: 1.9 $
  + * $Date: 2000/02/03 07:11:51 $
    *
    * ====================================================================
    * 
  @@ -80,6 +80,8 @@
   
   /**
    *
  + * Works only if you extend ResponseImpl and override doWrite() -
  + * all other implementations of Response should provide their own Stream
    *
    * @author James Duncan Davidson [duncan@eng.sun.com]
    * @author Jason Hunter [jch@eng.sun.com]
  @@ -101,8 +103,7 @@
       protected int totalCount = 0;
       protected boolean committed = false;
       protected boolean closed = false;
  -    //    Response response;
  -    Response resA;
  +    ResponseImpl resA;
       
       protected BufferedServletOutputStream() {
   	//	System.out.println("new BOS " + closed);
  @@ -110,7 +111,7 @@
   
       protected BufferedServletOutputStream(Response resA) {
   	//	System.out.println("new BOS " + closed);
  -	this.resA=resA;
  +	setResponse(resA);
       }
   
   //     public void setResponseAdapter( Response resA ) {
  @@ -127,7 +128,7 @@
       }
   
       public void setResponse( Response response ) {
  -	this.resA=response;
  +	this.resA=(ResponseImpl)response;
       }
   
       // Hack for the buffering issue.
  
  
  
  1.37      +57 -164   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.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- Context.java	2000/01/30 04:22:46	1.36
  +++ Context.java	2000/02/03 07:11:51	1.37
  @@ -149,8 +149,6 @@
       private Hashtable prefixMappedServlets = new Hashtable();
       private Hashtable extensionMappedServlets = new Hashtable();
       private Hashtable pathMappedServlets = new Hashtable();
  -    // servlets loaded on startup( String->ServletWrapper )
  -    private Hashtable loadableServlets = new Hashtable();
   
       int debug=0;
       
  @@ -351,76 +349,28 @@
   	t.printStackTrace(System.err);
       }
   
  +    /**
  +     * 
  +     */
       String getRealPath( String path) {
  -        String realPath = null;
  -
  -	int i = -1;
  - 
  -	// norm path
  -        while ((i = path.indexOf('\\')) > -1) {
  -            String a = path.substring(0, i);
  -            String b = "";
  - 
  -            if (i < path.length() - 1) {
  -                b = path.substring(i + 1);
  -            } 
  - 
  -            path = a + "/" + b;
  -        }
  - 
  -        try {
  -            URL url = getResource(path);
  -
  -	    if( debug>0 ) log( "getRealPath( " + path + ")=" + url);
  -	    
  -            if (url != null) {
  -                if (url.getProtocol().equalsIgnoreCase("war")) {
  -		    if (isWARExpanded()) {
  -		        String spec = url.getFile();
  -			
  -			if (spec.startsWith("/")) {
  -			    spec = spec.substring(1);
  -			}
  -
  -			int separator = spec.indexOf('!');
  -			URL warURL = null;
  -
  -			if (separator > -1) {
  -			    warURL = new URL(spec.substring(0, separator++));
  -			}
  -
  -			if (warURL.getProtocol().equalsIgnoreCase("file")) {
  -			    String s = getWorkDir() +"/" +
  -			        Constants.Context.WARExpandDir + path;
  -			    File f = new File(s);
  -			    String absPath = f.getAbsolutePath();
  - 
  -			    // take care of File.getAbsolutePath()
  -			    // troubles on jdk1.1.x/win
  -
  -			    realPath = FileUtil.patch(absPath);
  -			} else if (url.getProtocol().equalsIgnoreCase("http")) {
  -			    // XXX
  -			    // need to support http docBase'd context
  -			}
  -		    } else {
  -                        realPath = url.toString();
  -		    }
  -		} else if (url.getProtocol().equalsIgnoreCase("http")) {
  -                    // XXX
  -                    // need to support http docBase'd context
  -                } else if (url.getProtocol().equalsIgnoreCase("file")) {
  -		    // take care of File.getAbsolutePath() troubles on
  -		    // jdk1.1.x/win
  +	//	Real Path is the same as PathTranslated for a new request
  +	
  +	Context base=this; // contextM.getContext("");
  +	Request req=contextM.createRequest( base , normPath(path) );
  +	contextM.processRequest(req);
  +	
  +	String mappedPath = req.getMappedPath();
   
  -	            realPath = FileUtil.patch(url.getFile());
  -                }
  +	// XXX workaround - need to fix mapper to return mapped path
  +	if( mappedPath == null ) 
  +	    mappedPath=req.getPathInfo();
  +	if(mappedPath == null )
  +	    mappedPath=req.getLookupPath();
  +	
  +	String realPath= this.getDocBase() + mappedPath;
   
  -	    }
  -        } catch (Exception e) {
  -	    e.printStackTrace();
  -        }
  -	//Log	System.out.println("Get real path " + path + " = " +realPath);
  +	// Probably not needed - it will be used on the local FS
  +	realPath = FileUtil.patch(realPath);
   
   	return realPath;
       }
  @@ -535,20 +485,16 @@
   	this.initialized = true;
   
   	// Set defaults if not already there
  -	new DefaultContextSetter().handleContextInit( this );
  +	new DefaultContextSetter().contextInit( this );
   	
   	// set up work dir ( attribute + creation )
  -	new WorkDirInterceptor().handleContextInit( this );
  -
  -	// XXX who uses servletBase ???
  -	URL servletBase = getDocumentBase();
  -        this.setServletBase(servletBase);
  +	new WorkDirInterceptor().contextInit( this );
   
   	// Read context's web.xml
  -	new WebXmlInterceptor().handleContextInit( this );
  +	new WebXmlInterceptor().contextInit( this );
   
   	// load initial servlets
  -	new LoadOnStartupInterceptor().handleContextInit( this );
  +	new LoadOnStartupInterceptor().contextInit( this );
       }
   
       public SessionManager getSessionManager() {
  @@ -580,7 +526,7 @@
   
   	getSessionManager().removeSessions(this);
   
  -	new WorkDirInterceptor().handleContextShutdown(this);
  +	new WorkDirInterceptor().contextShutdown(this);
   	
   	System.out.println("Context: " + this + " down");
       }
  @@ -701,42 +647,6 @@
   	return contextFacade;
       }
   
  -
  -    public Enumeration getInitLevels() {
  -	return loadableServlets.keys();
  -    }
  -
  -    public Enumeration getLoadableServlets( Integer level ) {
  -	return ((Vector)loadableServlets.get( level )).elements();
  -    }
  -
  -    public void setLoadableServlets( Integer level, Vector servlets ) {
  -	loadableServlets.put( level, servlets );
  -    }
  -
  -    public void addLoadableServlet( Integer level,String name ) {
  -	Vector v;
  -	if( loadableServlets.get(level) != null ) 
  -	    v=(Vector)loadableServlets.get(level);
  -	else
  -	    v=new Vector();
  -	
  -	v.addElement(name);
  -	loadableServlets.put(level, v);
  -    }
  -    
  -
  -    // -------------------- From Container
  -
  -    public URL getServletBase() {
  -        return this.servletBase;
  -    }
  -
  -    public void setServletBase(URL servletBase) {
  -        this.servletBase = servletBase;
  -    }
  -
  -
       // --------------------
       
       /** Add a jsp to the "pre-defined" list ( used by web.xml )
  @@ -795,10 +705,17 @@
       }
   
       public boolean containsJSP(String path) {
  -        ServletWrapper[] sw = getServletsByPath(path);
  +	Enumeration enum = servlets.keys();
  +
  +	while (enum.hasMoreElements()) {
  +	    String key = (String)enum.nextElement();
  +	    ServletWrapper sw = (ServletWrapper)servlets.get(key);
   
  -        return (sw != null &&
  -	    sw.length > 0);
  +	    if( (sw instanceof JspWrapper ) &&
  +		path.equals( ((JspWrapper)sw).getPath()))
  +		return true;
  +	}
  +	return false;
       }
   
       /** Will remove a JSP from the list of "declared" jsps.
  @@ -996,53 +913,10 @@
   	servlets.remove(sw.getServletName());
       }
       
  -    /** Return servlets with a specified class name
  -     */
  -    private ServletWrapper[] getServletsByClassName(String name) {
  -        Vector servletWrappers = new Vector();
  -	Enumeration enum = servlets.keys();
  -
  -	while (enum.hasMoreElements()) {
  -	    String key = (String)enum.nextElement();
  -	    ServletWrapper sw = (ServletWrapper)servlets.get(key);
  -
  -
  -            if (sw.getServletClass() != null &&
  -                sw.getServletClass().equals(name)) {
  -	        servletWrappers.addElement(sw);
  -	    }
  -	}
  -
  -	ServletWrapper[] wrappers =
  -	    new ServletWrapper[servletWrappers.size()];
  -
  -	servletWrappers.copyInto((ServletWrapper[])wrappers);
  -
  -        return wrappers;
  +    public Enumeration getServletNames() {
  +	return servlets.keys();
       }
   
  -    public ServletWrapper[] getServletsByPath(String path) {
  -        Vector servletWrappers = new Vector();
  -	Enumeration enum = servlets.keys();
  -
  -	while (enum.hasMoreElements()) {
  -	    String key = (String)enum.nextElement();
  -	    ServletWrapper sw = (ServletWrapper)servlets.get(key);
  -
  -	    if( (sw instanceof JspWrapper ) &&
  -		path.equals( ((JspWrapper)sw).getPath()))
  -	        servletWrappers.addElement(sw);
  -	}
  -
  -	ServletWrapper[] wrappers =
  -	    new ServletWrapper[servletWrappers.size()];
  -
  -	servletWrappers.copyInto((ServletWrapper[])wrappers);
  -
  -        return wrappers;
  -    }
  -
  -
       // -------------------- Class Loading --------------------
       public ClassLoader getClassLoader() {
         return this.classLoader;
  @@ -1098,18 +972,37 @@
           return cp;
       }
   
  +    /* -------------------- Utils  -------------------- */
       public void setDebug( int level ) {
   	debug=level;
       }
   
  -    void log( String msg ) {
  +    public void log( String msg ) {
   	System.out.println("Context(" + path  + "): " + msg );
       }
       
       public String toString() {
  -	return "Ctx(" + path + ")";
  +	return "Ctx(" + path + "," + getDocBase() + ")";
   	// + " , " + getDocumentBase() + " ) ";
       }
   
  +
  +        // XXX Probably not needed, used by getRealPath()
  +    private String normPath( String path ) {
  +	int i = -1;
  +	// norm path
  +        while ((i = path.indexOf('\\')) > -1) {
  +            String a = path.substring(0, i);
  +            String b = "";
  + 
  +            if (i < path.length() - 1) {
  +                b = path.substring(i + 1);
  +            } 
  + 
  +            path = a + "/" + b;
  +        }
  +	return path;
  +    }
  +    
   
   }
  
  
  
  1.2       +14 -4     jakarta-tomcat/src/share/org/apache/tomcat/core/ContextInterceptor.java
  
  Index: ContextInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextInterceptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContextInterceptor.java	2000/01/13 18:20:32	1.1
  +++ ContextInterceptor.java	2000/02/03 07:11:51	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextInterceptor.java,v 1.1 2000/01/13 18:20:32 costin Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/01/13 18:20:32 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextInterceptor.java,v 1.2 2000/02/03 07:11:51 costin Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/02/03 07:11:51 $
    *
    * ====================================================================
    *
  @@ -75,6 +75,16 @@
   public interface ContextInterceptor {
       public static final int OK=0;
       
  -    public int handleContextInit(Context ctx);
  -    public int handleContextShutdown(Context ctx);
  +    public int contextInit(Context ctx);
  +    
  +    public int contextShutdown(Context ctx);
  +
  +    /** Notify when a new servlet is added
  +     */
  +    public int addServlet( Context ctx, ServletWrapper sw);
  +
  +    /** Notify when a servlet is removed from context
  +     */
  +    public int removeServlet( Context ctx, ServletWrapper sw);
  +    
   }
  
  
  
  1.31      +4 -37     jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- ContextManager.java	2000/02/01 07:37:36	1.30
  +++ ContextManager.java	2000/02/03 07:11:51	1.31
  @@ -258,6 +258,9 @@
       public void addRequestInterceptor( RequestInterceptor ri ) {
   	if(debug>0) log(" adding request intereptor " + ri.getClass().getName());
   	requestInterceptors.addElement( ri );
  +	// XXX XXX use getMethods() to find what notifications are needed by interceptor
  +	// ( instead of calling all interceptors )
  +	// No API change - can be done later.
       }
   
       public Enumeration getRequestInterceptors() {
  @@ -414,36 +417,6 @@
       
       // -------------------- Sub-Request mechanism --------------------
   
  -    // comment from Apache http_request.c
  -    /*****************************************************************
  -     *
  -     * The sub_request mechanism.
  -     *
  -     * Fns to look up a relative URI from, e.g., a map file or SSI document.
  -     * These do all access checks, etc., but don't actually run the transaction
  -     * ... use run_sub_req below for that.  Also, be sure to use destroy_sub_req
  -     * as appropriate if you're likely to be creating more than a few of these.
  -     * (An early Apache version didn't destroy the sub_reqs used in directory
  -     * indexing.  The result, when indexing a directory with 800-odd files in
  -     * it, was massively excessive storage allocation).
  -     *
  -     * Note more manipulation of protocol-specific vars in the request
  -     * structure...
  -     */
  -    Request createRequest( String method, String uri, Request orig ) {
  -	//  See: ap_sub_req_method_uri()
  -
  -	// "clone" the usefull info out of req
  -
  -	// clean up uri ( remove .., etc )
  -
  -	// location() - find the context
  -
  -	//  interceptors
  -
  -	return null;
  -    }
  -
       /** Create a new sub-request in a given context, set the context "hint"
        *  This is a particular case of sub-request that can't get out of
        *  a context ( and we know the context before - so no need to compute it again)
  @@ -477,14 +450,8 @@
   	// XXX set query string too 
   	return lr;
       }
  -
  -    void runSubRequest( Request req ) {
  -	// invoke_handler
  -
  -	// finalize_sub_req_protocol
  -	
  -    }
   
  +    // -------------------- Utils --------------------
       // Debug ( to be replaced with the real thing )
       public void setDebug( int level ) {
   	log( "Setting debug " + level );
  
  
  
  1.25      +27 -33    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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Request.java	2000/02/01 22:53:31	1.24
  +++ Request.java	2000/02/03 07:11:51	1.25
  @@ -87,6 +87,7 @@
   
       public String getProtocol() ;
   
  +    // -------------------- Connection information
       public String getServerName() ;
   
       public void setServerName(String serverName) ;
  @@ -95,6 +96,9 @@
           
       public String getRemoteAddr() ;
   
  +    /** Expensive - should be implemented as a callback where
  +     *  possible!
  +    */
       public String getRemoteHost() ;
   
       // -------------------- Headers -------------------- 
  @@ -124,36 +128,45 @@
       public String getCharacterEncoding() ;
   
       // -------------------- Mapping --------------------
  -    // Will be set by mappers
  -    
  +    // Will be set by mappers or 
  +    // by adapter
  +
  +    /** Context - will be set by contextMap stage of request interceptors
  +     */
       public void setContext(Context context) ;
   
       public Context getContext() ;
  -
  -    public String getContextPath();
   
  -    public String getServletName();
  +    /** Everything after context path ( servletPath + pathInfo + queryInfo )
  +     */
  +    public void setLookupPath( String l ) ;
   
  -    // Hints - will be set by Interceptors if not set
  -    // by adapter
       public String getLookupPath() ;
  -
  -    public void setLookupPath( String l ) ;
   
  +    /** Real Path - should be implemented as a callback ( override it in adapters).
  +     *  Map interceptor should set it to something reasonable ( context home + path )
  +     *  MappedPath is similar - it contain mappings inside a context, for normal
  +     *      contexts pathTranslated==context.docBase + mappedPath
  +     */
       String getPathTranslated() ;
   
  +    void setPathTranslated(String path) ;
  +
  +    /** Path Info - set be mappers or from adapter
  +     */
       public String getPathInfo() ;
   
       public void setPathInfo(String pathInfo) ;
  -    
  +
  +    /** Servlet Path
  +     */
       public void setServletPath(String servletPath) ;
   
       public String getServletPath() ;
  -
  -    public String getResolvedServlet() ;
  -
  -    public void setResolvedServlet(String rs ) ;
   
  +    /** Wrapper - the servlet that will execute the request
  +     *  Similar with "handler" in Apache.
  +     */
       public ServletWrapper getWrapper() ;
       
       public void setWrapper(ServletWrapper handler) ;
  @@ -165,10 +178,6 @@
   
       public void setMappedPath( String m ) ;
   
  -    public String getResourceName() ;
  -
  -    public void setResourceName( String m ) ;
  -
       // -------------------- Security --------------------
       // Will be set by security interceptors
   
  @@ -216,9 +225,6 @@
   
       public Enumeration getParameterNames() ;
   
  -    Hashtable getParametersCopy() ;
  -
  -    
       // -------------------- Attributes --------------------
       public Object getAttribute(String name) ;
   
  @@ -232,18 +238,6 @@
       public BufferedReader getReader() 	throws IOException;
   
       public ServletInputStream getInputStream() 	throws IOException;
  -
  -    /** Fill in the buffer. This method is probably easier to implement than
  -	previous.
  -	This method should only be called from SerlvetInputStream implementations.
  -	No need to implement it if your adapter implements ServletInputStream.
  -     */
  -    public  int doRead( byte b[], int off, int len ) throws IOException;
  -
  -    // XXX I hate this - but the only way to remove this method from the
  -    // inteface is to implement it on top of doRead(b[]).
  -    // Don't use this method if you can ( it is bad for performance !!)
  -    public int doRead() throws IOException;
   
       // -------------------- Internal methods --------------------
       /** Support for "pools"
  
  
  
  1.15      +4 -1      jakarta-tomcat/src/share/org/apache/tomcat/core/RequestDispatcherImpl.java
  
  Index: RequestDispatcherImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestDispatcherImpl.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- RequestDispatcherImpl.java	2000/01/30 03:43:01	1.14
  +++ RequestDispatcherImpl.java	2000/02/03 07:11:51	1.15
  @@ -228,9 +228,12 @@
   	Object old_query_string=realRequest.getAttribute("javax.servlet.include.query_string");
   	realRequest.setAttribute("javax.servlet.include.query_string", queryString);
   
  +	
   	// Not explicitely stated, but we need to save the old parameters before
   	// adding the new ones
  -	Hashtable old_parameters=realRequest.getParametersCopy();
  +	realRequest.getParameterNames(); // force reading of parameters from POST
  +	Hashtable old_parameters=(Hashtable)realRequest.getParameters().clone();
  +
   	// NOTE: it has a side effect of _reading_ the form data - which
   	// is against the specs ( you can't read the post until asked for
   	// parameters). I see no way of dealing with that -
  
  
  
  1.13      +22 -58    jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java
  
  Index: RequestImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- RequestImpl.java	2000/02/01 22:53:31	1.12
  +++ RequestImpl.java	2000/02/03 07:11:52	1.13
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java,v 1.12 2000/02/01 22:53:31 costin Exp $
  - * $Revision: 1.12 $
  - * $Date: 2000/02/01 22:53:31 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestImpl.java,v 1.13 2000/02/03 07:11:52 costin Exp $
  + * $Revision: 1.13 $
  + * $Date: 2000/02/03 07:11:52 $
    *
    * ====================================================================
    *
  @@ -127,8 +127,6 @@
       // set by interceptors
       ServletWrapper handler = null;
       String mappedPath = null;
  -    String resolvedServlet = null;
  -    String resouceName=null;
   
       protected String scheme;
       protected String method;
  @@ -210,16 +208,6 @@
           return parameters.keys();
       }
   
  -    /**
  -     * Used by the RequestDispatcherImpl to get a copy of the
  -     * original parameters before adding parameters from the
  -     * query string, if any.
  -     */
  -    public Hashtable getParametersCopy() {
  -	handleParameters();
  -	return (Hashtable) parameters.clone();
  -    }
  -
       public String getAuthType() {
       	return authType;
       }
  @@ -243,17 +231,16 @@
   	// can be null!! -
   	return contentType;
       }
  +
  +    public void setPathTranslated(String s ) {
  +    }
       
       public String getPathTranslated() {
  -	try {
  -	    URL url = context.getResourceURL(this);
  -	    
  -	    if (url != null &&	url.getProtocol().equals("file")) {
  -		return FileUtil.patch(url.getFile());
  -	    }
  -	} catch (MalformedURLException e) {
  -	}
  -	return null;
  +	// This is the correct Path_translated, previous implementation returned
  +	// the real path for this ( i.e. the URI ).
  +
  +	// Check the PATH_TRANSLATED specs before changing!
  +	return context.getRealPath( getPathInfo() );
       }
   
   
  @@ -405,14 +392,6 @@
       }
   
       // -------------------- LookupResult 
  -    public String getResolvedServlet() {
  -	return resolvedServlet;
  -    }
  -
  -    public void setResolvedServlet(String rs ) {
  -	resolvedServlet=rs;
  -    }
  -
       public ServletWrapper getWrapper() {
   	return handler;
       }
  @@ -432,14 +411,6 @@
   	mappedPath=m;
       }
   
  -    public String getResourceName() {
  -	return resouceName;
  -    }
  -
  -    public void setResourceName( String m ) {
  -	resouceName=m;
  -    }
  -
       public void setRequestURI( String r ) {
    	this.requestURI=r;
       }
  @@ -530,7 +501,8 @@
   
       // -------------------- Utils - facade for RequestUtil
       public BufferedReader getReader()
  -	throws IOException {
  +	throws IOException
  +    {
   	return RequestUtil.getReader( this );
       }
   
  @@ -614,11 +586,20 @@
   	return remoteHost;
       }    
   
  +    /** Fill in the buffer. This method is probably easier to implement than
  +	previous.
  +	This method should only be called from SerlvetInputStream implementations.
  +	No need to implement it if your adapter implements ServletInputStream.
  +     */
       // you need to override this method if you want non-empty InputStream
       public  int doRead( byte b[], int off, int len ) throws IOException {
   	return -1; // not implemented - implement getInputStream 
       }
   
  +
  +    // XXX I hate this - but the only way to remove this method from the
  +    // inteface is to implement it on top of doRead(b[]).
  +    // Don't use this method if you can ( it is bad for performance !!)
       // you need to override this method if you want non-empty InputStream
       public int doRead() throws IOException {
   	return -1;
  @@ -629,23 +610,12 @@
       // and Tom will find the value. You can also use the static
       // methods in RequestImpl
   
  -    // server may have it pre-calculated - return null if
  -    // it doesn't
  -    public String getContextPath() {
  -	return null;
  -    }
  -
       // What's between context path and servlet name ( /servlet )
       // A smart server may use arbitrary prefixes and rewriting
       public String getServletPrefix() {
   	return null;
       }
   
  -    // Servlet name ( a smart server may use aliases and rewriting !!! )
  -    public String getServletName() {
  -	return null;
  -    }
  -
       public void setScheme( String scheme ) {
   	this.scheme=scheme;
       }
  @@ -688,11 +658,5 @@
   	sb.append( ",MP:" + getMappedPath() );
   	sb.append( "," + getWrapper() +") ");
   	return sb.toString();
  -    }
  -
  -
  -    // utility method - should be in a different class
  -    public static String getMessage( int status ) {
  -	return sm.getString("sc."+ status);
       }
   }
  
  
  
  1.4       +26 -16    jakarta-tomcat/src/share/org/apache/tomcat/core/RequestInterceptor.java
  
  Index: RequestInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestInterceptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RequestInterceptor.java	2000/02/01 07:37:36	1.3
  +++ RequestInterceptor.java	2000/02/03 07:11:52	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestInterceptor.java,v 1.3 2000/02/01 07:37:36 costin Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/02/01 07:37:36 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestInterceptor.java,v 1.4 2000/02/03 07:11:52 costin Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/02/03 07:11:52 $
    *
    * ====================================================================
    *
  @@ -64,6 +64,7 @@
   
   package org.apache.tomcat.core;
   import javax.servlet.Servlet;
  +import java.util.*;
   
   /**
    * For request processing - before calling service() ( or any LifecycleInterceptors )
  @@ -72,6 +73,13 @@
    */
   public interface RequestInterceptor {
       public static final int OK=0;
  +
  +    /** Will return the methods fow which this interceptor is interested
  +     *  in notification.
  +     */
  +    public Enumeration getMethods();
  +
  +
       
       /** Will detect the context path for a request
        */
  @@ -81,26 +89,28 @@
        */
       public int requestMap(Request request);
   
  +    /** Called before service method is invoked.
  +     */
  +    public int preService(Request request, Response response);
  +
       /** Called before the first body write, and before sending
        *  the headers. The interceptor have a chance to change the
        *  output headers.
        */
       public int beforeBody( Request request, Response response);
  -    
  -    /** Security
  +        
  +    /** Called before the output buffer is commited
        */
  -    //    public int authentication(Request request);
  -    //    public int authorization(Request request);
  -
  -    /** This handle knows how to guess the session id
  -	from a request ( SSL, cookie, rewriting ).
  -	Note that the request need
  -    */
  -    //    public int sessionId(Request request);
  +    public int beforeCommit( Request request, Response response);
   
  -    //    public int preService(Request request);
  -    //    public int postService(Request request);
  +    /** Called after the output stream is closed ( either by servlet
  +     *  or automatically at end of service )
  +     */
  +    public int afterBody( Request request, Response response);
   
  -    //    public int log(Request request);
  +    /** Called after service method ends. Log is a particular case
  +     */
  +    public int postService(Request request, Response response);
   
   }
  +
  
  
  
  1.14      +0 -6      jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java
  
  Index: Response.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Response.java	2000/02/01 21:39:38	1.13
  +++ Response.java	2000/02/03 07:11:52	1.14
  @@ -115,12 +115,6 @@
   
       public PrintWriter getWriter() throws IOException ;
   
  -    /** Write a chunk of bytes. Should be called only from ServletOutputStream implementations,
  -     *	No need to implement it if your adapter implements ServletOutputStream.
  -     *  Headers and status will be written before this method is exceuted.
  -     */
  -    public void doWrite( byte buffer[], int pos, int count) throws IOException ;
  -
       // -------------------- Buffering --------------------
       
       public int getBufferSize() ;
  
  
  
  1.13      +3 -4      jakarta-tomcat/src/share/org/apache/tomcat/core/ResponseImpl.java
  
  Index: ResponseImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ResponseImpl.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ResponseImpl.java	2000/02/03 02:13:13	1.12
  +++ ResponseImpl.java	2000/02/03 07:11:52	1.13
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ResponseImpl.java,v 1.12 2000/02/03 02:13:13 mandar Exp $
  - * $Revision: 1.12 $
  - * $Date: 2000/02/03 02:13:13 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ResponseImpl.java,v 1.13 2000/02/03 07:11:52 costin Exp $
  + * $Revision: 1.13 $
  + * $Date: 2000/02/03 07:11:52 $
    *
    * ====================================================================
    *
  @@ -403,7 +403,6 @@
   	return out;
       }
       
  -
       /** Write a chunk of bytes. Should be called only from ServletOutputStream implementations,
        *	No need to implement it if your adapter implements ServletOutputStream.
        *  Headers and status will be written before this method is exceuted.
  
  
  
  1.16      +13 -3     jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java
  
  Index: ServletWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ServletWrapper.java	2000/01/15 03:52:57	1.15
  +++ ServletWrapper.java	2000/02/03 07:11:52	1.16
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java,v 1.15 2000/01/15 03:52:57 costin Exp $
  - * $Revision: 1.15 $
  - * $Date: 2000/01/15 03:52:57 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java,v 1.16 2000/02/03 07:11:52 costin Exp $
  + * $Revision: 1.16 $
  + * $Date: 2000/02/03 07:11:52 $
    *
    * ====================================================================
    *
  @@ -104,6 +104,8 @@
       protected long lastAccessed;
       protected int serviceCount = 0;
   
  +    int loadOnStartup=0;
  +    
       ServletWrapper(Context context) {
           this.context = context;
           config = new ServletConfigImpl(context);
  @@ -113,6 +115,14 @@
   	return context;
       }
   
  +    public void setLoadOnStartUp( int level ) {
  +	loadOnStartup=level;
  +    }
  +
  +    public int getLoadOnStartUp() {
  +	return loadOnStartup;
  +    }
  +    
       void setReloadable(boolean reloadable) {
   	isReloadable = reloadable;
       }
  
  
  
  1.4       +2 -25     jakarta-tomcat/src/share/org/apache/tomcat/deployment/WebApplicationReader.java
  
  Index: WebApplicationReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/deployment/WebApplicationReader.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WebApplicationReader.java	2000/01/30 04:22:46	1.3
  +++ WebApplicationReader.java	2000/02/03 07:11:53	1.4
  @@ -814,34 +814,11 @@
   	    // XXX ugly, but outside of context - the whole thing will be
   	    // rewriten, so don't worry
   	    
  -	    // if the resource was already defined, override with the new definition
  -	    // XXX I have very little ideea about what it does !
  -	    if (removeResource) {
  -
  -	        Enumeration levels = ctx.getInitLevels();
  -
  -		while (levels.hasMoreElements()) {
  -		    Integer level = (Integer)levels.nextElement();
  -		    Enumeration servletsOnLevel=ctx.getLoadableServlets( level );
  -		    
  -		    Vector buf = new Vector();
  -		    while (servletsOnLevel.hasMoreElements()) {
  -		        String servletName = (String)servletsOnLevel.nextElement();
  -
  -			if (ctx.containsServletByName(servletName)) {
  -			    buf.addElement(servletName);
  -			}
  -		    }
  -		    ctx.setLoadableServlets(level, buf);
  -		}
  -	    }
  -	    
   	    int loadOnStartUp = webComponentDescriptor.getLoadOnStartUp();
   
               if (loadOnStartUp > Integer.MIN_VALUE) {
  -	        Integer key = new Integer(loadOnStartUp);
  -		ctx.addLoadableServlet( key, name );
  -		
  +		ServletWrapper swrap=ctx.getServletByName(name);
  +		swrap.setLoadOnStartUp( loadOnStartUp );
   	    }
   
   	    Enumeration enum =
  
  
  
  1.3       +1 -1      jakarta-tomcat/src/share/org/apache/tomcat/loader/ServletClassLoaderImpl.java
  
  Index: ServletClassLoaderImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/loader/ServletClassLoaderImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServletClassLoaderImpl.java	2000/01/18 06:17:44	1.2
  +++ ServletClassLoaderImpl.java	2000/02/03 07:11:54	1.3
  @@ -87,7 +87,7 @@
       }
   
       private void initURLs() {
  -        URL baseURL = context.getServletBase();
  +        URL baseURL = context.getDocumentBase();
           String protocol = baseURL.getProtocol();
           int port = baseURL.getPort();
           String hostname = baseURL.getHost();
  
  
  
  1.3       +2 -9      jakarta-tomcat/src/share/org/apache/tomcat/request/FixHeaders.java
  
  Index: FixHeaders.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/FixHeaders.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FixHeaders.java	2000/02/01 21:39:39	1.2
  +++ FixHeaders.java	2000/02/03 07:11:54	1.3
  @@ -72,19 +72,12 @@
    *  Will generate the output headers ( cookies, etc ) plus tomcat-specific headers.
    * 
    */
  -public class FixHeaders implements RequestInterceptor {
  +public class FixHeaders extends  BaseInterceptor implements RequestInterceptor {
       
       public FixHeaders() {
  +	methods.addElement("beforeBody");
       }
   	
  -    public int requestMap(Request request ) {
  -	return 0;
  -    }
  -
  -    public int contextMap( Request rrequest ) {
  -	return 0;
  -    }
  -
       public int beforeBody( Request request, Response response ) {
   	HttpDate date = new HttpDate(System.currentTimeMillis());
   	response.setHeader("Date", date.toString());
  
  
  
  1.7       +3 -1      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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SessionInterceptor.java	2000/02/01 21:39:39	1.6
  +++ SessionInterceptor.java	2000/02/03 07:11:54	1.7
  @@ -77,9 +77,11 @@
    * add new interceptors for other methods.
    * 
    */
  -public class SessionInterceptor implements RequestInterceptor {
  +public class SessionInterceptor extends  BaseInterceptor implements RequestInterceptor {
       
       public SessionInterceptor() {
  +	methods.addElement("requestMap");
  +	methods.addElement("beforeBody");
       }
   	
       public int requestMap(Request request ) {
  
  
  
  1.5       +3 -1      jakarta-tomcat/src/share/org/apache/tomcat/request/SimpleMapper.java
  
  Index: SimpleMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/SimpleMapper.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimpleMapper.java	2000/02/01 22:53:31	1.4
  +++ SimpleMapper.java	2000/02/03 07:11:54	1.5
  @@ -72,11 +72,13 @@
    *  For "production" environment you should use either an optimized version
    *  or a real web server parser.
    */
  -public class SimpleMapper  implements  RequestInterceptor {
  +public class SimpleMapper extends  BaseInterceptor implements RequestInterceptor {
       int debug=0;
       ContextManager cm;
       
       public SimpleMapper() {
  +	methods.addElement("contextMap");
  +	methods.addElement("requestMap");	
       }
   
       public void setContextManager( ContextManager cm ) {
  
  
  
  1.1                  jakarta-tomcat/src/share/org/apache/tomcat/request/BaseInterceptor.java
  
  Index: BaseInterceptor.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.request;
  
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.util.*;
  import org.apache.tomcat.deployment.*;
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import javax.servlet.http.*;
  
  /**
   */
  public class BaseInterceptor implements RequestInterceptor {
      
      protected Vector methods=new Vector();
      
      public BaseInterceptor() {
      }
  	
      public int requestMap(Request request ) {
  	return 0;
      }
  
      public int contextMap( Request rrequest ) {
  	return 0;
      }
  
      public int preService(Request request, Response response) {
  	return 0;
      }
  
      public int beforeBody( Request rrequest, Response response ) {
  	return 0;
      }
  
      public int beforeCommit( Request request, Response response) {
  	return 0;
      }
  
  
      public int afterBody( Request request, Response response) {
  	return 0;
      }
  
      public int postService(Request request, Response response) {
  	return 0;
      }
  
      public Enumeration getMethods() {
  	return methods.elements();
      }
  
  }
  
  
  
  1.6       +14 -11    jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpResponseAdapter.java
  
  Index: HttpResponseAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpResponseAdapter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HttpResponseAdapter.java	2000/02/01 07:37:39	1.5
  +++ HttpResponseAdapter.java	2000/02/03 07:11:55	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpResponseAdapter.java,v 1.5 2000/02/01 07:37:39 costin Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/02/01 07:37:39 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpResponseAdapter.java,v 1.6 2000/02/03 07:11:55 costin Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/02/03 07:11:55 $
    *
    * ====================================================================
    *
  @@ -113,14 +113,17 @@
   	Enumeration e = headers.names();
   	while (e.hasMoreElements()) {
   	    String name = (String)e.nextElement();
  -	    String value = headers.getHeader(name);
  -	    headersSB.setLength(0);
  -	    headersSB.append(name).append(": ").append(value).append("\r\n");
  -	    try {
  -		sout.write( headersSB.toString().getBytes(Constants.CharacterEncoding.Default) );
  -	    } catch( IOException ex ) {
  -		ex.printStackTrace();
  -		//XXX mark the error - should abandon everything 
  +	    String values[] = headers.getHeaders(name);
  +	    for( int i=0; i< values.length; i++ ) {
  +		String value=values[i];
  +		headersSB.setLength(0);
  +		headersSB.append(name).append(": ").append(value).append("\r\n");
  +		try {
  +		    sout.write( headersSB.toString().getBytes(Constants.CharacterEncoding.Default) );
  +		} catch( IOException ex ) {
  +		    ex.printStackTrace();
  +		    //XXX mark the error - should abandon everything 
  +		}
   	    }
   	}
   	sout.write( CRLF, 0, 2 );
  
  
  
  1.10      +6 -6      jakarta-tomcat/src/shell/tomcat.sh
  
  Index: tomcat.sh
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/shell/tomcat.sh,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- tomcat.sh	2000/01/27 01:24:51	1.9
  +++ tomcat.sh	2000/02/03 07:11:55	1.10
  @@ -1,6 +1,6 @@
   #!/bin/sh
   #
  -# $Id: tomcat.sh,v 1.9 2000/01/27 01:24:51 costin Exp $
  +# $Id: tomcat.sh,v 1.10 2000/02/03 07:11:55 costin Exp $
   
   # Shell script to start and stop the server
   
  @@ -62,13 +62,13 @@
   
   oldCP=$CLASSPATH
    
  -CLASSPATH=${TOMCAT_HOME}/lib/webserver.jar
  -CLASSPATH=${CLASSPATH}:${TOMCAT_HOME}/lib/servlet.jar
  -CLASSPATH=${CLASSPATH}:${TOMCAT_HOME}/lib/jasper.jar
  -CLASSPATH=${CLASSPATH}:${TOMCAT_HOME}/lib/xml.jar
  -## CLASSPATH=${CLASSPATH}:${TOMCAT_HOME}/webpages/WEB-INF/classes/jsp/beans
  +CLASSPATH=.
  +for i in ${TOMCAT_HOME}/lib/* ; do
  +  CLASSPATH=${CLASSPATH}:$i
  +done
   
   CLASSPATH=${CLASSPATH}:${JAVA_HOME}/lib/tools.jar
  +echo XXX $CLASSPATH
   
   
   # Backdoor classpath setting for development purposes when all classes
  
  
  
  1.1                  jakarta-tomcat/src/shell/watchdog.sh
  
  Index: watchdog.sh
  ===================================================================
  #!/bin/sh
  
  # set tomcat env 
  . bin/tomcat.sh env
  
  ant -Dtomcat.home $TOMCAT_HOME -f conf/watchdog.xml servlet-test jsp-test