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 Constants.java ContextConfig.java LocalStrings.properties
Date Tue, 25 Apr 2000 20:11:31 GMT
craigmcc    00/04/25 13:11:30

  Modified:    proposals/catalina/src/conf server.xml
               proposals/catalina/src/share/org/apache/tomcat Context.java
               proposals/catalina/src/share/org/apache/tomcat/core
                        StandardContext.java StandardHost.java
                        StandardResources.java StandardServer.java
               proposals/catalina/src/share/org/apache/tomcat/deploy
                        ContextEnvironment.java
  Added:       proposals/catalina/src/share/org/apache/tomcat/startup
                        Constants.java ContextConfig.java
                        LocalStrings.properties
  Log:
  Check in the beginnings of context configuration from the web.xml file,
  plus other changes to optimize the application of the map() methods in
  the container hierarchy.
  
  This stuff doesn't work yet -- debugging it is the next step.
  
  Revision  Changes    Path
  1.7       +9 -8      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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- server.xml	2000/04/22 23:15:49	1.6
  +++ server.xml	2000/04/25 20:11:28	1.7
  @@ -40,15 +40,16 @@
                 directory="logs" prefix="localhost_log." suffix=".txt"
                 timestamp="true"/>
   
  -      <Context path="/" docBase="webpages"/>
  -
  -      <Context path="/examples" docBase="examples">
  -	<!-- Processes all requests for this Context -->
  -        <Valve className="org.apache.tomcat.security.HttpSecurityValve"/>
  -	<!-- Used to manage sessions for this Context only -->
  +      <!-- Initial context to start playing with -->
  +      <Context path="/" docBase="webpages/ROOT">
  +        <Listener className="org.apache.tomcat.startup.ContextConfig"
  +	          debug="1"/>
  +        <!--
           <Manager className="org.apache.tomcat.session.StandardManager"
  -                 checkInterval="15" maxActiveSessions="100"
  -		 pathname="localhost_sessions/examples.sessions"/>
  +	         checkInterval="15" maxActiveSessions="100"
  +                 pathname="localhost_sessions/ROOT.sessions"/>
  +        -->
  +        <Resources className="org.apache.tomcat.resources.StandardResources"/>
         </Context>
   
       </Host>
  
  
  
  1.8       +75 -4     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Context.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Context.java	2000/04/23 01:42:27	1.7
  +++ Context.java	2000/04/25 20:11:28	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Context.java,v
1.7 2000/04/23 01:42:27 craigmcc Exp $
  - * $Revision: 1.7 $
  - * $Date: 2000/04/23 01:42:27 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Context.java,v
