costin      02/04/09 10:13:51

  Modified:    jk/java/org/apache/jk/server JkCoyoteHandler.java
  Log:
  Implement the input buffer.
  
  Recycle the req/res ( coyote http adapter doesn't call recycle on
  coyoteRequest/coyoteResponse - which is actually a very good idea ).
  
  Add a workaround for the fact that COMMIT is not called.
  
  Revision  Changes    Path
  1.5       +28 -5     
jakarta-tomcat-connectors/jk/java/org/apache/jk/server/JkCoyoteHandler.java
  
  Index: JkCoyoteHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/server/JkCoyoteHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JkCoyoteHandler.java      8 Apr 2002 22:59:37 -0000       1.4
  +++ JkCoyoteHandler.java      9 Apr 2002 17:13:51 -0000       1.5
  @@ -86,7 +86,8 @@
       int utfC2bNote;
       int obNote;
       int epNote;
  -
  +    int inputStreamNote;
  +    
       Adapter adapter;
       protected JkMain jkMain=new JkMain();
       
  @@ -121,6 +122,8 @@
           jkMain.getWorkerEnv().addHandler("container", this );
   
           try {
  +            // jkMain.setJkHome() XXX;
  +            
               jkMain.init();
               jkMain.start();
   
  @@ -130,6 +133,8 @@
               utfC2bNote=wEnv.getNoteId( WorkerEnv.ENDPOINT_NOTE, "utfC2B" );
               epNote=wEnv.getNoteId( WorkerEnv.ENDPOINT_NOTE, "ep" );
               obNote=wEnv.getNoteId( WorkerEnv.ENDPOINT_NOTE, "coyoteBuffer" );
  +            inputStreamNote= wEnv.getNoteId( WorkerEnv.ENDPOINT_NOTE,
  +                                             "jkInputStream");
   
           } catch( Exception ex ) {
               ex.printStackTrace();
  @@ -146,6 +151,7 @@
       {
           int epNote;
           int headersMsgNote;
  +        int inputStreamNote;
           org.apache.coyote.Response res;
           
           void setResponse( org.apache.coyote.Response res ) {
  @@ -155,6 +161,12 @@
           public int doWrite(ByteChunk chunk) 
               throws IOException
           {
  +            if (!res.isCommitted()) {
  +                // Send the connector a request for commit. The connector should
  +                // then validate the headers, send them (using sendHeader) and 
  +                // set the filters accordingly.
  +                res.action(ActionCode.ACTION_COMMIT, null);
  +            }
               if( log.isInfoEnabled() )
                   log.info("doWrite " );
               MsgContext ep=(MsgContext)res.getNote( epNote );
  @@ -172,8 +184,12 @@
               throws IOException
           {
               if( log.isInfoEnabled() )
  -                log.info("doRead " );
  -            return 0;
  +                log.info("doRead " + chunk.getBytes() + " " +  chunk.getOffset() + 
" " + chunk.getLength());
  +            MsgContext ep=(MsgContext)res.getNote( epNote );
  +
  +            JkInputStream jkIS=(JkInputStream)ep.getNote( inputStreamNote );
  +            // return jkIS.read( chunk.getBytes(), chunk.getOffset(), 
chunk.getLength());
  +            return jkIS.doRead( chunk );
           }
       }
   
  @@ -186,13 +202,16 @@
           org.apache.coyote.Response res=req.getResponse();
           res.setHook( this );
   
  +        log.info( "Invoke " + req + " " + res + " " + req.requestURI().toString());
           JkCoyoteBuffers ob=(JkCoyoteBuffers)res.getNote( obNote );
           if( ob == null ) {
               // Buffers not initialized yet
               // Workaround - IB, OB require state.
               ob=new JkCoyoteBuffers();
  +            // Pass the required state.
               ob.epNote=epNote;
               ob.headersMsgNote=headersMsgNote;
  +            ob.inputStreamNote=inputStreamNote;
               ob.setResponse(res);
               res.setOutputBuffer( ob );
               req.setInputBuffer( ob );
  @@ -209,6 +228,9 @@
           } catch( Exception ex ) {
               ex.printStackTrace();
           }
  +
  +        req.recycle();
  +        res.recycle();
           return OK;
       }
   
  @@ -217,10 +239,11 @@
       public void action(ActionCode actionCode, Object param) {
           try {
               if( actionCode==ActionCode.ACTION_COMMIT ) {
  +                org.apache.coyote.Response res=(org.apache.coyote.Response)param;
  +
                   if( log.isInfoEnabled() )
  -                    log.info("COMMIT sending headers " );
  +                    log.info("COMMIT sending headers " + res + " " + 
res.getMimeHeaders() );
                   
  -                org.apache.coyote.Response res=(org.apache.coyote.Response)param;
                   
                   C2B c2b=(C2B)res.getNote( utfC2bNote );
                   if( c2b==null ) {
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to