tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/java/org/apache/jk/server/tomcat33 JkRequest33.java JkResponse33.java JkServlet33.java Worker33.java
Date Wed, 06 Feb 2002 17:51:44 GMT
costin      02/02/06 09:51:44

  Modified:    jk/java/org/apache/jk/server/tomcat33 JkRequest33.java
                        JkResponse33.java JkServlet33.java Worker33.java
  Log:
  Update for the API changes.
  
  Add the missing input stream support.
  
  Now the 33 adapter should be fully functional ( or close enough - I'll
  start running watchdogs ). Config is still missing from both adapters,
  it's the only thing remaining before we're ready to release jk2 ( the java
  side ).
  
  Revision  Changes    Path
  1.3       +32 -30    jakarta-tomcat-connectors/jk/java/org/apache/jk/server/tomcat33/JkRequest33.java
  
  Index: JkRequest33.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/server/tomcat33/JkRequest33.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JkRequest33.java	26 Jan 2002 17:25:20 -0000	1.2
  +++ JkRequest33.java	6 Feb 2002 17:51:44 -0000	1.3
  @@ -63,7 +63,6 @@
   import java.net.*;
   import java.util.*;
   
  -import org.apache.jk.*;
   import org.apache.jk.core.*;
   import org.apache.jk.common.*;
   import org.apache.tomcat.modules.server.PoolTcpConnector;
  @@ -78,8 +77,9 @@
   class JkRequest33 extends Request 
   {
       BaseRequest ajpReq;
  -    Channel ch;
  -    Endpoint ep;
  +    MsgContext ep;
  +
  +    JkInputStream jkIS;
       
       public JkRequest33(BaseRequest ajpReq) 
       {
  @@ -91,7 +91,7 @@
   	remoteAddrMB = ajpReq.remoteAddr();
   	remoteHostMB = ajpReq.remoteHost();
   	serverNameMB = ajpReq.serverName();
  -
  +        
   	// XXX sync cookies 
   	scookies = new Cookies( headers );
   	urlDecoder=new UDecoder();
  @@ -106,9 +106,11 @@
   	this.ajpReq=ajpReq;
       }
   
  -    public void setEndpoint( Channel ch, Endpoint ep ) {
  -        this.ch=ch;
  +    public void setEndpoint( MsgContext ep ) {
           this.ep=ep;
  +        int bodyNote= ep.getWorkerEnv().getNoteId( WorkerEnv.ENDPOINT_NOTE,
  +                                                   "jkInputStream");
  +        jkIS=(JkInputStream)ep.getNote( bodyNote );
       }
       
       // -------------------- Wrappers for changed method names
  @@ -155,17 +157,6 @@
   	return ajpReq.getSecure();
       }
       
  -    public int getContentLength() {
  -        int i=ajpReq.getContentLength();
  -	if( i >= 0 ) return i;
  -	i= super.getContentLength();
  -	return i;
  -    }
  -
  -    public void setContentLength( int i ) {
  -	super.setContentLength(i); // XXX sync
  -    }
  -
       // -------------------- Attributes --------------------
       
       public void setAttribute(String name, Object value) {
  @@ -191,6 +182,7 @@
       public void recycle() {
   	super.recycle();
   	ajpReq.recycle();
  +        jkIS.recycle();
       }
   
       public String dumpRequest() {
  @@ -199,26 +191,36 @@
       
       // -------------------- 
       
  -    // XXX This should go away if we introduce an InputBuffer.
  -    // We almost have it as result of encoding fixes, but for now
  -    // just keep this here, doesn't hurt too much.
       public int doRead() throws IOException 
       {
  -	if( available <= 0 )
  -	    return -1;
  -// 	available--;
  -// 	return ajp13.reqHandler.doRead(ajp13);
  -        return -1;
  +        // we need to manager the request's available
  +        // this should go away, we support this in JkInputStream,
  +        // which is similar with OutputBuffer - it should
  +        // take away the body processing
  +        if( contentLength == -1 ) {
  +            return jkIS.read();
  +	}
  +	if( available <= 0 ) {
  +            return -1;
  +        }
  +	available--;
  +
  +        return jkIS.read();
       }
       
       public int doRead(byte[] b, int off, int len) throws IOException 
       {
  -	if( available <= 0 )
  +        int rd=-1;
  +        if( contentLength == -1 ) {
  +	    rd=jkIS.read(b,off,len);
  +	    return rd;
  +	}
  +	if( available <= 0 ) {
   	    return -1;
  -// 	int rd=ajp13.reqHandler.doRead( ajp13, b,off, len );
  -// 	available -= rd;
  -// 	return rd;
  -        return -1;
  +        }
  +	rd=jkIS.read( b,off, len );
  +	available -= rd;
  +	return rd;
       }
       
   }
  
  
  
  1.3       +3 -3      jakarta-tomcat-connectors/jk/java/org/apache/jk/server/tomcat33/JkResponse33.java
  
  Index: JkResponse33.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/server/tomcat33/JkResponse33.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JkResponse33.java	26 Jan 2002 17:25:20 -0000	1.2
  +++ JkResponse33.java	6 Feb 2002 17:51:44 -0000	1.3
  @@ -80,7 +80,7 @@
   {
       boolean finished=false;
       Channel ch;
  -    Endpoint ep;
  +    MsgContext ep;
       int headersMsgNote;
       int c2bConvertersNote;
       int utfC2bNote;
  @@ -92,8 +92,8 @@
           utfC2bNote=we.getNoteId( WorkerEnv.ENDPOINT_NOTE, "utfC2B" );
       }
   
  -    public void setEndpoint( Channel ch, Endpoint ep ) {
  -        this.ch=ch;
  +    public void setEndpoint( MsgContext ep ) {
  +        this.ch=ep.getChannel();
           this.ep=ep;
           MsgAjp msg=(MsgAjp)ep.getNote( headersMsgNote );
           if( msg==null ) {
  
  
  
  1.3       +4 -3      jakarta-tomcat-connectors/jk/java/org/apache/jk/server/tomcat33/JkServlet33.java
  
  Index: JkServlet33.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/server/tomcat33/JkServlet33.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JkServlet33.java	12 Jan 2002 04:20:43 -0000	1.2
  +++ JkServlet33.java	6 Feb 2002 17:51:44 -0000	1.3
  @@ -90,16 +90,17 @@
       public void initializeContainer(ServletConfig cfg) {
           try {
               ServletContext sctx=cfg.getServletContext();
  -            Context ctx=(Context)sctx.getAttribute( Context.ATTRIB_REAL_CONTEXT );
  +            Context ctx=
  +                (Context)sctx.getAttribute( Context.ATTRIB_REAL_CONTEXT );
               if( ctx==null ) {
                   d("Untrusted app or error, ctx==null ");
                   return;
               }
               cm=ctx.getContextManager();
  -            
               // We now have control over the whole thing !
  -            
  +
               // We could register an interceptor to be notified
  +            // on tomcat's events
               registerInterceptors();
               
               Worker33 worker=new Worker33();
  
  
  
  1.3       +9 -6      jakarta-tomcat-connectors/jk/java/org/apache/jk/server/tomcat33/Worker33.java
  
  Index: Worker33.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/server/tomcat33/Worker33.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Worker33.java	26 Jan 2002 17:25:20 -0000	1.2
  +++ Worker33.java	6 Feb 2002 17:51:44 -0000	1.3
  @@ -80,7 +80,7 @@
   /** Tomcat 33 worker
    *
    */
  -public class Worker33 extends Worker
  +public class Worker33 extends JkHandler
   {
       ContextManager cm;
       
  @@ -92,35 +92,38 @@
       private int reqNote;
       
       public void init() throws IOException {
  -        reqNote=we.getNoteId( WorkerEnv.REQUEST_NOTE, "tomcat33Request" );
  +        reqNote=wEnv.getNoteId( WorkerEnv.REQUEST_NOTE, "tomcat33Request" );
       }
   
       public void setContextManager( ContextManager cm ) {
           this.cm=cm;
       }
       
  -    public void service( BaseRequest req, Channel ch, Endpoint ep )
  +    public int invoke( Msg msg, MsgContext ep ) // BaseRequest req, Channel ch, Endpoint
ep )
           throws IOException
       {
           d("Incoming request " );
  +        BaseRequest req=ep.getRequest();
  +        Channel ch=ep.getChannel();
           JkRequest33 treq=(JkRequest33)req.getNote( reqNote );
           JkResponse33 tres;
           if( treq==null ) {
               treq=new JkRequest33(req);
               req.setNote( reqNote, treq );
  -            tres=new JkResponse33(we);
  +            tres=new JkResponse33(wEnv);
               treq.setResponse( tres );
               cm.initRequest( treq, tres );
           }
           tres=(JkResponse33)treq.getResponse();
  -        treq.setEndpoint( ch, ep );
  -        tres.setEndpoint( ch, ep );
  +        treq.setEndpoint( ep );
  +        tres.setEndpoint( ep );
   
           try {
               cm.service( treq, tres );
           } catch(Exception ex ) {
               ex.printStackTrace();
           }
  +        return OK;
       }
   
       private static final int dL=0;
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message