1.8 2000/04/25 20:11:28 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2000/04/25 20:11:28 $
    *
    * ====================================================================
    *
  @@ -90,7 +90,7 @@
    * <p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2000/04/23 01:42:27 $
  + * @version $Revision: 1.8 $ $Date: 2000/04/25 20:11:28 $
    */
   
   public interface Context extends Container {
  @@ -114,6 +114,22 @@
   
   
       /**
  +     * Return the document root for this Context.  This can be an absolute
  +     * pathname, a relative pathname, or a URL.
  +     */
  +    public String getDocBase();
  +
  +
  +    /**
  +     * Set the document root for this Context.  This can be an absolute
  +     * pathname, a relative pathname, or a URL.
  +     *
  +     * @param docBase The new document root
  +     */
  +    public void setDocBase(String docBase);
  +
  +
  +    /**
        * Return the login configuration descriptor for this web application.
        */
       public LoginConfig getLoginConfig();
  @@ -163,6 +179,22 @@
       public void setSessionTimeout(int timeout);
   
   
  +    /**
  +     * Return the Java class name of the Wrapper implementation used
  +     * for servlets registered in this Context.
  +     */
  +    public String getWrapperClass();
  +
  +
  +    /**
  +     * Set the Java class name of the Wrapper implementation used
  +     * for servlets registered in this Context.
  +     *
  +     * @param wrapperClass The new wrapper class
  +     */
  +    public void setWrapperClass(String wrapperClass);
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -181,6 +213,21 @@
   
   
       /**
  +     * Add a new EJB resource reference for this web application.
  +     *
  +     * @param name EJB resource reference name
  +     * @param description EJB resource reference description
  +     * @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 
  +     */
  +    public void addEjb(String name, String description,
  +		       String type, String home,
  +		       String remote, String link);
  +
  +
  +    /**
        * Add an environment entry for this web application.
        *
        * @param environment New environment entry
  @@ -189,6 +236,18 @@
   
   
       /**
  +     * Add an environment entry for this web application.
  +     *
  +     * @param name Name of the environment entry
  +     * @param description Description of the environment entry
  +     * @param type Java class of the environment entry
  +     * @param value Value of the environment entry (as a String)
  +     */
  +    public void addEnvironment(String name, String description,
  +			       String type, String value);
  +
  +
  +    /**
        * Add an error page for the specified Java exception.
        *
        * @param exception Fully qualified exception class
  @@ -223,6 +282,18 @@
        * @param resource New resource reference
        */
       public void addResource(ContextResource resource);
  +
  +
  +    /**
  +     * Add a resource reference for this web application.
  +     *
  +     * @param name Name of this resource reference
  +     * @param description Description of this resource reference
  +     * @param type Java class of this resource reference
  +     * @param auth Authentication technique used by this resource reference
  +     */
  +    public void addResource(String name, String description,
  +			    String type, String auth);
   
   
       /**
  
  
  
  1.10      +119 -4    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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- StandardContext.java	2000/04/23 01:42:33	1.9
  +++ StandardContext.java	2000/04/25 20:11:28	1.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
1.9 2000/04/23 01:42:33 craigmcc Exp $
  - * $Revision: 1.9 $
  - * $Date: 2000/04/23 01:42:33 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
1.10 2000/04/25 20:11:28 craigmcc Exp $
  + * $Revision: 1.10 $
  + * $Date: 2000/04/25 20:11:28 $
    *
    * ====================================================================
    *
  @@ -92,7 +92,7 @@
    * requests directed to a particular servlet.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.9 $ $Date: 2000/04/23 01:42:33 $
  + * @version $Revision: 1.10 $ $Date: 2000/04/25 20:11:28 $
    */
   
   public final class StandardContext
  @@ -136,6 +136,12 @@
   
   
       /**
  +     * The document root for this web application.
  +     */
  +    private String docBase = null;
  +
  +
  +    /**
        * The EJB resource references for this web application, keyed by name.
        */
       private Hashtable ejbs = new Hashtable();
  @@ -231,6 +237,12 @@
       private Hashtable welcomeFiles = new Hashtable();
   
   
  +    /**
  +     * Java class name of the Wrapper class implementation we use.
  +     */
  +    private String wrapperClass = "org.apache.tomcat.core.StandardWrapper";
  +
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -261,6 +273,30 @@
   
   
       /**
  +     * Return the document root for this Context.  This can be an absolute
  +     * pathname, a relative pathname, or a URL.
  +     */
  +    public String getDocBase() {
  +
  +	return (this.docBase);
  +
  +    }
  +
  +
  +    /**
  +     * Set the document root for this Context.  This can be an absolute
  +     * pathname, a relative pathname, or a URL.
  +     *
  +     * @param docBase The new document root
  +     */
  +    public void setDocBase(String docBase) {
  +
  +	this.docBase = docBase;
  +
  +    }
  +
  +
  +    /**
        * Return the login configuration descriptor for this web application.
        */
       public LoginConfig getLoginConfig() {
  @@ -350,6 +386,30 @@
       }
   
   
  +    /**
  +     * Return the Java class name of the Wrapper implementation used
  +     * for servlets registered in this Context.
  +     */
  +    public String getWrapperClass() {
  +
  +	return (this.wrapperClass);
  +
  +    }
  +
  +
  +    /**
  +     * Set the Java class name of the Wrapper implementation used
  +     * for servlets registered in this Context.
  +     *
  +     * @param wrapperClass The new wrapper class
  +     */
  +    public void setWrapperClass(String wrapperClass) {
  +
  +	this.wrapperClass = wrapperClass;
  +
  +    }
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -397,6 +457,25 @@
   
   
       /**
  +     * Add a new EJB resource reference for this web application.
  +     *
  +     * @param name EJB resource reference name
  +     * @param description EJB resource reference description
  +     * @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 
  +     */
  +    public void addEjb(String name, String description,
  +		       String type, String home,
  +		       String remote, String link) {
  +
  +	addEjb(new ContextEjb(name, description, type, home, remote, link));
  +
  +    }
  +
  +
  +    /**
        * Add an environment entry for this web application.
        *
        * @param environment New environment entry
  @@ -410,6 +489,22 @@
   
   
       /**
  +     * Add an environment entry for this web application.
  +     *
  +     * @param name Name of the environment entry
  +     * @param description Description of the environment entry
  +     * @param type Java class of the environment entry
  +     * @param value Value of the environment entry (as a String)
  +     */
  +    public void addEnvironment(String name, String description,
  +			       String type, String value) {
  +
  +	addEnvironment(new ContextEnvironment(name, description, type, value));
  +
  +    }
  +
  +
  +    /**
        * Add an error page for the specified Java exception.
        *
        * @param exception Fully qualified exception class
  @@ -467,6 +562,22 @@
   
   
       /**
  +     * Add a resource reference for this web application.
  +     *
  +     * @param name Name of this resource reference
  +     * @param description Description of this resource reference
  +     * @param type Java class of this resource reference
  +     * @param auth Authentication technique used by this resource reference
  +     */
  +    public void addResource(String name, String description,
  +			    String type, String auth) {
  +
  +	addResource(new ContextResource(name, description, type, auth));
  +
  +    }
  +
  +
  +    /**
        * Add a security role reference for this web application.
        *
        * @param role Security role used in the application
  @@ -955,6 +1066,10 @@
        * @param update Update request to reflect this mapping?
        */
       public Wrapper map(Request request, boolean update) {
  +
  +	// Has this request already been mapped?
  +	if (update && (request.getWrapper() != null))
  +	    return (request.getWrapper());
   
   	// Identify the context-relative URI to be mapped
   	String contextPath =
  
  
  
  1.6       +8 -4      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHost.java
  
  Index: StandardHost.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHost.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StandardHost.java	2000/04/23 01:42:34	1.5
  +++ StandardHost.java	2000/04/25 20:11:29	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHost.java,v
1.5 2000/04/23 01:42:34 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/04/23 01:42:34 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHost.java,v
1.6 2000/04/25 20:11:29 craigmcc Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/04/25 20:11:29 $
    *
    * ====================================================================
    *
  @@ -84,7 +84,7 @@
    * requests directed to a particular web application.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.5 $ $Date: 2000/04/23 01:42:34 $
  + * @version $Revision: 1.6 $ $Date: 2000/04/25 20:11:29 $
    */
   
   public final class StandardHost
  @@ -249,6 +249,10 @@
        * @param update Update request to reflect this mapping?
        */
       public Context map(Request request, boolean update) {
  +
  +	// Has this request already been mapped?
  +	if (update && (request.getContext() != null))
  +	    return (request.getContext());
   
   	// Perform mapping on our request URI
   	String uri =
  
  
  
  1.6       +48 -18    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardResources.java
  
  Index: StandardResources.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardResources.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StandardResources.java	2000/04/23 01:42:34	1.5
  +++ StandardResources.java	2000/04/25 20:11:29	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardResources.java,v
1.5 2000/04/23 01:42:34 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/04/23 01:42:34 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardResources.java,v
1.6 2000/04/25 20:11:29 craigmcc Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/04/25 20:11:29 $
    *
    * ====================================================================
    *
  @@ -65,6 +65,7 @@
   package org.apache.tomcat.core;
   
   
  +import java.beans.PropertyChangeEvent;
   import java.beans.PropertyChangeSupport;
   import java.beans.PropertyChangeListener;
   import java.io.File;
  @@ -90,11 +91,11 @@
    * requests are resolved against the document base URL that is configured.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.5 $ $Date: 2000/04/23 01:42:34 $
  + * @version $Revision: 1.6 $ $Date: 2000/04/25 20:11:29 $
    */
   
   public final class StandardResources
  -    implements Resources, Lifecycle {
  +    implements Resources, Lifecycle, PropertyChangeListener {
   
   
       // ----------------------------------------------------------- Constructors
  @@ -106,7 +107,6 @@
       public StandardResources() {
   
   	super();
  -	setDocRoot("webpages");
   
       }
   
  @@ -123,7 +123,7 @@
       /**
        * The document root URL for this component.
        */
  -    private String docRoot = null;
  +    private String docBase = null;
   
   
       /**
  @@ -179,7 +179,15 @@
       public void setContainer(Container container) {
   
   	Container oldContainer = this.container;
  +	if ((oldContainer != null) && (oldContainer instanceof Context))
  +	    ((Context) oldContainer).removePropertyChangeListener(this);
  +
   	this.container = container;
  +	if ((this.container != null) && (this.container instanceof Context)) {
  +	    ((Context) this.container).addPropertyChangeListener(this);
  +	    setDocBase(((Context) this.container).getDocBase());
  +	}
  +
   	support.firePropertyChange("container", oldContainer, this.container);
   
       }
  @@ -188,9 +196,9 @@
       /**
        * Return the document root for this component.
        */
  -    public String getDocRoot() {
  +    public String getDocBase() {
   
  -	return (this.docRoot);
  +	return (this.docBase);
   
       }
   
  @@ -198,23 +206,23 @@
       /**
        * Set the document root for this component.
        *
  -     * @param docRoot The new document root
  +     * @param docBase The new document root
        *
        * @exception IllegalArgumentException if this would create a
        *  malformed URL
        */
  -    public void setDocRoot(String docRoot) {
  +    public void setDocBase(String docBase) {
   
   	URL url = null;
   	try {
  -	    url = URLUtil.resolve(docRoot);
  +	    url = URLUtil.resolve(docBase);
   	} catch (MalformedURLException e) {
   	    throw new IllegalArgumentException
   		(sm.getString("standardResources.malformedURL"));
   	}
  -	String oldDocRoot = this.docRoot;
  -	this.docRoot = url.toString();
  -	support.firePropertyChange("docRoot", oldDocRoot, this.docRoot);
  +	String oldDocBase = this.docBase;
  +	this.docBase = url.toString();
  +	support.firePropertyChange("docBase", oldDocBase, this.docBase);
   
       }
   
  @@ -281,8 +289,8 @@
   
   	if ((path == null) || (!path.startsWith("/")))
   	    return (null);
  -	if (docRoot.startsWith("file://"))
  -	    return (docRoot.substring(6) + path);	// FIXME: Windows?
  +	if (docBase.startsWith("file://"))
  +	    return (docBase.substring(6) + path);	// FIXME: Windows?
   	else
   	    return (null);
   
  @@ -327,7 +335,7 @@
   	if ((path == null) || (!path.startsWith("/")))
   	    throw new MalformedURLException
   		(sm.getString("standardResources.malformedPath"));
  -	return (new URL(docRoot + path));
  +	return (new URL(docBase + path));
   
       }
   
  @@ -379,6 +387,28 @@
       public void removePropertyChangeListener(PropertyChangeListener listener) {
   
   	support.removePropertyChangeListener(listener);
  +
  +    }
  +
  +
  +    // ----------------------------------------- PropertyChangeListener Methods
  +
  +
  +    /**
  +     * Process property change events from our associated Context.
  +     *
  +     * @param event The property change event that has occurred
  +     */
  +    public void propertyChange(PropertyChangeEvent event) {
  +
  +	// Validate the source of this event
  +	if (!(event.getSource() instanceof Context))
  +	    return;
  +	Context context = (Context) event.getSource();
  +
  +	// Process a relevant property change
  +	if (event.getPropertyName().equals("docBase"))
  +	    setDocBase((String) event.getNewValue());
   
       }
   
  
  
  
  1.5       +47 -30    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardServer.java
  
  Index: StandardServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardServer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StandardServer.java	2000/04/23 01:42:35	1.4
  +++ StandardServer.java	2000/04/25 20:11:29	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardServer.java,v
1.4 2000/04/23 01:42:35 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/04/23 01:42:35 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardServer.java,v
1.5 2000/04/25 20:11:29 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/04/25 20:11:29 $
    *
    * ====================================================================
    *
  @@ -67,6 +67,7 @@
   
   import java.io.InputStream;
   import java.io.IOException;
  +import java.net.InetAddress;
   import java.net.ServerSocket;
   import java.net.Socket;
   import java.util.Enumeration;
  @@ -88,7 +89,7 @@
    * (but not required) when deploying and starting Tomcat.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2000/04/23 01:42:35 $
  + * @version $Revision: 1.5 $ $Date: 2000/04/25 20:11:29 $
    */
   
   public final class StandardServer
  @@ -267,32 +268,9 @@
   		System.exit(1);
   	    }
   
  -	    // Validate that the client is on our server
  -	    // NOTE:  This code works around a bug in the IBM 1.1.8 JVM
  -	    // for Linux, which returns the address bytes reversed!
  -	    boolean matchForward = true;
  -	    boolean matchReverse = true;
  -	    byte local[] = socket.getLocalAddress().getAddress();
  -	    byte remote[] = socket.getInetAddress().getAddress();
  -	    if ((local.length != 4) && (remote.length != 4)) {
  -		matchForward = false;	// FIXME: How long are IPv6 addresses?
  -		matchReverse = false;
  -	    }
  -	    if (matchForward) {
  -		for (int i = 0; i < 4; i++) {
  -		    if (local[i] != remote[i]) {
  -			matchForward = false;
  -			break;
  -		    }
  -		}
  -		for (int i = 0; i < 4; i++) {
  -		    if (local[i] != remote[3 - i]) {
  -			matchReverse = false;
  -			break;
  -		    }
  -		}
  -	    }
  -	    if (!matchForward && !matchReverse) {
  +	    boolean localAddress = isSameAddress(socket.getLocalAddress(),
  +						 socket.getInetAddress());
  +	    if (!localAddress) {
   		System.err.println("Invalid shutdown connection from " +
   				   socket.getInetAddress() + " ignored");
   		try {
  @@ -354,6 +332,45 @@
       public String getInfo() {
   
   	return (info);
  +
  +    }
  +
  +
  +    // -------------------------------------------------------- Private Methods
  +
  +
  +    /**
  +     * Return <code>true</code> if the specified client and server addresses
  +     * are the same.  This method works around a bug in the IBM 1.1.8 JVM on
  +     * Linux, where the address bytes are returned reversed in some
  +     * circumstances.
  +     *
  +     * @param server The server's InetAddress
  +     * @param client The client's InetAddress
  +     */
  +    private boolean isSameAddress(InetAddress server, InetAddress client) {
  +
  +	// Compare the byte array versions of the two addresses
  +	byte serverAddr[] = server.getAddress();
  +	byte clientAddr[] = client.getAddress();
  +	if (serverAddr.length != clientAddr.length)
  +	    return (false);
  +	boolean match = true;
  +	for (int i = 0; i < serverAddr.length; i++) {
  +	    if (serverAddr[i] != clientAddr[i]) {
  +		match = false;
  +		break;
  +	    }
  +	}
  +	if (match)
  +	    return (true);
  +
  +	// Compare the reversed form of the two addresses
  +	for (int i = 0; serverAddr.length < 4; i++) {
  +	    if (serverAddr[i] != clientAddr[(serverAddr.length-1)-i])
  +		return (false);
  +	}
  +	return (true);
   
       }
   
  
  
  
  1.2       +8 -4      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/deploy/ContextEnvironment.java
  
  Index: ContextEnvironment.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/deploy/ContextEnvironment.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContextEnvironment.java	2000/02/12 23:15:45	1.1
  +++ ContextEnvironment.java	2000/04/25 20:11:29	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/deploy/ContextEnvironment.java,v
1.1 2000/02/12 23:15:45 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/02/12 23:15:45 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/deploy/ContextEnvironment.java,v
1.2 2000/04/25 20:11:29 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/04/25 20:11:29 $
    *
    * ====================================================================
    *
  @@ -70,7 +70,7 @@
    * an <code>&lt;env-entry&gt;</code> element in the deployment descriptor.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/02/12 23:15:45 $
  + * @version $Revision: 1.2 $ $Date: 2000/04/25 20:11:29 $
    */
   
   public final class ContextEnvironment {
  @@ -103,9 +103,13 @@
   
   
       private String description = null;
  +
       private String name = null;
  +
       private String type = null;
  +
       private String value = null;
  +
   
       // ------------------------------------------------------------- Properties
   
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/Constants.java
  
  Index: Constants.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/Constants.java,v
1.1 2000/04/25 20:11:30 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/04/25 20:11:30 $
   *
   * ====================================================================
   *
   * 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.startup;
  
  
  /**
   * String constants for the startup package.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/04/25 20:11:30 $
   */
  
  public final class Constants {
  
      public static final String Package = "org.apache.tomcat.startup";
  
      public static final String WebXmlResource = "/WEB-INF/web.xml";
  
  }
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java
  
  Index: ContextConfig.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java,v
1.1 2000/04/25 20:11:30 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/04/25 20:11:30 $
   *
   * ====================================================================
   *
   * 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.startup;
  
  
  import java.io.InputStream;
  import org.apache.tomcat.Context;
  import org.apache.tomcat.Lifecycle;
  import org.apache.tomcat.LifecycleEvent;
  import org.apache.tomcat.LifecycleListener;
  import org.apache.tomcat.Logger;
  import org.apache.tomcat.Resources;
  import org.apache.tomcat.Wrapper;
  import org.apache.tomcat.util.StringManager;
  import org.apache.tomcat.util.xml.SaxContext;
  import org.apache.tomcat.util.xml.XmlAction;
  import org.apache.tomcat.util.xml.XmlMapper;
  
  
  /**
   * Startup event listener for a <b>Context</b> that configures the properties
   * of that Context, and the associated defined servlets, from the "web.xml"
   * resource for this web application.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/04/25 20:11:30 $
   */
  
  public final class ContextConfig
      implements LifecycleListener {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The Context we are associated with.
       */
      private Context context = null;
  
  
      /**
       * The debugging detail level for this component.
       */
      private int debug = 0;
  
  
      /**
       * The string resources for this package.
       */
      private static final StringManager sm =
  	StringManager.getManager(Constants.Package);
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the debugging detail level for this component.
       */
      public int getDebug() {
  
  	return (this.debug);
  
      }
  
  
      /**
       * Set the debugging detail level for this component.
       *
       * @param debug The new debugging detail level
       */
      public void setDebug(int debug) {
  
  	this.debug = debug;
  
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Process the START event for an associated Context.
       *
       * @param event The lifecycle event that has occurred
       */
      public void lifecycleEvent(LifecycleEvent event) {
  
  	// Identify the context we are associated with
  	try {
  	    context = (Context) event.getData();
  	} catch (ClassCastException e) {
  	    log(sm.getString("contextConfig.cce", event.getData()), e);
  	    return;
  	}
  
  	// Process the event that has occurred
  	if (event.getType().equals(Lifecycle.START_EVENT))
  	    start();
  	else if (event.getType().equals(Lifecycle.STOP_EVENT))
  	    stop();
  
      }
  
  
      // -------------------------------------------------------- Private Methods
  
  
      /**
       * Create and return an XmlMapper configured to process the web application
       * deployment descriptor (web.xml).
       */
      private XmlMapper createMapper() {
  
  	XmlMapper mapper = new XmlMapper();
  	if (debug > 0)
  	    mapper.setDebug(3);
  
  	mapper.addRule("web-app/context-param",
  		       mapper.methodSetter("addParameter", 2));
  	mapper.addRule("web-app/context-param/param-name",
  		       mapper.methodParam(0));
  	mapper.addRule("web-app/context-param/param-value",
  		       mapper.methodParam(1));
  
  	mapper.addRule("web-app/distributable",
  		       mapper.methodSetter("setDistributable", 0));
  
  	mapper.addRule("web-app/ejb-ref",
  		       mapper.methodSetter("addEjb", 6));
  	mapper.addRule("web-app/ejb-ref/description",
  		       mapper.methodParam(1));
  	mapper.addRule("web-app/ejb-ref/ejb-ref-name",
  		       mapper.methodParam(0));
  	mapper.addRule("web-app/ejb-ref/ejb-ref-type",
  		       mapper.methodParam(2));
  	mapper.addRule("web-app/ejb-ref/home",
  		       mapper.methodParam(3));
  	mapper.addRule("web-app/ejb-ref/remote",
  		       mapper.methodParam(4));
  	mapper.addRule("web-app/ejb-ref/ejb-link",
  		       mapper.methodParam(5));
  
  	mapper.addRule("web-app/env-entry",
  		       mapper.methodSetter("addEnvironment", 4));
  	mapper.addRule("web-app/env-entry/description",
  		       mapper.methodParam(1));
  	mapper.addRule("web-app/env-entry/env-entry-name",
  		       mapper.methodParam(0));
  	mapper.addRule("web-app/env-entry/env-entry-type",
  		       mapper.methodParam(2));
  	mapper.addRule("web-app/env-entry/env-entry-value",
  		       mapper.methodParam(3));
  
  	;	// FIXME - web-app/error-page
  
  	;	// FIXME - web-app/login-config
  
  	mapper.addRule("web-app/mime-mapping",
  		       mapper.methodSetter("addMimeMapping", 2));
  	mapper.addRule("web-app/mime-mapping/extension",
  		       mapper.methodParam(0));
  	mapper.addRule("web-app/mime-mapping/mime-type",
  		       mapper.methodParam(1));
  
  	mapper.addRule("web-app/resource-ref",
  		       mapper.methodSetter("addResource", 4));
  	mapper.addRule("web-app/resource-ref/description",
  		       mapper.methodParam(1));
  	mapper.addRule("web-app/resource-ref/res-auth",
  		       mapper.methodParam(3));
  	mapper.addRule("web-app/resource-ref/res-ref-name",
  		       mapper.methodParam(0));
  	mapper.addRule("web-app/resource-ref/res-type",
  		       mapper.methodParam(2));
  
  	;	// FIXME - web-app/security-constraint
  
  	mapper.addRule("web-app/security-role",
  		       mapper.methodSetter("addSecurityRole", 1));
  	mapper.addRule("web-app/security-role/role-name",
  		       mapper.methodParam(0));
  
  	mapper.addRule("web-app/servlet",
  		       mapper.objectCreate(context.getWrapperClass()));
  	mapper.addRule("web-app/servlet",
  		       mapper.setParent("setParent"));
  	mapper.addRule("web-app/servlet",
  		       mapper.addChild("addChild",
  				       "org.apache.tomcat.Wrapper"));
  	mapper.addRule("web-app/servlet/init-param",
  		       mapper.methodSetter("addInitParameter", 2));
  	mapper.addRule("web-app/servlet/init-param/param-name",
  		       mapper.methodParam(0));
  	mapper.addRule("web-app/servlet/init-param/param-value",
  		       mapper.methodParam(1));
  	mapper.addRule("web-app/servlet/jsp-file",
  		       mapper.methodSetter("setJspFile", 0));
  	mapper.addRule("web-app/servlet/load-on-startup",
  		       mapper.methodSetter("setLoadOnStartup", 0));
  	mapper.addRule("web-app/servlet/security-role-ref",
  		       mapper.methodSetter("addSecurityReference", 2));
  	mapper.addRule("web-app/servlet/security-role-ref/role-link",
  		       mapper.methodParam(1));
  	mapper.addRule("web-app/servlet/security-role-ref/role-name",
  		       mapper.methodParam(0));
  	mapper.addRule("web-app/servlet/servlet-class",
  		       mapper.methodSetter("setServletClass", 0));
  	mapper.addRule("web-app/servlet/servlet-name",
  		       mapper.methodSetter("setName", 0));
  
  	mapper.addRule("web-app/servlet-mapping",
  		       mapper.methodSetter("addServletMapping", 2));
  	mapper.addRule("web-app/servlet-mapping/servlet-name",
  		       mapper.methodParam(1));
  	mapper.addRule("web-app/servlet-mapping/url-pattern",
  		       mapper.methodParam(0));
  
  	mapper.addRule("web-app/session-config",
  		       mapper.methodSetter("setSessionTimeout", 1,
  					   new String[]{"int"}));
  	mapper.addRule("web-app/session-config/session-timeout",
  		       mapper.methodParam(0));
  
  	mapper.addRule("web-app/taglib",
  		       mapper.methodSetter("addTaglib", 2));
  	mapper.addRule("web-app/taglib/taglib-location",
  		       mapper.methodParam(1));
  	mapper.addRule("web-app/taglib/taglib-uri",
  		       mapper.methodParam(0));
  
  	mapper.addRule("web-app/welcome-file-list/welcome-file",
  		       mapper.methodSetter("addWelcomeFile", 0));
  
  	return (mapper);
  
      }
  
  
      /**
       * Log a message on the Logger associated with our Context (if any)
       *
       * @param message Message to be logged
       */
      private void log(String message) {
  
  	Logger logger = null;
  	if (context != null)
  	    logger = context.getLogger();
  	if (logger != null)
  	    logger.log("ContextConfig[" + context.getName() + "]: " + message);
  	else
  	    System.out.println("ContextConfig[" + context.getName() + "]: "
  			       + message);
  
      }
  
  
      /**
       * Log a message on the Logger associated with our Context (if any)
       *
       * @param message Message to be logged
       * @param throwable Associated exception
       */
      private void log(String message, Throwable throwable) {
  
  	Logger logger = null;
  	if (context != null)
  	    logger = context.getLogger();
  	if (logger != null)
  	    logger.log("ContextConfig[" + context.getName() + "] "
  		       + message, throwable);
  	else {
  	    System.out.println("ContextConfig[" + context.getName() + "]: "
  			       + message);
  	    System.out.println("" + throwable);
  	    throwable.printStackTrace(System.out);
  	}
  
      }
  
  
      /**
       * Process a "start" event for this Context.
       */
      private void start() {
  
  	if (debug > 0)
  	    log(sm.getString("contextConfig.start", context.getName()));
  
  	// Configure a mapper to read a web application deployment descriptor
  	XmlMapper mapper = createMapper();
  
  	// Process the "default" web.xml settings first
  	;	// FIXME - process "default" web.xml settings
  
  	// Process the deployment descriptor for this app second
  	Resources resources = context.getResources();
  	if (resources == null) {
  	    log(sm.getString("contextConfig.resources", context.getName()));
  	    return;
  	}
  	InputStream stream =
  	    resources.getResourceAsStream(Constants.WebXmlResource);
  	if (stream == null) {
  	    log(sm.getString("contextConfig.descriptor", context.getName()));
  	    return;
  	}
  	try {
  	    mapper.readXml(stream, context);
  	} catch (Exception e) {
  	    log(sm.getString("contextConfig.parser", context.getName()), e);
  	    return;
  	}
  
      }
  
  
      /**
       * Process a "stop" event for this Context.
       */
      private void stop() {
  
  	if (debug > 0)
  	    log(sm.getString("contextConfig.stop", context.getName()));
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  contextConfig.cce=Lifecycle event data object {0} is not a Context
  contextConfig.descriptor=No web.xml for context {0}, using default web.xml only
  contextConfig.default=Parse error processing default web.xml
  contextConfig.parser=Parse error processing context {0} web.xml
  contextConfig.resources=No resources for context {0}, using default web.xml only
  contextConfig.start=ContextConfig: Processing START for context {0}
  contextConfig.stop=ContextConfig: Processing STOP for context {0}
  
  
  

Mime
View raw message