Those patches allow :
to access to a 'con' handler in JNIEndpointConnector 
to extend JNIConnectionHandler in order to access JNIRequestAdapter and
JNIResponseAdapter.
I just put JNIRequestAdapter and JNIResponseAdapter public in
org.apache.tomcat.service.connector

Bye
--- 
E:\work\JNIConnector\sources\org\apache\tomcat\service\connector\JNIConnectionHandler.java
  Tue Jul  3 14:34:56 2001
+++ 
+E:\work\jakarta-tomcat-3.2.2-src\src\share\org\apache\tomcat\service\connector\JNIConnectionHandler.java
+    Tue Jul  3 14:35:09 2001
@@ -63,7 +63,10 @@
 
 package org.apache.tomcat.service.connector;
 
+import java.io.IOException;
 import org.apache.tomcat.core.*;
+import org.apache.tomcat.util.*;
+import javax.servlet.ServletInputStream;
 import java.util.Vector;
 import java.io.File;
 
@@ -202,6 +205,183 @@
                      int cnt);
 }
 
+class JNIRequestAdapter extends RequestImpl {
+    static StringManager sm = StringManager.getManager("org.apache.tomcat.service");
+    ContextManager contextM;
+    boolean shutdown=false;
+
+    JNIConnectionHandler h;
+    long s;
+    long l;
+
+    public int doRead() throws IOException {
+        byte []b = new byte[1];
+        int rc = doRead(b, 0, 1);
+
+        if(rc <= 0) {
+            return -1;
+        }
+
+        return ((int)b[0]) & 0x000000FF;
+    }
+
+    public  int doRead(byte b[], int off, int len) throws IOException {
+        int rc = 0;
+
+        while(0 == rc) {
+               rc = h.read(s, l, b, off, len);
+               if(0 == rc) {
+                   Thread.currentThread().yield();
+               }
+           }
+           return rc;
+    }
+
+    public JNIRequestAdapter(ContextManager cm,
+                             JNIConnectionHandler h) {
+       this.contextM = cm;
+       this.h = h;
+    }
+
+    protected void readNextRequest(long s, long l) throws IOException {
+        String []env = new String[15];
+        int i = 0;
 
+       this.s = s;
+       this.l = l;
 
+        for(i = 0 ; i < 12 ; i++) {
+            env[i] = null;
+        }
+
+        /*
+         * Read the environment
+         */
+        if(h.readEnvironment(s, l, env) > 0) {
+               method      = env[0];
+               requestURI  = env[1];
+               queryString = env[2];
+               remoteAddr  = env[3];
+               remoteHost  = env[4];
+               serverName  = env[5];
+            serverPort  = Integer.parseInt(env[6]);
+            authType    = env[7];
+            remoteUser  = env[8];
+            scheme      = env[9];
+            protocol    = env[10];
+            // response.setServerHeader(env[11]);
+
+            if(scheme.equalsIgnoreCase("https")) {
+                if(null != env[12]) {
+                           attributes.put("javax.servlet.request.X509Certificate",
+                                      env[12]);
+                   }
+
+                if(null != env[13]) {
+                           attributes.put("javax.servlet.request.cipher_suite",
+                                      env[13]);
+                   }
+
+                if(null != env[14]) {
+                           attributes.put("javax.servlet.request.ssl_session",
+                                      env[14]);
+                   }
+            }
+
+
+        } else {
+            throw new IOException("Error: JNI implementation error");
+        }
+
+        /*
+         * Read the headers
+         */
+        int nheaders = h.getNumberOfHeaders(s, l);
+        if(nheaders > 0) {
+            String []names = new String[nheaders];
+            String []values = new String[nheaders];
+            if(h.readHeaders(s, l, names, values) > 0) {
+                for(i = 0 ; i < nheaders ; i++) {
+                    headers.putHeader(names[i].toLowerCase(), values[i]);
+                }
+            } else {
+                throw new IOException("Error: JNI implementation error");
+            }
+        }
+
+           // REQUEST_URI may include a query string
+           int idQ= requestURI.indexOf("?");
+           if ( idQ > -1) {
+           requestURI = requestURI.substring(0, idQ);
+        }
+
+           contentLength = headers.getIntHeader("content-length");
+           contentType = headers.getHeader("content-type");
+    }
+
+    public ServletInputStream getInputStream() throws IOException {
+        if(contentLength <= 0) {
+            throw new IOException("Empty input stream");
+        }
+
+        in = new BufferedServletInputStream(this);
+       return in;
+    }
+}
+
+
+// Ajp use Status: instead of Status
+class JNIResponseAdapter extends ResponseImpl {
+
+    JNIConnectionHandler h;
+    long s;
+    long l;
+
+    public JNIResponseAdapter(JNIConnectionHandler h) {
+       this.h = h;
+    }
+
+    protected void setRequestAttr(long s, long l) throws IOException {
+       this.s = s;
+       this.l = l;
+    }
+
+    public void endHeaders() throws IOException {
+
+       if(request.getProtocol()==null) // HTTP/0.9
+               return;
+
+        super.endHeaders();
+
+       // Servlet Engine header will be set per/adapter - smarter adapters will
+       // not send it every time ( have it in C side ), and we may also want
+       // to add informations about the adapter used
+       if( request.getContext() != null)
+           setHeader("Servlet-Engine", request.getContext().getEngineHeader());
+
+        int    hcnt = 0;
+        String []headerNames = null;
+        String []headerValues = null;
+        headers.removeHeader("Status");
+        hcnt = headers.size();
+        headerNames = new String[hcnt];
+        headerValues = new String[hcnt];
+
+        for(int i = 0; i < hcnt; i++) {
+            MimeHeaderField h = headers.getField(i);
+            headerNames[i] = h.getName();
+            headerValues[i] = h.getValue();
+        }
+
+        if(h.startReasponse(s, l, status, getMessage(status), headerNames, 
+headerValues, hcnt) <= 0) {
+            throw new IOException("Error: JNI startReasponse implementation error");
+        }
+    }
+
+    public void doWrite(byte buf[], int pos, int count) throws IOException {
+        if(h.write(s, l, buf, pos, count) <= 0) {
+            throw new IOException("Error: JNI implementation error");
+        }
+    }
+}
 
--- E:\work\JNIConnector\sources\org\apache\tomcat\service\JNIEndpointConnector.java   
 Tue Jul  3 13:48:04 2001
+++ 
+E:\work\jakarta-tomcat-3.2.2-src\src\share\org\apache\tomcat\service\JNIEndpointConnector.java
+      Thu Jun 22 14:41:02 2000
@@ -84,7 +84,7 @@
     // XXX replace static strings with constants
 
     static JNIEndpoint ep;
-    protected JNIConnectionHandler con = new JNIConnectionHandler();
+    JNIConnectionHandler con = new JNIConnectionHandler();
 
     Object cm;
     String handlerNativeLib;
@@ -134,7 +134,6 @@
     }
 
     private LogHelper loghelper = new LogHelper("tc_log", "JNIEndpointConnector");
-    public LogHelper getLogger() {return loghelper;}
 
     /**
      * Set a logger explicitly.

Reply via email to