tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/config ServerXmlInterceptor.java
Date Fri, 29 Dec 2000 20:31:36 GMT
costin      00/12/29 12:31:36

  Modified:    src/share/org/apache/tomcat/core BaseInterceptor.java
                        Container.java Context.java ContextManager.java
                        Handler.java OutputBuffer.java Request.java
                        Response.java
               src/share/org/apache/tomcat/modules/config
                        ServerXmlInterceptor.java
  Log:
  Explicit imports in core. There are few more dependencies that
  should be removed ( and moved to the facade, as high-level constructs -
  Principal, etc ).
  
  Next step is to do the same thing in util, and remove ( move out ) all
  utils that are no longer used.
  
  The place for "general utils" is in a "jpr" ( i.e. java-APR )-like project,
  and even the curently-used utils shouldn't be part of tomcat ( in the
  same way as Apache2.0 makes a clear difference and uses 2 CVS trees - one
  for the general-code and one for the library )
  
  Revision  Changes    Path
  1.35      +0 -6      jakarta-tomcat/src/share/org/apache/tomcat/core/BaseInterceptor.java
  
  Index: BaseInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BaseInterceptor.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- BaseInterceptor.java	2000/12/28 21:03:17	1.34
  +++ BaseInterceptor.java	2000/12/29 20:31:26	1.35
  @@ -60,13 +60,7 @@
   
   package org.apache.tomcat.core;
   
  -import org.apache.tomcat.core.*;
  -import org.apache.tomcat.util.*;
   import org.apache.tomcat.util.log.*;
  -import java.io.*;
  -import java.net.*;
  -import java.util.*;
  -import java.lang.reflect.*;
   
   /** Implement "Chain of Responsiblity" pattern ( == hooks ).
    *
  
  
  
  1.43      +2 -4      jakarta-tomcat/src/share/org/apache/tomcat/core/Container.java
  
  Index: Container.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Container.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- Container.java	2000/12/28 07:14:44	1.42
  +++ Container.java	2000/12/29 20:31:27	1.43
  @@ -59,11 +59,9 @@
   
   package org.apache.tomcat.core;
   
  -import org.apache.tomcat.util.*;
   import org.apache.tomcat.util.hooks.*;
  -import java.io.*;
  -import java.net.*;
  -import java.util.*;
  +import java.util.Hashtable;
  +import java.util.Enumeration;
   
   // XXX better names: Location, URLPattern,  
   
  
  
  
  1.131     +9 -6      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.130
  retrieving revision 1.131
  diff -u -r1.130 -r1.131
  --- Context.java	2000/12/26 23:13:55	1.130
  +++ Context.java	2000/12/29 20:31:27	1.131
  @@ -61,13 +61,16 @@
   package org.apache.tomcat.core;
   
   import org.apache.tomcat.util.depend.*;
  -import org.apache.tomcat.util.*;
  -import java.security.*;
  -import java.lang.reflect.*;
  +import org.apache.tomcat.util.MimeMap;
   import org.apache.tomcat.util.log.*;
  -import java.io.*;
  -import java.net.*;
  -import java.util.*;
  +
  +import java.io.File;
  +import java.net.FileNameMap;
  +import java.net.URL;
  +
  +import java.util.Hashtable;
  +import java.util.Vector;
  +import java.util.Enumeration;
   
   
   /**
  
  
  
  1.162     +5 -4      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.161
  retrieving revision 1.162
  diff -u -r1.161 -r1.162
  --- ContextManager.java	2000/12/28 21:03:17	1.161
  +++ ContextManager.java	2000/12/29 20:31:27	1.162
  @@ -59,11 +59,12 @@
   
   package org.apache.tomcat.core;
   
  -import org.apache.tomcat.util.*;
   import org.apache.tomcat.util.log.*;
  -import java.io.*;
  -import java.net.*;
  -import java.util.*;
  +
  +import java.util.Hashtable;
  +import java.util.Vector;
  +import java.util.Enumeration;
  +
   
   /**
     ContextManager is the entry point and "controler" of the servlet execution.
  
  
  
  1.34      +1 -4      jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java
  
  Index: Handler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- Handler.java	2000/12/20 15:25:51	1.33
  +++ Handler.java	2000/12/29 20:31:28	1.34
  @@ -58,12 +58,9 @@
    */ 
   package org.apache.tomcat.core;
   
  -import org.apache.tomcat.util.*;
  +import org.apache.tomcat.util.Counters;
   import org.apache.tomcat.util.log.*;
   import org.apache.tomcat.util.collections.EmptyEnumeration;
  -import java.io.*;
  -import java.net.*;
  -import java.util.*;
   
   /**
    * The class that will generate the actual response or response fragment.
  
  
  
  1.10      +7 -2      jakarta-tomcat/src/share/org/apache/tomcat/core/OutputBuffer.java
  
  Index: OutputBuffer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/OutputBuffer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- OutputBuffer.java	2000/11/16 16:59:18	1.9
  +++ OutputBuffer.java	2000/12/29 20:31:28	1.10
  @@ -58,8 +58,13 @@
    */ 
   package org.apache.tomcat.core;
   
  -import java.io.*;
  -import java.util.*;
  +import java.io.Writer;
  +import java.io.OutputStream;
  +import java.io.OutputStreamWriter;
  +import java.io.IOException;
  +import java.io.UnsupportedEncodingException;
  +
  +import java.util.Hashtable;
   
   /**
    * The buffer used by tomcat response. It allows writting chars and
  
  
  
  1.84      +13 -6     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.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- Request.java	2000/12/28 01:57:40	1.83
  +++ Request.java	2000/12/29 20:31:29	1.84
  @@ -60,15 +60,22 @@
   
   package org.apache.tomcat.core;
   
  -import org.apache.tomcat.util.*;
  +import org.apache.tomcat.util.MimeHeaders;
  +import org.apache.tomcat.util.Counters;
  +import org.apache.tomcat.util.SimplePrincipal;
  +import org.apache.tomcat.util.MessageBytes;
  +
  +// XXX 
  +import org.apache.tomcat.helper.RequestUtil;
  +
   import org.apache.tomcat.util.http.*;
  -import org.apache.tomcat.helper.*;
  +
   import org.apache.tomcat.session.ServerSession;
  +
  +import java.security.Principal;
   import java.io.IOException;
  -import java.io.*;
  -import java.net.*;
  -import java.security.*;
  -import java.util.*;
  +import java.util.Enumeration;
  +import java.util.Hashtable;
   
   /**
    *
  
  
  
  1.45      +8 -5      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.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- Response.java	2000/12/26 23:35:33	1.44
  +++ Response.java	2000/12/29 20:31:29	1.45
  @@ -60,11 +60,14 @@
   
   package org.apache.tomcat.core;
   
  -import java.io.*;
  -import java.net.*;
  -import java.util.*;
  -import org.apache.tomcat.util.*;
  -import org.apache.tomcat.helper.*;
  +import java.io.IOException;
  +import java.util.Locale;
  +
  +import org.apache.tomcat.util.StringManager;
  +import org.apache.tomcat.util.MimeHeaders;
  +
  +// XXX 
  +import org.apache.tomcat.helper.RequestUtil;
   
   /**
    *
  
  
  
  1.3       +211 -1    jakarta-tomcat/src/share/org/apache/tomcat/modules/config/ServerXmlInterceptor.java
  
  Index: ServerXmlInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/config/ServerXmlInterceptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServerXmlInterceptor.java	2000/12/29 01:34:41	1.2
  +++ ServerXmlInterceptor.java	2000/12/29 20:31:34	1.3
  @@ -65,7 +65,6 @@
   import java.util.*;
   import java.net.*;
   import org.apache.tomcat.util.*;
  -import org.apache.tomcat.helper.*;
   import org.apache.tomcat.util.xml.*;
   import org.apache.tomcat.core.*;
   import org.apache.tomcat.modules.server.*;
  @@ -152,5 +151,216 @@
   
       public void setHome( String h ) {
   	System.getProperties().put("tomcat.home", h);
  +    }
  +}
  +/**
  + *  Helper for reading server.xml
  + *
  + * @author Costin
  + */
  +class ServerXmlHelper {
  +    private static StringManager sm =
  +	StringManager.getManager("org.apache.tomcat.resources");
  +
  +    public static final String[] MODULE_PKGS={
  +	"org.apache.tomcat.modules.session.",
  +	"org.apache.tomcat.modules.server.",
  +	"org.apache.tomcat.modules.config.",
  +	"org.apache.tomcat.modules.security.",
  +	"org.apache.tomcat.request.", // OLD
  +	"org.apache.tomcat.context." // OLD
  +    };
  +       
  +    
  +    public ServerXmlHelper() {
  +    }
  +
  +    // Set the mappings
  +    public void setHelper( XmlMapper xh ) {
  +	xh.addRule( "ContextManager", xh.setProperties() );
  +
  +	setInterceptorRules( xh );
  +	setContextRules( xh );
  +	setVHostRules( xh );
  +    }
  +
  +    public static void setInterceptorRules( XmlMapper xh ) {
  +	xh.addRule( "ContextManager/ContextInterceptor",
  +		    xh.objectCreate(null, "className", MODULE_PKGS));
  +	xh.addRule( "ContextManager/ContextInterceptor",
  +		    xh.setProperties() );
  +	xh.addRule( "ContextManager/ContextInterceptor",
  +		    xh.setParent("setContextManager") );
  +	xh.addRule( "ContextManager/ContextInterceptor",
  +		    xh.addChild( "addInterceptor",
  +				 "org.apache.tomcat.core.BaseInterceptor"));
  +
  +	xh.addRule( "ContextManager/RequestInterceptor",
  +		    xh.objectCreate(null, "className", MODULE_PKGS));
  +	xh.addRule( "ContextManager/RequestInterceptor",
  +		    xh.setProperties() );
  +	xh.addRule( "ContextManager/RequestInterceptor",
  +		    xh.setParent("setContextManager") );
  +	xh.addRule( "ContextManager/RequestInterceptor",
  +		    xh.addChild( "addInterceptor",
  +				 "org.apache.tomcat.core.BaseInterceptor"));
  +    }
  +    
  +    public static void setContextRules( XmlMapper xh ) {
  +	// Default host
  + 	xh.addRule( "Context",
  +		    xh.objectCreate("org.apache.tomcat.core.Context"));
  +	xh.addRule( "Context",
  +		    xh.setProperties() );
  +	xh.addRule( "Context",
  +		    xh.setParent("setContextManager") );
  +
  +	xh.addRule( "Context", new XmlAction() {
  +		public void end( SaxContext ctx) throws Exception {
  +		    Context tcCtx=(Context)ctx.currentObject();
  +		    String host=(String)ctx.getVariable("current_host");
  +
  +		    if( host!=null && ! "DEFAULT".equals( host )) 
  +			tcCtx.setHost( host );
  +		}
  +	    });
  +
  +	xh.addRule( "Context",
  +		    xh.addChild("addContext",
  +				"org.apache.tomcat.core.Context") );
  +	
  +	// Configure context interceptors
  +	xh.addRule( "Context/Interceptor",
  +		    xh.objectCreate(null, "className", MODULE_PKGS));
  +	xh.addRule( "Context/Interceptor",
  +		    xh.setProperties() );
  +	xh.addRule( "Context/Interceptor",
  +		    xh.setParent("setContext") );
  +	xh.addRule( "Context/Interceptor",
  +		    xh.addChild( "addInterceptor",
  +				 "org.apache.tomcat.core.BaseInterceptor"));
  +	// Old style 
  +	xh.addRule( "Context/RequestInterceptor",
  +		    xh.objectCreate(null, "className", MODULE_PKGS));
  +	xh.addRule( "Context/RequestInterceptor",
  +		    xh.setProperties() );
  +	xh.addRule( "Context/RequestInterceptor",
  +		    xh.setParent("setContext") );
  +	xh.addRule( "Context/RequestInterceptor",
  +		    xh.addChild( "addInterceptor",
  +				 "org.apache.tomcat.core.BaseInterceptor"));
  +    }
  +
  +    // Virtual host support.
  +    public static void setVHostRules( XmlMapper xh ) {
  + 	xh.addRule( "Host", xh.setVariable( "current_host", "name"));
  +	xh.addRule( "Host", xh.setProperties());
  +    }
  +
  +    public void setConnectorHelper( XmlMapper xh ) {
  +	xh.addRule( "ContextManager/Connector",
  +		    xh.objectCreate(null, "className", MODULE_PKGS));
  +	xh.addRule( "ContextManager/Connector",
  +		    xh.setParent( "setContextManager",
  +				  "org.apache.tomcat.core.ContextManager") );
  +	xh.addRule( "ContextManager/Connector",
  +		    xh.addChild( "addInterceptor",
  +				 "org.apache.tomcat.core.BaseInterceptor"));
  +
  +	xh.addRule( "ContextManager/Connector/Parameter",
  +		    xh.methodSetter("setProperty",2) );
  +	xh.addRule( "ContextManager/Connector/Parameter",
  +		    xh.methodParam(0, "name") );
  +	xh.addRule( "ContextManager/Connector/Parameter",
  +		    xh.methodParam(1, "value") );
  +    }
  +
  +
  +    /** Setup loggers when reading the configuration file - this will be
  +     *  called only when starting tomcat as deamon, all other modes will
  +     * output to stderr
  +     * *** [I don't think that's true any more -Alex]
  +     */
  +    public void setLogHelper( XmlMapper xh ) {
  +	setLogRules( xh );
  +    }
  +
  +    public static void setLogRules( XmlMapper xh ) {
  +	xh.addRule("Server/Logger",
  +		   xh.objectCreate("org.apache.tomcat.util.log.QueueLogger"));
  +	xh.addRule("Server/Logger", xh.setProperties());
  +	xh.addRule("Server/Logger", 
  +		   xh.addChild("addLogger",
  +			       "org.apache.tomcat.util.log.Logger") );
  +
  +	xh.addRule("Context/Logger",
  +		   xh.objectCreate("org.apache.tomcat.util.log.QueueLogger"));
  +	xh.addRule("Context/Logger", xh.setProperties());
  +	xh.addRule("Context/Logger", 
  +		   xh.addChild("setLogger",
  +			       "org.apache.tomcat.util.log.Logger") );
  +
  +	xh.addRule("Context/ServletLogger",
  +		   xh.objectCreate("org.apache.tomcat.util.log.QueueLogger"));
  +	xh.addRule("Context/ServletLogger", xh.setProperties());
  +	xh.addRule("Context/ServletLogger", 
  +		   xh.addChild("setServletLogger",
  +			       "org.apache.tomcat.util.log.Logger") );
  +
  +
  +    }
  +
  +    /**
  +     * Return the configuration file we are processing.  If the
  +     * <code>-config filename</code> command line argument is not
  +     * used, the default configuration filename will be loaded from
  +     * the TOMCAT_HOME directory.
  +     *
  +     * If a relative config file is used, it will be relative to the current
  +     * working directory.
  +     *
  +     * @param cm The ContextManager we are configuring
  +     **/
  +    public String getTomcatInstall() {
  +	// Use the "tomcat.home" property to resolve the default filename
  +	String tchome = System.getProperty("tomcat.home");
  +	if (tchome == null) {
  +	    System.out.println(sm.getString("tomcat.nohome"));
  +	    tchome = ".";
  +	    // Assume current working directory
  +	}
  +	return tchome;
  +    }
  +
  +    public Vector getUserConfigFiles(File master) {
  +	File dir = new File(master.getParent());
  +	String[] names = dir.list( new ConfigFilter(master) );
  +	Vector v = new Vector(names.length);
  +	for (int i=0; i<names.length; ++i) {
  +	    File found = new File(dir, names[i]);
  +	    v.addElement(found);
  +	}
  +	return v;
  +    }
  +
  +    class ConfigFilter implements FilenameFilter {
  +	String start;
  +	String end;
  +	public ConfigFilter(File master) {
  +	    String name = master.getName();
  +	    int dot = name.indexOf(".");
  +	    if (dot==-1) return;
  +	    start = name.substring(0,dot) + "-";
  +	    end = name.substring(dot);
  +	}
  +	public boolean accept(File dir, String name) {
  +	    if (start == null || end == null) return false;
  +	    if (name.startsWith(start) &&
  +		name.endsWith(end))
  +	    {
  +		return true;
  +	    }
  +	    return false;
  +	}
       }
   }
  
  
  

Mime
View raw message