tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup ContextConfig.java
Date Sat, 29 Apr 2000 23:20:35 GMT
craigmcc    00/04/29 16:20:34

  Modified:    proposals/catalina/src/conf server.xml web.xml
               proposals/catalina/src/share/org/apache/tomcat/core
                        ContainerBase.java StandardContext.java
                        StandardWrapperValve.java
               proposals/catalina/src/share/org/apache/tomcat/startup
                        ContextConfig.java
  Added:       proposals/catalina/src/share/org/apache/tomcat/servlets
                        InvokerServlet.java
  Log:
  Correct a mapping bug on prefix matching that was setting getPathInfo() incorrectly.
  
  Add the first crack at the invoker servlet.  It seems to work correctly itself,
  but no output from the called servlet shows up at the browser.  Ultimately, this
  will use RequestDispatcher.forward() to call the invoked servlet -- right now it
  is using a kludge through access to Catalina internals.
  
  Right now, ServletWrapperValve has a log() statement for each request, to show what
  HTTP method and request URI it thinks is being requested.  This will help isolate why
  OPTIONS requests don't seem to be showing up -- there shouldn't be anything in
  Catalina itself that cares what the method is, so there might be something inside
  javax.servlet.http.HttpServlet itself that messes this up.
  
  Revision  Changes    Path
  1.11      +2 -2      jakarta-tomcat/proposals/catalina/src/conf/server.xml
  
  Index: server.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/conf/server.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- server.xml	2000/04/29 05:59:51	1.10
  +++ server.xml	2000/04/29 23:20:31	1.11
  @@ -48,9 +48,9 @@
         </Context>
   
         <!-- Examples Context -->
  -      <Context path="/examples" docBase="webapps/examples" debug="0">
  +      <Context path="/examples" docBase="webapps/examples" debug="2">
           <Listener className="org.apache.tomcat.startup.ContextConfig"
  -	          debug="0"/>
  +	          debug="2"/>
           <Manager className="org.apache.tomcat.session.StandardManager"
   	         checkInterval="15" maxActiveSessions="100"
                    pathname="sessions/localhost_examples.sessions"/>
  
  
  
  1.3       +2 -1      jakarta-tomcat/proposals/catalina/src/conf/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/conf/web.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- web.xml	2000/04/29 18:24:24	1.2
  +++ web.xml	2000/04/29 23:20:31	1.3
  @@ -15,7 +15,7 @@
       <load-on-startup>1</load-on-startup>
       <init-param>
         <param-name>debug</param-name>
  -      <param-value>99</param-value>
  +      <param-value>0</param-value>
       </init-param>
     </servlet>
   
  @@ -23,6 +23,7 @@
     <servlet>
       <servlet-name>invoker</servlet-name>
       <servlet-class>org.apache.tomcat.servlets.InvokerServlet</servlet-class>
  +    <load-on-startup>2</load-on-startup>
       <init-param>
         <param-name>debug</param-name>
         <param-value>99</param-value>
  
  
  
  1.15      +12 -10    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java
  
  Index: ContainerBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ContainerBase.java	2000/04/29 05:59:53	1.14
  +++ ContainerBase.java	2000/04/29 23:20:32	1.15
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java,v
1.14 2000/04/29 05:59:53 craigmcc Exp $
  - * $Revision: 1.14 $
  - * $Date: 2000/04/29 05:59:53 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java,v
1.15 2000/04/29 23:20:32 craigmcc Exp $
  + * $Revision: 1.15 $
  + * $Date: 2000/04/29 23:20:32 $
    *
    * ====================================================================
    *
    * 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
  @@ -15,7 +15,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
  @@ -23,15 +23,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"
  @@ -59,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   
   package org.apache.tomcat.core;
  @@ -149,7 +149,7 @@
    * class comments of the implementation class.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.14 $ $Date: 2000/04/29 05:59:53 $
  + * @version $Revision: 1.15 $ $Date: 2000/04/29 23:20:32 $
    */
   
   public abstract class ContainerBase
  @@ -780,6 +780,8 @@
   		    ((Lifecycle) child).start();
   		} catch (LifecycleException e) {
   		    log("ContainerBase.addChild: start: ", e);
  +		    throw new IllegalStateException
  +		        ("ContainerBase.addChild: start: " + e);
   		}
   	    }
   	    children.put(child.getName(), child);
  
  
  
  1.13      +16 -17    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- StandardContext.java	2000/04/29 05:59:53	1.12
  +++ StandardContext.java	2000/04/29 23:20:32	1.13
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
1.12 2000/04/29 05:59:53 craigmcc Exp $
  - * $Revision: 1.12 $
  - * $Date: 2000/04/29 05:59:53 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
