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 Request.java
Date Thu, 02 Nov 2000 21:39:13 GMT
costin      00/11/02 13:39:13

  Modified:    src/share/org/apache/tomcat/core Request.java
  Log:
  - Added request "state"
  
  - Replaced String with MessageBytes for request components ( uri, method,
  protocol, etc). ( needed for no-ascii charset support, performance )
  
  - replace getWrapper with getHandler ( Wrapper is part of facade )
  
  ( other classes are changed to accomodate the String->MessageByte
  conversion )
  
  Revision  Changes    Path
  1.70      +87 -39    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.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- Request.java	2000/10/08 21:28:56	1.69
  +++ Request.java	2000/11/02 21:39:12	1.70
  @@ -98,6 +98,16 @@
        */
       public static final String ATTRIB_REAL_REQUEST="org.apache.tomcat.request";
   
  +    public static final int STATE_UNUSED=0;
  +
  +    public static final int STATE_INVALID=-1;
  +
  +    public static final int STATE_NEW=1;
  +
  +    public static final int STATE_CONTEXT_MAPPED=2;
  +
  +    public static final int STATE_MAPPED=3;
  +    
       // -------------------- properties --------------------
   
       protected int serverPort;
  @@ -105,6 +115,8 @@
       protected String remoteHost;
       protected String localHost;
   
  +    protected int state;
  +
       // Request components represented as MB.
       // MB are also used for headers - it allows lazy
       // byte->char conversion so we can add the encoding
  @@ -129,6 +141,8 @@
   
       // Processed information ( redundant ! )
       protected Hashtable parameters = new Hashtable();
  +    protected boolean didReadFormData;
  +    protected boolean didParameters;
   
       protected int contentLength = -1;
       protected String contentType = null;
  @@ -150,10 +164,6 @@
       protected Context context;
       protected Object requestFacade;
   
  -    protected boolean didReadFormData;
  -    protected boolean didParameters;
  -    // end "Request" variables
  -
       // Session
       protected String reqSessionId;
       protected String sessionIdSource;
  @@ -185,6 +195,14 @@
    	recycle(); // XXX need better placement-super()
       }
   
  +    public final int getState() {
  +	return state;
  +    }
  +
  +    final void setState( int state ) {
  +	this.state=state;
  +    }
  +    
       /** Called by mapper interceptors after the context
   	is found or directly by server adapters when
   	this is known in advance
  @@ -231,42 +249,42 @@
   
       // -------------------- Request data --------------------
   
  -    public MessageBytes getSchemeMB() {
  -	return schemeMB;
  -    }
  +//     public MessageBytes getSchemeMB() {
  +// 	return schemeMB;
  +//     }
   
  -    public String getScheme() {
  -        return schemeMB.toString();
  -    }
  +//     public String getScheme() {
  +//         return schemeMB.toString();
  +//     }
   
  -    public void setScheme( String scheme ) {
  -	schemeMB.setString(scheme);
  -    }
  +//     public void setScheme( String scheme ) {
  +// 	schemeMB.setString(scheme);
  +//     }
   
  -    public String getMethod() {
  -        return methodMB.toString();
  -    }
  +//     public String getMethod() {
  +//         return methodMB.toString();
  +//     }
   
  -    public void setMethod( String method ) {
  -	methodMB.setString(method);
  -    }
  +//     public void setMethod( String method ) {
  +// 	methodMB.setString(method);
  +//     }
   
  -    public String getRequestURI() {
  -	return uriMB.toString();
  +    public MessageBytes scheme() {
  +	return schemeMB;
       }
  -
  -    public void setRequestURI( String r ) {
  - 	uriMB.setString(r);
  +    
  +    public MessageBytes method() {
  +	return methodMB;
       }
  -
  -    public String getQueryString() {
  -        return queryMB.toString();
  +    
  +    public MessageBytes requestURI() {
  +	return uriMB;
       }
   
  -    public void setQueryString(String queryString) {
  -	queryMB.setString(queryString);
  +    public MessageBytes queryString() {
  +	return queryMB;
       }
  -
  +    
       public String getProtocol() {
           return protoMB.toString();
       }
  @@ -424,7 +442,7 @@
   	    // Call all authentication callbacks. If any of them is able to
   	    // 	identify the user it will set the principal in req.
   	    int status=0;
  -	    BaseInterceptor reqI[]= context.getContainer().
  +	    BaseInterceptor reqI[]= getContainer().
   		getInterceptors(Container.H_authenticate);
   	    for( int i=0; i< reqI.length; i++ ) {
   		status=reqI[i].authenticate( this, response );
  @@ -477,7 +495,7 @@
   	checkRoles[0]=role;
   
   	int status=0;
  -	BaseInterceptor reqI[]= context.getContainer().
  +	BaseInterceptor reqI[]= getContainer().
   	    getInterceptors(Container.H_authorize);
   
   	// Call all authorization callbacks. 
  @@ -564,8 +582,8 @@
   
   	if( ! create ) return null;
   
  -	BaseInterceptor reqI[]= contextM.
  -	    getInterceptors(this, Container.H_newSessionRequest);
  +	BaseInterceptor reqI[]= getContainer().
  +	    getInterceptors(Container.H_newSessionRequest);
   
   	for( int i=0; i< reqI.length; i++ ) {
   	    reqI[i].newSessionRequest( this, response );
  @@ -609,15 +627,44 @@
       }
   
       // -------------------- LookupResult
  -    public Handler getWrapper() {
  +
  +    /** As result of mapping the request a "handler" will be associated
  +	and called to generate the result.
  +
  +	The handler is null if no mapping was found ( so far ).
  +
  +	The handler can be set if the request is found to match any
  +	of the rules defined in web.xml ( and as a result, a container will
  +	be set ), or if a special interceptor will define a tomcat-specific
  +	handler ( like static, jsp, or invoker ).
  +    */
  +    public Handler getHandler() {
   	return handler;
       }
   
  -    public void setWrapper(Handler handler) {
  +    public void setHandler(Handler handler) {
   	this.handler=handler;
       }
   
  +    /** Return the container ( URL pattern ) where this request has been
  +	mapped.
  +
  +	If the request is invalid ( context can't be determined )
  +	the ContextManager.container will be returned.
  +
  +	If the request is not mapped ( requestMap not called yet )
  +	or the request corresponds to the "default" map ( * ) or a
  +	special implicit map ( *.jsp, invoker ),
  +	then the context's default container is returned
  +    */
       public Container getContainer() {
  +	if( container==null && context==null) {
  +	    container=contextM.getContainer();
  +	    // only for invalid requests !
  +	}
  +	if( container==null ) {
  +	    container=context.getContainer();
  +	}
   	return container;
       }
   
  @@ -723,7 +770,7 @@
       // -------------------- Utils - facade for RequestUtil
       private void handleParameters() {
      	if(!didParameters) {
  -	    String qString=getQueryString();
  +	    String qString=queryString().toString();
   	    if(qString!=null) {
   		didParameters=true;
   		RequestUtil.processFormData( qString, parameters );
  @@ -733,7 +780,8 @@
   	    didReadFormData = true;
   	    Hashtable postParameters=RequestUtil.readFormData( this );
   	    if(postParameters!=null)
  -		parameters = RequestUtil.mergeParameters(parameters, postParameters);
  +		parameters = RequestUtil.mergeParameters(parameters,
  +							 postParameters);
   	}
       }
   
  @@ -802,7 +850,7 @@
   	    if( getServletPath() != null )
   		sb.append( " + " + getServletPath() + " + " + getPathInfo());
   	} else {
  -	    sb.append(getRequestURI());
  +	    sb.append(requestURI().toString());
   	}
   	sb.append(")");
   	return sb.toString();
  
  
  

Mime
View raw message