tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@hyperreal.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Constants.java Container.java Context.java LookupResult.java RequestMapper.java
Date Fri, 05 Nov 1999 18:36:39 GMT
costin      99/11/05 10:36:38

  Modified:    src/share/org/apache/tomcat/core Constants.java
                        Container.java Context.java LookupResult.java
                        RequestMapper.java
  Log:
  Merged gonzo's fixes from j2ee branch.
  
  Revision  Changes    Path
  1.5       +3 -7      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Constants.java	1999/11/03 20:54:59	1.4
  +++ Constants.java	1999/11/05 18:36:30	1.5
  @@ -1,8 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Constants.java,v
1.4 1999/11/03 20:54:59 costin Exp $
  - * $Revision: 1.4 $
  - * $Date: 1999/11/03 20:54:59 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -171,9 +167,9 @@
       }
   
       public static class JSP {
  -	public static final String NAME = "jsp";
  +        public static final String NAME = "jsp";
   	public static final String CLASSNAME = "org.apache.jasper.runtime.JspServlet";
  -	
  +     
           public static class Directive {
               public static class Compile {
                   public static final String Name = "jsp_precompile";
  @@ -200,7 +196,7 @@
           public static final String ERROR_MESSAGE =
               "javax.servlet.error.message";
           public static final String RESOLVED_SERVLET =
  -            "javax.servlet.resolved";
  +            "org.apache.tomcat.servlet.resolved";
       }
   
       public static class Locale {
  
  
  
  1.3       +15 -10    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Container.java	1999/11/03 20:38:51	1.2
  +++ Container.java	1999/11/05 18:36:30	1.3
  @@ -1,8 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Container.java,v
1.2 1999/11/03 20:38:51 costin Exp $
  - * $Revision: 1.2 $
  - * $Date: 1999/11/03 20:38:51 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -266,7 +262,7 @@
   	if (sw != null &&
   	    (path.length() > 0)) {
   	    if (path.startsWith("/") &&
  -                path.endsWith("/*")){ 
  +                path.endsWith("/*")){
   	        prefixMappedServlets.put(path, sw);
   	    } else if (path.startsWith("*.")) {
   	        extensionMappedServlets.put(path, sw);
  @@ -295,7 +291,7 @@
       }
   
       LookupResult lookupServlet(String lookupPath) {
  -        RequestMapper requestMapper = new RequestMapper();
  +        RequestMapper requestMapper = new RequestMapper(this);
   
   	requestMapper.setPathMaps(pathMappedServlets);
   	requestMapper.setPrefixMaps(prefixMappedServlets);
  @@ -304,7 +300,7 @@
   	LookupResult lookupResult =
   	    requestMapper.lookupServlet(lookupPath);
   
  -	if (lookupResult == null) {
  +        if (lookupResult == null) {
   	    ServletWrapper wrapper = null;
   
   	    if (defaultServlet != null) {
  @@ -369,6 +365,11 @@
           // XXX
           // check for duplicates!
   
  +        if (servlets.get(name) != null) {
  +            removeServlet(name);
  +            removeServletByName(name);
  +        }
  +
           ServletWrapper wrapper = new ServletWrapper(this);
   
   	wrapper.setServletName(name);
  @@ -439,8 +440,9 @@
   	    String key = (String)enum.nextElement();
   	    ServletWrapper sw = (ServletWrapper)servlets.get(key);
   
  -	    if (sw.getServletClass() != null &&
  -	        sw.getServletClass().equals(name)) {
  +
  +            if (sw.getServletClass() != null &&
  +                sw.getServletClass().equals(name)) {
   	        servletWrappers.addElement(sw);
   	    }
   	}
  @@ -452,8 +454,11 @@
   
           return wrappers;
       }
  +
  +    // XXX
  +    // made package protected so that RequestMapper can have access
   
  -    private ServletWrapper[] getServletsByPath(String path) {
  +    ServletWrapper[] getServletsByPath(String path) {
           Vector servletWrappers = new Vector();
   	Enumeration enum = servlets.keys();
   
  
  
  
  1.8       +4 -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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Context.java	1999/11/03 20:38:51	1.7
  +++ Context.java	1999/11/05 18:36:31	1.8
  @@ -1,8 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v 1.7
1999/11/03 20:38:51 costin Exp $
  - * $Revision: 1.7 $
  - * $Date: 1999/11/03 20:38:51 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -635,7 +631,10 @@
   	request.setServletPath(result.getServletPath());
   	request.setPathInfo(result.getPathInfo());
   
  -        if (result.getMappedPath() != null) {
  +        if (result.getResolvedServlet() != null) {
  +            request.setAttribute(Constants.Attribute.RESOLVED_SERVLET,
  +                result.getResolvedServlet());
  +        } else if (result.getMappedPath() != null) {
               request.setAttribute(Constants.Attribute.RESOLVED_SERVLET,
                   result.getMappedPath());
           } else {
  
  
  
  1.2       +12 -7     jakarta-tomcat/src/share/org/apache/tomcat/core/LookupResult.java
  
  Index: LookupResult.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/LookupResult.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LookupResult.java	1999/10/09 00:30:14	1.1
  +++ LookupResult.java	1999/11/05 18:36:33	1.2
  @@ -1,8 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/LookupResult.java,v
1.1 1999/10/09 00:30:14 duncan Exp $
  - * $Revision: 1.1 $
  - * $Date: 1999/10/09 00:30:14 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -76,20 +72,25 @@
       private String servletPath = null;
       private String mappedPath = null;
       private String pathInfo = null;
  +    private String resolvedServlet = null;
   
       LookupResult(ServletWrapper wrapper, String servletPath,
           String pathInfo) {
  -	this.wrapper = wrapper;
  -	this.servletPath = servletPath;
  -	this.pathInfo = pathInfo;
  +        this(wrapper, servletPath, null, pathInfo, null);
       }
   
       LookupResult(ServletWrapper wrapper, String servletPath,
           String mappedPath, String pathInfo) {
  +        this(wrapper, servletPath, mappedPath, pathInfo, null);
  +    }
  +
  +    LookupResult(ServletWrapper wrapper, String servletPath,
  +        String mappedPath, String pathInfo, String resolvedServlet) {
   	this.wrapper = wrapper;
   	this.servletPath = servletPath;
   	this.mappedPath = mappedPath;
   	this.pathInfo = pathInfo;
  +	this.resolvedServlet = resolvedServlet;
       }
   
       ServletWrapper getWrapper() {
  @@ -106,5 +107,9 @@
   
       String getPathInfo() {
   	return pathInfo;
  +    }
  +
  +    String getResolvedServlet() {
  +	return resolvedServlet;
       }
   }
  
  
  
  1.5       +21 -8     jakarta-tomcat/src/share/org/apache/tomcat/core/RequestMapper.java
  
  Index: RequestMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestMapper.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RequestMapper.java	1999/11/03 20:55:00	1.4
  +++ RequestMapper.java	1999/11/05 18:36:33	1.5
  @@ -1,8 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestMapper.java,v
1.4 1999/11/03 20:55:00 costin Exp $
  - * $Revision: 1.4 $
  - * $Date: 1999/11/03 20:55:00 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -74,6 +70,7 @@
    */
   
   public class RequestMapper {
  +    private Container container = null;
       private Hashtable prefixMaps = null;
       private Hashtable extensionMaps = null;
       private Hashtable pathMaps = null;
  @@ -82,7 +79,8 @@
       private String pathInfo = null;
       private String resourceName = null;
   
  -    RequestMapper() {
  +    RequestMapper(Container container) {
  +        this.container = container;
       }
   
       void setPathMaps(Hashtable pathMaps) {
  @@ -103,9 +101,11 @@
   
   	if (wrapper != null) {
               this.mapPath = getMapPath(wrapper);
  +            String resolvedServlet = getResolvedServlet(this.mapPath);
   
               lookupResult = new LookupResult(wrapper,
  -                this.servletPath, this.mapPath, this.pathInfo);
  +                this.servletPath, this.mapPath, this.pathInfo,
  +                resolvedServlet);
           }
   
   	return lookupResult;
  @@ -237,7 +237,8 @@
               this.resourceName = this.servletPath;
   
               while (stillSearching) {
  -                if (wrapper.getPath() != null &&
  +                if (wrapper != null &&
  +                    wrapper.getPath() != null &&
                       wrapper.getServletClass() == null) {
                           this.resourceName = wrapper.getPath();
                           wrapper = getMatch(wrapper.getPath() +
  @@ -286,7 +287,7 @@
               this.resourceName != null) {
               // XXX
               // hack to differentiate amongst a mapped servlet and a jsp
  -            if (! wrapper.getServletClass().equals(Constants.JSP.CLASSNAME)) {
  +	    if (! wrapper.getServletClass().equals(Constants.JSP.CLASSNAME)) {
                   mapPath = "/" + wrapper.getServletClass();
               } else {
                   mapPath = this.resourceName;
  @@ -294,5 +295,17 @@
           }
   
           return mapPath;
  +    }
  +
  +    private String getResolvedServlet(String path) {
  +        String resolvedServlet = null;
  +        ServletWrapper[] sw = this.container.getServletsByPath(path);
  +
  +        if (sw.length > 0) {
  +            // assume one
  +            resolvedServlet = sw[0].getServletName();
  +        }
  +
  +        return resolvedServlet;
       }
   }
  
  
  

Mime
View raw message