1.13 2000/04/29 23:20:32 craigmcc Exp $
  + * $Revision: 1.13 $
  + * $Date: 2000/04/29 23:20:32 $
    *
    * ====================================================================
    *
    * 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
  @@ -15,7 +15,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
  @@ -23,15 +23,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"
  @@ -59,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   
   package org.apache.tomcat.core;
  @@ -92,7 +92,7 @@
    * requests directed to a particular servlet.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.12 $ $Date: 2000/04/29 05:59:53 $
  + * @version $Revision: 1.13 $ $Date: 2000/04/29 23:20:32 $
    */
   
   public final class StandardContext
  @@ -254,8 +254,8 @@
   	return (this.distributable);
   
       }
  -    
  -    
  +
  +
       /**
        * Set the distributable flag for this web application.
        *
  @@ -464,7 +464,7 @@
        * @param type Java class name of the EJB bean implementation class
        * @param home Java class name of the EJB home implementation class
        * @param remote Java class name of the EJB remote implementation class
  -     * @param link Optional link to a J2EE EJB definition 
  +     * @param link Optional link to a J2EE EJB definition
        */
       public void addEjb(String name, String description,
   		       String type, String home,
  @@ -1114,8 +1114,8 @@
   		int slash = servletPath.lastIndexOf("/");
   		if (slash < 0)
   		    break;
  -		String pattern = servletPath.substring(0, slash) + "/*";
  -		name = (String) servletMappings.get(pattern);
  +		servletPath = servletPath.substring(0, slash);
  +		name = (String) servletMappings.get(servletPath + "/*");
   		if (name != null)
   		    wrapper = (Wrapper) findChild(name);
   		if (wrapper != null) {
  @@ -1124,7 +1124,6 @@
   			pathInfo = null;
   		    break;
   		}
  -		servletPath = servletPath.substring(0, slash);
   	    }
   	}
   
  @@ -1168,7 +1167,7 @@
   	    log(sm.getString("standardContext.mappingError", relativeURI));
   	    return (null);
   	}
  -	
  +
   
   	// Update the Request (if requested) and return this Wrapper
   	if (debug > 0)
  
  
  
  1.6       +14 -10    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java
  
  Index: StandardWrapperValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StandardWrapperValve.java	2000/04/29 18:24:25	1.5
  +++ StandardWrapperValve.java	2000/04/29 23:20:33	1.6
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java,v
1.5 2000/04/29 18:24:25 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/04/29 18:24:25 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardWrapperValve.java,v
1.6 2000/04/29 23:20:33 craigmcc Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/04/29 23:20:33 $
    *
    * ====================================================================
    *
    * 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
  @@ -15,7 +15,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
  @@ -23,15 +23,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"
  @@ -59,7 +59,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   
   package org.apache.tomcat.core;
  @@ -87,7 +87,7 @@
    * <code>StandardWrapper</code> container implementation.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.5 $ $Date: 2000/04/29 18:24:25 $
  + * @version $Revision: 1.6 $ $Date: 2000/04/29 23:20:33 $
    */
   
   final class StandardWrapperValve
  @@ -130,12 +130,16 @@
   	    if ((servlet instanceof HttpServlet) &&
   		(sreq instanceof HttpServletRequest) &&
   		(sres instanceof HttpServletResponse)) {
  +		log("Processing request " + ((HttpServletRequest) sreq).getMethod() +
  +		    " " + ((HttpServletRequest) sreq).getRequestURI());
   		((HttpServlet) servlet).service((HttpServletRequest) sreq,
   						(HttpServletResponse) sres);
   	    } else {
   		servlet.service(sreq, sres);
   	    }
   	    wrapper.deallocate(servlet);
  +	    log(" Flushing response buffer");
  +	    sres.flushBuffer();
   	} catch (Throwable t) {
   	    log(sm.getString("standardWrapper.servletException"), t);
   	    wrapper.deallocate(servlet);
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/InvokerServlet.java
  
  Index: InvokerServlet.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/InvokerServlet.java,v
1.1 2000/04/29 23:20:33 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/04/29 23:20:33 $
   *
   * ====================================================================
   *
   * 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.servlets;
  
  
  import java.io.BufferedInputStream;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.InputStream;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.sql.Timestamp;
  import java.util.Enumeration;
  import java.util.Vector;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.ServletOutputStream;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.tomcat.Context;
  import org.apache.tomcat.HttpRequest;
  import org.apache.tomcat.HttpResponse;
  import org.apache.tomcat.Wrapper;
  import org.apache.tomcat.util.xml.SaxContext;
  import org.apache.tomcat.util.xml.XmlAction;
  import org.apache.tomcat.util.xml.XmlMapper;
  
  
  /**
   * The default servlet-invoking servlet for most web applications,
   * used to serve requests to servlets that have not been registered
   * in the web application deployment descriptor.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/04/29 23:20:33 $
   */
  
  public final class InvokerServlet
      extends HttpServlet {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The Context container associated with our web application.
       */
      private Context context = null;
  
  
      /**
       * The debugging detail level for this servlet.
       */
      private int debug = 0;
  
  
      /**
       * The class name of new Wrapper classes that we will construct dynamically.
       */
      private String wrapperClass = "org.apache.tomcat.core.StandardWrapper";
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Finalize this servlet.
       */
      public void destroy() {
  
  	;	// No actions necessary
  
      }
  
  
      /**
       * Process a GET request for the specified resource.
       *
       * @param request The servlet request we are processing
       * @param response The servlet response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet-specified error occurs
       */
      public void doGet(HttpServletRequest request,
  		      HttpServletResponse response)
  	throws IOException, ServletException {
  
  	serveRequest(request, response);
  
      }
  
  
      /**
       * Process a HEAD request for the specified resource.
       *
       * @param request The servlet request we are processing
       * @param response The servlet response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet-specified error occurs
       */
      public void doHead(HttpServletRequest request,
  		       HttpServletResponse response)
  	throws IOException, ServletException {
  
  	serveRequest(request, response);
  
      }
  
  
      /**
       * Process a POST request for the specified resource.
       *
       * @param request The servlet request we are processing
       * @param response The servlet response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet-specified error occurs
       */
      public void doPost(HttpServletRequest request,
  		       HttpServletResponse response)
  	throws IOException, ServletException {
  
  	serveRequest(request, response);
  
      }
  
  
      /**
       * Initialize this servlet.
       */
      public void init() throws ServletException {
  
  	// Set our properties from the initialization parameters
  	String value = null;
  	try {
  	    value = getServletConfig().getInitParameter("debug");
  	    debug = Integer.parseInt(value);
  	} catch (Throwable t) {
  	    ;
  	}
  
  	// Identify the internal container resources we need
  	Wrapper wrapper = (Wrapper) getServletConfig();
  	context = (Context) wrapper.getParent();
  
  	if (debug > 0)
  	    log("InvokerServlet.init: Associated with Context '" +
  	        context.getPath() + "'");
  
      }
  
  
  
      // -------------------------------------------------------- Private Methods
  
  
      /**
       * Serve the specified request, creating the corresponding response.
       * After the first time a particular servlet class is requested, it will
       * be served directly (like any registered servlet) because it will have
       * been registered and mapped in our associated Context.
       *
       * @param request The servlet request we are processing
       * @param response The servlet response we are creating
       *
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet-specified error occurs
       */
      public void serveRequest(HttpServletRequest request,
  		             HttpServletResponse response)
  	throws IOException, ServletException {
  
  	// Identify the class name of the servlet we want
  	if (debug > 0)
  	    log("InvokerServlet.serveRequest: Serving request " +
  	    	request.getMethod() + " " + request.getRequestURI());
  	String pathInfo = request.getPathInfo();
  	if (pathInfo == null) {
  	    if (debug > 0)
  	        log("InvokerServlet.serveRequest:  Invalid pathInfo '" +
  	            pathInfo + "'");
  	    response.sendError(HttpServletResponse.SC_BAD_REQUEST,
  	                       request.getRequestURI());
  	    return;
          }
  
  	// Create and register a new Wrapper for this servlet class
  	String servletClass = pathInfo.substring(1);
  	int slash = servletClass.indexOf("/");
  	if (slash >= 0) {
  	    pathInfo = servletClass.substring(slash);
  	    servletClass = servletClass.substring(0, slash);
          } else {
  	    pathInfo = "";
          }
  	String name = "org.apache.tomcat.INVOKER." + servletClass;
  	String path = request.getServletPath() + "/" + servletClass;
  	Wrapper wrapper = null;
  	if (debug > 0)
  	    log("InvokerServlet.serveRequest:  Creating wrapper for '" +
  	        servletClass + "'");
  	try {
  	    Class wrapperClassObject = Class.forName(wrapperClass);
  	    wrapper = (Wrapper) wrapperClassObject.newInstance();
  	    wrapper.setName(name);
  	    wrapper.setLoadOnStartup(0);
  	    wrapper.setServletClass(servletClass);
  	    context.addChild(wrapper);
  	    context.addServletMapping(path, name);
          } catch (Throwable t) {
  	    log("InvokerServlet.serveRequest", t);
  	    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
  	    return;
          }
  
  	// Pass this request on to the newly created wrapper
  	// FIXME - use RequestDispatcher.forward() when available
  	if (debug > 0)
  	    log("InvokerServlet.serveRequest:  Forwarding to servlet");
  	try {
  	    HttpRequest hrequest = (HttpRequest) request;
  	    HttpResponse hresponse = (HttpResponse) response;
  	    hrequest.setServletPath(path);
  	    if (pathInfo.length() > 0)
  	        hrequest.setPathInfo(pathInfo);
  	    else
  	        hrequest.setPathInfo(null);
  	    wrapper.invoke(hrequest, hresponse);
          } catch (ClassCastException e) {
  	    log("InvokerServlet.serveRequest", e);
  	    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
  	    return;
          }
  	/*
  	RequestDispatcher rd =
  	    getServletContext().getRequestDispatcher(path + pathInfo);
  	rd.forward(request, response);
  	*/
  
  
      }
  
  
  }
  
  
  
  1.5       +81 -10    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java
  
  Index: ContextConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContextConfig.java	2000/04/29 05:59:56	1.4
  +++ ContextConfig.java	2000/04/29 23:20:34	1.5
  @@ -1,13 +1,13 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java,v
1.4 2000/04/29 05:59:56 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/04/29 05:59:56 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java,v
1.5 2000/04/29 23:20:34 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/04/29 23:20:34 $
    *
    * ====================================================================
    *
    * 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
  @@ -15,7 +15,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
  @@ -23,15 +23,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"
  @@ -59,21 +59,25 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */ 
  + */
   
   
   package org.apache.tomcat.startup;
   
   
  +import java.io.File;
   import java.io.FileInputStream;
   import java.io.FileNotFoundException;
   import java.io.InputStream;
   import java.io.IOException;
   import java.lang.reflect.InvocationTargetException;
  +import java.net.MalformedURLException;
  +import java.net.URL;
   import org.apache.tomcat.Context;
   import org.apache.tomcat.Lifecycle;
   import org.apache.tomcat.LifecycleEvent;
   import org.apache.tomcat.LifecycleListener;
  +import org.apache.tomcat.Loader;
   import org.apache.tomcat.Logger;
   import org.apache.tomcat.Resources;
   import org.apache.tomcat.Wrapper;
  @@ -92,7 +96,7 @@
    * resource for this web application.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2000/04/29 05:59:56 $
  + * @version $Revision: 1.5 $ $Date: 2000/04/29 23:20:34 $
    */
   
   public final class ContextConfig
  @@ -379,6 +383,70 @@
   
   
       /**
  +     * Configure the repositories for the Loader associated with
  +     * this Context.
  +     */
  +    private void loaderConfig() {
  +
  +	if (debug > 0)
  +	    log("Configuring class loader repositories");
  +
  +	// Identify the components we will need
  +	// FIXME - dependency on StandardLoader versus Loader?
  +	StandardLoader loader = null;
  +	try {
  +	    loader = (StandardLoader) context.getLoader();
  +        } catch (ClassCastException e) {
  +	    ;
  +        }
  +	if (loader == null)
  +	    return;
  +	Resources resources = context.getResources();
  +
  +	// Add the WEB-INF/classes subdirectory
  +	URL classesURL = null;
  +	try {
  +	    classesURL = resources.getResource("/WEB-INF/classes");
  +        } catch (MalformedURLException e) {
  +	    ;
  +	}
  +	if ((classesURL != null) && "file".equals(classesURL.getProtocol())) {
  +	    File classesFile = new File(classesURL.getFile());
  +	    if (classesFile.exists() && classesFile.canRead() &&
  +	        classesFile.isDirectory()) {
  +		if (debug > 0)
  +		    log(" Adding '" + classesFile.getAbsolutePath() + "'");
  +		loader.addRepository(classesFile.getAbsolutePath());
  +	    }
  +	}
  +
  +	// Add the WEB-INF/lib/*.jar files
  +	URL libURL = null;
  +	try {
  +	    libURL = resources.getResource("/WEB-INF/lib");
  +	} catch (MalformedURLException e) {
  +	    ;
  +	}
  +	if ((libURL != null) && "file".equals(libURL.getProtocol())) {
  +	    File libFile = new File(libURL.getFile());
  +	    if (libFile.exists() && libFile.canRead() &&
  +	        libFile.isDirectory()) {
  +		String filenames[] = libFile.list();
  +		for (int i = 0; i < filenames.length; i++) {
  +		    if (!filenames[i].endsWith(".jar"))
  +		        continue;
  +		    File jarFile = new File(libFile, filenames[i]);
  +		    if (debug > 0)
  +		        log(" Adding '" + jarFile.getAbsolutePath() + "'");
  +		    loader.addRepository(jarFile.getAbsolutePath());
  +		}
  +	    }
  +	}
  +
  +    }
  +
  +
  +    /**
        * Log a message on the Logger associated with our Context (if any)
        *
        * @param message Message to be logged
  @@ -452,6 +520,9 @@
   		log(sm.getString("contextConfig.defaultResources"));
   	    context.setResources(new StandardResources());
   	}
  +
  +	// Configure the Loader for this Context
  +	loaderConfig();
   
   	// Process the default and application web.xml files
   	defaultConfig(mapper);
  
  
  

Mime
View raw message