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/core Container.java Context.java Request.java RequestDispatcherImpl.java RequestMapper.java ServletContextFacade.java LookupResult.java
Date Fri, 07 Jan 2000 18:48:35 GMT
costin      00/01/07 10:48:35

  Modified:    src/share/org/apache/tomcat/core Container.java Context.java
                        Request.java RequestDispatcherImpl.java
                        RequestMapper.java ServletContextFacade.java
  Removed:     src/share/org/apache/tomcat/core LookupResult.java
  Log:
  First step - removed LookupResult.
  
  LookupResult is used for "sub-requests" in RequestDispatcher
  and Context.getResource().
  We use Request instead for both normal requests and sub-requests.
  
  All tests are passing, it shouldn't brake to much.
  
  Revision  Changes    Path
  1.7       +11 -7     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Container.java	1999/11/26 09:03:43	1.6
  +++ Container.java	2000/01/07 18:48:34	1.7
  @@ -290,14 +290,14 @@
   	pathMappedServlets.remove(mapping);
       }
   
  -    LookupResult lookupServlet(String lookupPath) {
  +    Request lookupServlet(String lookupPath) {
           RequestMapper requestMapper = new RequestMapper(this);
   
   	requestMapper.setPathMaps(pathMappedServlets);
   	requestMapper.setPrefixMaps(prefixMappedServlets);
   	requestMapper.setExtensionMaps(extensionMappedServlets);
   
  -	LookupResult lookupResult =
  +	Request lookupResult =
   	    requestMapper.lookupServlet(lookupPath);
   
           if (lookupResult == null) {
  @@ -313,20 +313,24 @@
   	    String servletPath = Constants.Servlet.Default.Map;
               String pathInfo = lookupPath;
   
  -	    lookupResult =
  -	        new LookupResult(wrapper, servletPath, pathInfo);
  +	    lookupResult = new Request();
  +	    lookupResult.setWrapper( wrapper );
  +	    lookupResult.setServletPath( servletPath );
  +	    lookupResult.setPathInfo( pathInfo );
   	}
   
   	return lookupResult;
       }
   
  -    LookupResult lookupServletByName(String servletName) {
  -        LookupResult lookupResult = null;
  +    Request lookupServletByName(String servletName) {
  +        Request lookupResult = null;
   
   	ServletWrapper wrapper = (ServletWrapper)servlets.get(servletName);
   
   	if (wrapper != null) {
  -	    lookupResult = new LookupResult(wrapper, null, "");
  +	    lookupResult = new Request();
  +	    lookupResult.setWrapper( wrapper );
  +	    lookupResult.setPathInfo("");
   	}
   
           return lookupResult;
  
  
  
  1.12      +3 -1      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Context.java	2000/01/04 02:53:06	1.11
  +++ Context.java	2000/01/07 18:48:34	1.12
  @@ -625,7 +625,9 @@
   
   	request.setServerSession(session);  // may be null
   
  -	LookupResult result =
  +	// XXX XXX XXX lookupServlet should operate on the original
  +	// request, it will change when we introduce the interceptors.
  +	Request result =
   	    container.lookupServlet(request.getLookupPath());
   	
   	request.setServletPath(result.getServletPath());
  
  
  
  1.11      +38 -4     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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Request.java	2000/01/04 02:53:06	1.10
  +++ Request.java	2000/01/07 18:48:34	1.11
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v 1.10
2000/01/04 02:53:06 rubys Exp $
  - * $Revision: 1.10 $
  - * $Date: 2000/01/04 02:53:06 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v 1.11
2000/01/07 18:48:34 costin Exp $
  + * $Revision: 1.11 $
  + * $Date: 2000/01/07 18:48:34 $
    *
    * ====================================================================
    *
  @@ -116,11 +116,16 @@
       protected boolean didCookies;
       // end "Request" variables
   
  +    // LookupResult - used by sub-requests and
  +    // set by interceptors
  +    ServletWrapper wrapper = null;
  +    String mappedPath = null;
  +    String resolvedServlet = null;
  +
       protected StringManager sm =
           StringManager.getManager(Constants.Package);
   
       public Request() {
  -        requestFacade = new HttpServletRequestFacade(this);
       }
   
       public void setRequestAdapter( RequestAdapter reqA) {
  @@ -298,6 +303,10 @@
   
       // -------------------- Request methods ( high level )
       public HttpServletRequestFacade getFacade() {
  +	// some requests are internal, and will never need a
  +	// facade - no need to create a new object unless needed.
  +        if( requestFacade==null )
  +	    requestFacade = new HttpServletRequestFacade(this);
   	return requestFacade;
       }
   
  @@ -396,6 +405,31 @@
   //  		return null;
   //  	    }
   //  	}
  +    }
  +
  +    // -------------------- LookupResult 
  +    String getResolvedServlet() {
  +	return resolvedServlet;
  +    }
  +
  +    void setResolvedServlet(String rs ) {
  +	resolvedServlet=rs;
  +    }
  +
  +    ServletWrapper getWrapper() {
  +	return wrapper;
  +    }
  +    
  +    void setWrapper(ServletWrapper wrapper) {
  +	this.wrapper=wrapper;
  +    }
  +
  +    String getMappedPath() {
  +	return mappedPath;
  +    }
  +
  +    void setMappedPath( String m ) {
  +	mappedPath=m;
       }
   
       // -------------------- Setters
  
  
  
  1.4       +13 -4     jakarta-tomcat/src/share/org/apache/tomcat/core/RequestDispatcherImpl.java
  
  Index: RequestDispatcherImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestDispatcherImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RequestDispatcherImpl.java	1999/12/29 04:54:15	1.3
  +++ RequestDispatcherImpl.java	2000/01/07 18:48:34	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestDispatcherImpl.java,v
1.3 1999/12/29 04:54:15 bergsten Exp $
  - * $Revision: 1.3 $
  - * $Date: 1999/12/29 04:54:15 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestDispatcherImpl.java,v
1.4 2000/01/07 18:48:34 costin Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/01/07 18:48:34 $
    *
    * ====================================================================
    *
  @@ -84,7 +84,7 @@
       private StringManager sm =
           StringManager.getManager(Constants.Package);
       private Context context;
  -    private LookupResult lookupResult = null;
  +    private Request lookupResult = null;
       private String name = null;
       private String urlPath;
       private String queryString;
  @@ -112,6 +112,10 @@
   
   	urlPath = context.getPath() + urlPath;
   
  +	// XXX Need to clean up - what's the diff between the lookupResult
  +	// ( internal-generated sub-request ) and ForwardedRequest  ?
  +	// I think ForwardedRequest can be removed, it's a particular case of
  +	// sub-request ( costin )
   	ForwardedRequest fRequest =
   	    new ForwardedRequest(realRequest, urlPath);
   
  @@ -129,6 +133,11 @@
       throws ServletException, IOException {
   	HttpServletRequest req = (HttpServletRequest)request;
   
  +	// XXX instead of setting the new parameters and back to original,
  +	// it should just use a sub-request ( by cloning the original ) 
  +	// That will simplify everything and make the code clear ( costin )
  +	
  +	// 
           // XXX
           // while this appears to work i believe the code
           // could be streamlined/normalized a bit.
  
  
  
  1.7       +9 -5      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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RequestMapper.java	1999/12/17 18:59:14	1.6
  +++ RequestMapper.java	2000/01/07 18:48:34	1.7
  @@ -74,6 +74,7 @@
       private Hashtable prefixMaps = null;
       private Hashtable extensionMaps = null;
       private Hashtable pathMaps = null;
  +
       private String servletPath = null;
       private String mapPath = null;
       private String pathInfo = null;
  @@ -95,17 +96,20 @@
           this.extensionMaps = extensionMaps;
       }
   
  -    LookupResult lookupServlet(String path) {
  -	LookupResult lookupResult = null;
  +    Request lookupServlet(String path) {
  +	Request lookupResult = null;
   	ServletWrapper wrapper = getMatch(path);
   
   	if (wrapper != null) {
               this.mapPath = getMapPath(wrapper);
               String resolvedServlet = getResolvedServlet(this.mapPath);
   
  -            lookupResult = new LookupResult(wrapper,
  -                this.servletPath, this.mapPath, this.pathInfo,
  -                resolvedServlet);
  +	    lookupResult = new Request();
  +	    lookupResult.setWrapper( wrapper );
  +	    lookupResult.setServletPath( servletPath );
  +	    lookupResult.setMappedPath( mapPath );
  +	    lookupResult.setPathInfo(pathInfo);
  +	    lookupResult.setResolvedServlet( resolvedServlet );
           }
   
   	return lookupResult;
  
  
  
  1.6       +4 -4      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ServletContextFacade.java	1999/11/27 06:20:03	1.5
  +++ ServletContextFacade.java	2000/01/07 18:48:34	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletContextFacade.java,v
1.5 1999/11/27 06:20:03 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 1999/11/27 06:20:03 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletContextFacade.java,v
1.6 2000/01/07 18:48:34 costin Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/01/07 18:48:34 $
    *
    * ====================================================================
    *
  @@ -250,7 +250,7 @@
   	// this could use a once over - after war perhaps
   
           URL docBase = context.getDocumentBase();
  -	LookupResult lr =
  +	Request lr =
   	    getRealContext().getContainer().lookupServlet(path);
   	String mappedPath = path;
   
  
  
  

Mime
View raw message