You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@locus.apache.org on 2000/01/08 16:34:29 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util URLUtil.java

costin      00/01/08 07:34:29

  Modified:    src/share/org/apache/tomcat/core Constants.java Context.java
                        DefaultServlet.java ServletContextFacade.java
               src/share/org/apache/tomcat/util URLUtil.java
  Log:
  Cosmetic changes in Constants - use CAPITAL_LETTER style,
  fewer internal classes ( there are more constant classes than
  normal classes ).
  
  Also, use the real name where it is constant enough ( for example
  "http" instead of Constants.HTTP - I don't think this constant
  will change too soon :-), and it's easier to read)
  
  More changes will follow.
  
  Revision  Changes    Path
  1.8       +9 -29     jakarta-tomcat/src/share/org/apache/tomcat/core/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Constants.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Constants.java	1999/12/14 22:32:15	1.7
  +++ Constants.java	2000/01/08 15:34:28	1.8
  @@ -66,7 +66,16 @@
    */
   
   public class Constants {
  +    public static final String TOMCAT_NAME = "Tomcat Web Server";
  +    public static final String TOMCAT_VERSION = "3.0";
   
  +    public static final String JSP_NAME = "JSP";
  +    public static final String JSP_VERSION = "1.1";
  +	
  +    public static final String SERVLET_NAME = "Servlet";
  +    public static final int SERVLET_MAJOR = 2;
  +    public static final int SERVLET_MINOR = 2;
  +
       public static final String Package = "org.apache.tomcat.core";
       public static final int RequestURIMatchRecursion = 5;
       public static final String WorkDir = "work";
  @@ -92,27 +101,6 @@
               LibDir
           };
   
  -        public static final String EngineHeader =
  -            Tomcat.Name + "/" + Tomcat.Version + " (" + JSP.Name + " " +
  -	    JSP.Version + "; " + Servlet.Name + " " + Servlet.Version;
  -
  -        public static class Servlet {
  -            public static final String Name = "Servlet";
  -	    public static final String Version = "2.2";
  -            public static final int MajorVersion = 2;
  -            public static final int MinorVersion = 2;
  -	}
  -
  -        public static class JSP {
  -	    public static final String Name = "JSP";
  -	    public static final String Version = "1.1";
  -	}
  -
  -        public static class Tomcat {
  -	    public static final String Name = "Tomcat Web Server";
  -	    public static final String Version = "3.0";
  -	}
  -
           public static class Attribute {
   	    public static class WorkDir {
   	        public static final String Name = "sun.servlet.workdir";
  @@ -207,13 +195,5 @@
   
       public static class Header {
           public static final String AcceptLanguage = "Accept-Language";
  -    }
  - 
  -    public static class Request {
  -        public static final String HTTP = "http";
  -        public static final String HTTPS = "https";
  -        public static final String FILE = "file";
  -        public static final String WAR = "war";
  -        public static final String JAR = "jar";
       }
   }
  
  
  
  1.17      +6 -5      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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Context.java	2000/01/08 15:09:26	1.16
  +++ Context.java	2000/01/08 15:34:28	1.17
  @@ -152,7 +152,10 @@
   	    // no longer use core.properties - the configuration comes from
   	    // server.xml or web.xml - no more properties.
   	    StringBuffer sb=new StringBuffer();
  -	    sb.append(Constants.Context.EngineHeader);
  +	    sb.append(Constants.TOMCAT_NAME).append("/").append(Constants.TOMCAT_VERSION);
  +	    sb.append(" (").append(Constants.JSP_NAME).append(" ").append(Constants.JSP_VERSION);
  +	    sb.append("; ").append(Constants.SERVLET_NAME).append(" ");
  +	    sb.append(Constants.SERVLET_MAJOR).append(".").append(Constants.SERVLET_MINOR);
   	    sb.append( "; Java " );
   	    sb.append(System.getProperty("java.version")).append("; ");
   	    sb.append(System.getProperty("os.name") + " ");
  @@ -397,8 +400,7 @@
   
   	URL servletBase = this.docBase;
   
  -	if (docBase.getProtocol().equalsIgnoreCase(
  -	    Constants.Request.WAR)) {
  +	if (docBase.getProtocol().equalsIgnoreCase("war")) {
   	    if (isWARExpanded()) {
   	        this.warDir = new File(getWorkDir(),
   		    Constants.Context.WARExpandDir);
  @@ -453,8 +455,7 @@
   
   	String s = docBase.toString();
   
  -	if (docBase.getProtocol().equalsIgnoreCase(
  -	    Constants.Request.WAR)) {
  +	if (docBase.getProtocol().equalsIgnoreCase("war")) {
   	    if (s.endsWith("/")) {
   	        s = s.substring(0, s.length() - 1);
   	    }
  
  
  
  1.7       +10 -14    jakarta-tomcat/src/share/org/apache/tomcat/core/DefaultServlet.java
  
  Index: DefaultServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/DefaultServlet.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultServlet.java	1999/11/08 03:58:38	1.6
  +++ DefaultServlet.java	2000/01/08 15:34:28	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/DefaultServlet.java,v 1.6 1999/11/08 03:58:38 akv Exp $
  - * $Revision: 1.6 $
  - * $Date: 1999/11/08 03:58:38 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/DefaultServlet.java,v 1.7 2000/01/08 15:34:28 costin Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/01/08 15:34:28 $
    *
    * ====================================================================
    *
  @@ -119,15 +119,14 @@
           URL url = getServletContext().getResource(pathInfo);
   
   	if (url != null) {
  -	    if (url.getProtocol().equals(Constants.Request.WAR) &&
  +	    if (url.getProtocol().equals("war") &&
   	        context.isWARExpanded()) {
   		String s = context.getWARDir().toString() + pathInfo;
   
   		url = URLUtil.resolve(s);
   	    }
   
  -	    if (url.getProtocol().equalsIgnoreCase(
  -	        Constants.Request.FILE)) {
  +	    if (url.getProtocol().equalsIgnoreCase("file")) {
   		// serve file
   
   		File f = new File(url.getFile());
  @@ -147,8 +146,7 @@
   		    response.sendError(response.SC_NOT_FOUND,
                           "File Not Found: " + requestURI);
   		}
  -	    } else if (url.getProtocol().equalsIgnoreCase(
  -	        Constants.Request.WAR)) {
  +	    } else if (url.getProtocol().equalsIgnoreCase("war")) {
   	        // get content from war
   
   	        String documentBase = context.getDocumentBase().toString();
  @@ -187,8 +185,7 @@
   	String absPath = file.getAbsolutePath();
           String docBase = "";
   
  -	if (context.getDocumentBase().getProtocol().equalsIgnoreCase(
  -	    Constants.Request.WAR) &&
  +	if (context.getDocumentBase().getProtocol().equalsIgnoreCase("war") &&
   	    context.isWARExpanded()) {
   	    String s = context.getWARDir().getAbsolutePath();
   
  @@ -542,8 +539,7 @@
   	String[] fileNames = file.list();
           String docBase = "";
   
  -        if (context.getDocumentBase().getProtocol().equalsIgnoreCase(
  -            Constants.Request.WAR) &&
  +        if (context.getDocumentBase().getProtocol().equalsIgnoreCase("war") &&
   	    context.isWARExpanded()) {
   	    String s = context.getWARDir().getAbsolutePath();
   
  @@ -723,9 +719,9 @@
   	buf.append("<tr><td colspan=3 bgcolor=#ffffff>&nbsp;</td></tr>");
   	buf.append("<tr><td colspan=3 bgcolor=#cccccc>");
   	buf.append("<font size=-1>");
  -	buf.append(Constants.Context.Tomcat.Name);
  +	buf.append(Constants.TOMCAT_NAME);
   	buf.append(" v");
  -	buf.append(Constants.Context.Tomcat.Version);
  +	buf.append(Constants.TOMCAT_VERSION);
   	buf.append("</font></td></tr></table>");
   
   	if (! inInclude) {
  
  
  
  1.8       +8 -14     jakarta-tomcat/src/share/org/apache/tomcat/core/ServletContextFacade.java
  
  Index: ServletContextFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletContextFacade.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ServletContextFacade.java	2000/01/07 19:14:12	1.7
  +++ ServletContextFacade.java	2000/01/08 15:34:28	1.8
  @@ -136,11 +136,11 @@
       }
   
       public int getMajorVersion() {
  -        return Constants.Context.Servlet.MajorVersion;
  +        return Constants.SERVLET_MAJOR;
       }
   
       public int getMinorVersion() {
  -        return Constants.Context.Servlet.MinorVersion;
  +        return Constants.SERVLET_MINOR;
       }
   
       public String getMimeType(String filename) {
  @@ -156,8 +156,7 @@
               URL url = getResource(path);
   
               if (url != null) {
  -                if (url.getProtocol().equalsIgnoreCase(
  -		    Constants.Request.WAR)) {
  +                if (url.getProtocol().equalsIgnoreCase("war")) {
   		    if (context.isWARExpanded()) {
   		        String spec = url.getFile();
   
  @@ -172,8 +171,7 @@
   			    warURL = new URL(spec.substring(0, separator++));
   			}
   
  -			if (warURL.getProtocol().equalsIgnoreCase(
  -			    Constants.Request.FILE)) {
  +			if (warURL.getProtocol().equalsIgnoreCase("file")) {
   			    String s = context.getWorkDir() +"/" +
   			        Constants.Context.WARExpandDir + path;
   			    File f = new File(s);
  @@ -183,20 +181,17 @@
   			    // troubles on jdk1.1.x/win
   
   			    realPath = FileUtil.patch(absPath);
  -			} else if (url.getProtocol().equalsIgnoreCase(
  -			    Constants.Request.HTTP)) {
  +			} else if (url.getProtocol().equalsIgnoreCase("http")) {
   			    // XXX
   			    // need to support http docBase'd context
   			}
   		    } else {
                           // realPath is null
   		    }
  -		} else if (url.getProtocol().equalsIgnoreCase(
  -		    Constants.Request.HTTP)) {
  +		} else if (url.getProtocol().equalsIgnoreCase("http")) {
                       // XXX
                       // need to support http docBase'd context
  -                } else if (url.getProtocol().equalsIgnoreCase(
  -		    Constants.Request.FILE)) {
  +                } else if (url.getProtocol().equalsIgnoreCase("file")) {
   		    // take care of File.getAbsolutePath() troubles on
   		    // jdk1.1.x/win
   
  @@ -266,8 +261,7 @@
   
   	if (path.equals("")) {
   	    url = docBase;
  -	} else if (docBase.getProtocol().equalsIgnoreCase(
  -	    Constants.Request.WAR)) {
  +	} else if (docBase.getProtocol().equalsIgnoreCase("war")) {
   	    if (context.isWARExpanded()) {
   		File f = new File(context.getWARDir().toString());
   		String absPath = f.getAbsolutePath();
  
  
  
  1.4       +4 -5      jakarta-tomcat/src/share/org/apache/tomcat/util/URLUtil.java
  
  Index: URLUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/URLUtil.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- URLUtil.java	1999/10/22 01:47:13	1.3
  +++ URLUtil.java	2000/01/08 15:34:29	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/URLUtil.java,v 1.3 1999/10/22 01:47:13 costin Exp $
  - * $Revision: 1.3 $
  - * $Date: 1999/10/22 01:47:13 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/URLUtil.java,v 1.4 2000/01/08 15:34:29 costin Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/01/08 15:34:29 $
    *
    * ====================================================================
    *
  @@ -122,8 +122,7 @@
   	    resolve = new URL("file", "", path);
   	}
   
  -        if (! resolve.getProtocol().equalsIgnoreCase(
  -                org.apache.tomcat.core.Constants.Request.WAR) &&
  +        if (! resolve.getProtocol().equalsIgnoreCase("war") &&
               resolve.getFile().toLowerCase().endsWith(
                   "." + Constants.MIME.WAR)) {
               URL u = new URL(Constants.MIME.WAR + ":" +