Hi Remy, Do you think coyote could be ever used with Tomcat 3.3 ? ie: works with JDK 1.1, support TC 3.3 via modules....
JK/JK2 are available for both TC 3.3/4.x, it could be fine to have also a common HTTP connector for them and coyote seems to be the perfect candidate :) - Henri Gomez ___[_]____ EMAIL : [EMAIL PROTECTED] (. .) PGP KEY : 697ECEDD ...oOOo..(_)..oOOo... PGP Fingerprint : 9DF8 1EA8 ED53 2F39 DC9B 904A 364F 80E6 >-----Original Message----- >From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] >Sent: Wednesday, February 27, 2002 9:24 AM >To: [EMAIL PROTECTED] >Subject: cvs commit: >jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4 >CoyoteConnector.java CoyoteProcessor.java > > >remm 02/02/27 00:24:08 > > Modified: coyote/src/java/org/apache/coyote/tomcat4 > CoyoteConnector.java CoyoteProcessor.java > Log: > - Code cleanup: remove old debug code for the thread pool, >use exclusively > internationalized strings. > > Revision Changes Path > 1.2 +62 -97 >jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tom >cat4/CoyoteConnector.java > > Index: CoyoteConnector.java > =================================================================== > RCS file: >/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/ >coyote/tomcat4/CoyoteConnector.java,v > retrieving revision 1.1 > retrieving revision 1.2 > diff -u -r1.1 -r1.2 > --- CoyoteConnector.java 17 Jan 2002 21:08:44 -0000 1.1 > +++ CoyoteConnector.java 27 Feb 2002 08:24:08 -0000 1.2 > @@ -1,7 +1,7 @@ > /* > - * $Header: >/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/ >coyote/tomcat4/CoyoteConnector.java,v 1.1 2002/01/17 21:08:44 >remm Exp $ > - * $Revision: 1.1 $ > - * $Date: 2002/01/17 21:08:44 $ > + * $Header: >/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/ >coyote/tomcat4/CoyoteConnector.java,v 1.2 2002/02/27 08:24:08 >remm Exp $ > + * $Revision: 1.2 $ > + * $Date: 2002/02/27 08:24:08 $ > * > * >==================================================================== > * > @@ -103,7 +103,7 @@ > * > * @author Craig R. McClanahan > * @author Remy Maucherat > - * @version $Revision: 1.1 $ $Date: 2002/01/17 21:08:44 $ > + * @version $Revision: 1.2 $ $Date: 2002/02/27 08:24:08 $ > */ > > > @@ -326,12 +326,6 @@ > "org.apache.coyote.http11.Http11Processor"; > > > - /** > - * Coyote Processor class. > - */ > - private Class processorClass = null; > - > - > // >------------------------------------------------------------- >Properties > > > @@ -839,11 +833,9 @@ > */ > public Request createRequest() { > > - // if (debug >= 2) > - // log("createRequest: Creating new request"); > CoyoteRequest request = new CoyoteRequest(); > request.setConnector(this); > - return null;//(request); > + return (request); > > } > > @@ -854,11 +846,9 @@ > */ > public Response createResponse() { > > - // if (debug >= 2) > - // log("createResponse: Creating new response"); > CoyoteResponse response = new CoyoteResponse(); > response.setConnector(this); > - return null;//(response); > + return (response); > > } > > @@ -873,8 +863,6 @@ > */ > void recycle(CoyoteProcessor processor) { > > - // if (debug >= 2) > - // log("recycle: Recycling processor " + >processor); > processors.push(processor); > > } > @@ -893,22 +881,14 @@ > > synchronized (processors) { > if (processors.size() > 0) { > - // if (debug >= 2) > - // log("createProcessor: Reusing existing >processor"); > return ((CoyoteProcessor) processors.pop()); > } > if ((maxProcessors > 0) && (curProcessors < >maxProcessors)) { > - // if (debug >= 2) > - // log("createProcessor: Creating new processor"); > return (newProcessor()); > } else { > if (maxProcessors < 0) { > - // if (debug >= 2) > - // log("createProcessor: Creating new >processor"); > return (newProcessor()); > } else { > - // if (debug >= 2) > - // log("createProcessor: Cannot create >new processor"); > return (null); > } > } > @@ -964,14 +944,12 @@ > */ > private CoyoteProcessor newProcessor() { > > - // if (debug >= 2) > - // log("newProcessor: Creating new processor"); > CoyoteProcessor processor = new >CoyoteProcessor(this, curProcessors++); > if (processor instanceof Lifecycle) { > try { > ((Lifecycle) processor).start(); > } catch (LifecycleException e) { > - log("newProcessor", e); > + >log(sm.getString("coyoteConnector.newProcessor"), e); > return (null); > } > } > @@ -991,14 +969,15 @@ > * KeyStore from >file (SSL only) > * @exception NoSuchAlgorithmException KeyStore >algorithm unsupported > * by current >provider (SSL only) > - * @exception CertificateException general >certificate error (SSL only) > + * @exception CertificateException general >certificate error > + * (SSL only) > * @exception UnrecoverableKeyException internal >KeyStore problem with > * the >certificate (SSL only) > * @exception KeyManagementException problem in the >key management > * layer (SSL only) > */ > private ServerSocket open() > - throws IOException, KeyStoreException, NoSuchAlgorithmException, > + throws IOException, KeyStoreException, >NoSuchAlgorithmException, > CertificateException, UnrecoverableKeyException, > KeyManagementException { > > @@ -1024,6 +1003,41 @@ > } > > > + /** > + * Open server socket. > + */ > + private Exception openServerSocket() { > + > + Exception result = null; > + > + // Establish a server socket on the specified port > + try { > + serverSocket = open(); > + } catch (IOException e) { > + log(sm.getString("coyoteConnector.IOProblem"), e); > + result = e; > + } catch (KeyStoreException e) { > + log(sm.getString("coyoteConnector.keystoreProblem"), e); > + result = e; > + } catch (NoSuchAlgorithmException e) { > + >log(sm.getString("coyoteConnector.keystoreAlgorithmProblem"), e); > + result = e; > + } catch (CertificateException e) { > + >log(sm.getString("coyoteConnector.certificateProblem"), e); > + result = e; > + } catch (UnrecoverableKeyException e) { > + >log(sm.getString("coyoteConnector.unrecoverableKey"), e); > + result = e; > + } catch (KeyManagementException e) { > + >log(sm.getString("coyoteConnector.keyManagementProblem"), e); > + result = e; > + } > + > + return result; > + > + } > + > + > // ---------------------------------------------- >Background Thread Methods > > > @@ -1039,56 +1053,29 @@ > // Accept the next incoming connection from the >server socket > Socket socket = null; > try { > - // if (debug >= 3) > - // log("run: Waiting on >serverSocket.accept()"); > socket = serverSocket.accept(); > - // if (debug >= 3) > - // log("run: Returned >from serverSocket.accept()"); > if (connectionTimeout > 0) > socket.setSoTimeout(connectionTimeout); > socket.setTcpNoDelay(tcpNoDelay); > - } catch (AccessControlException ace) { > - log("socket accept security exception", ace); > + } catch (AccessControlException e) { > + >log(sm.getString("coyoteConnector.securityException"), e); > continue; > } catch (IOException e) { > - // if (debug >= 3) > - // log("run: Accept >returned IOException", e); > try { > // If reopening fails, exit > synchronized (threadSync) { > if (started && !stopped) > log("accept: ", e); > if (!stopped) { > - // if (debug >= 3) > - // >log("run: Closing server socket"); > serverSocket.close(); > - // if >(debug >= 3) > - // >log("run: Reopening server socket"); > - serverSocket = open(); > + openServerSocket(); > } > } > - // if (debug >= 3) > - // log("run: >IOException processing completed"); > } catch (IOException ioe) { > - log("socket reopen, io problem: ", ioe); > - break; > - } catch (KeyStoreException kse) { > - log("socket reopen, keystore problem: ", kse); > - break; > - } catch (NoSuchAlgorithmException nsae) { > - log("socket reopen, keystore algorithm >problem: ", nsae); > - break; > - } catch (CertificateException ce) { > - log("socket reopen, certificate problem: ", ce); > - break; > - } catch (UnrecoverableKeyException uke) { > - log("socket reopen, unrecoverable key: ", uke); > - break; > - } catch (KeyManagementException kme) { > - log("socket reopen, key management >problem: ", kme); > + >log(sm.getString("coyoteConnector.serverSocketReopenFail"), > + ioe); > break; > } > - > continue; > } > > @@ -1103,8 +1090,6 @@ > } > continue; > } > - // if (debug >= 3) > - // log("run: Assigning socket to >processor " + processor); > processor.assign(socket); > > // The processor will recycle itself when it finishes > @@ -1112,8 +1097,6 @@ > } > > // Notify the threadStop() method that we have shut >ourselves down > - // if (debug >= 3) > - // log("run: Notifying threadStop() that >we have shut down"); > synchronized (threadSync) { > threadSync.notifyAll(); > } > @@ -1195,39 +1178,21 @@ > * Initialize this connector (create ServerSocket here!) > */ > public void initialize() > - throws LifecycleException { > + throws LifecycleException { > + > if (initialized) > - throw new LifecycleException ( > - sm.getString("coyoteConnector.alreadyInitialized")); > + throw new LifecycleException > + >(sm.getString("coyoteConnector.alreadyInitialized")); > > - this.initialized=true; > - Exception eRethrow = null; > + this.initialized = true; > > - // Establish a server socket on the specified port > - try { > - serverSocket = open(); > - } catch (IOException ioe) { > - log("coyoteConnector, io problem: ", ioe); > - eRethrow = ioe; > - } catch (KeyStoreException kse) { > - log("coyoteConnector, keystore problem: ", kse); > - eRethrow = kse; > - } catch (NoSuchAlgorithmException nsae) { > - log("coyoteConnector, keystore algorithm >problem: ", nsae); > - eRethrow = nsae; > - } catch (CertificateException ce) { > - log("coyoteConnector, certificate problem: ", ce); > - eRethrow = ce; > - } catch (UnrecoverableKeyException uke) { > - log("coyoteConnector, unrecoverable key: ", uke); > - eRethrow = uke; > - } catch (KeyManagementException kme) { > - log("coyoteConnector, key management problem: ", kme); > - eRethrow = kme; > - } > + Exception eRethrow = openServerSocket(); > > - if ( eRethrow != null ) > - throw new LifecycleException(threadName + >".open", eRethrow); > + if (eRethrow != null) { > + throw new LifecycleException > + >(sm.getString("coyoteConnector.initException", threadName), > + eRethrow); > + } > > } > > @@ -1282,7 +1247,7 @@ > try { > ((Lifecycle) processor).stop(); > } catch (LifecycleException e) { > - log("coyoteConnector.stop", e); > + >log(sm.getString("coyoteConnector.stopException"), e); > } > } > } > > > > 1.4 +67 -51 >jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tom >cat4/CoyoteProcessor.java > > Index: CoyoteProcessor.java > =================================================================== > RCS file: >/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/ >coyote/tomcat4/CoyoteProcessor.java,v > retrieving revision 1.3 > retrieving revision 1.4 > diff -u -r1.3 -r1.4 > --- CoyoteProcessor.java 1 Feb 2002 17:13:48 -0000 1.3 > +++ CoyoteProcessor.java 27 Feb 2002 08:24:08 -0000 1.4 > @@ -1,6 +1,6 @@ > -/* * $Header: >/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/ >coyote/tomcat4/CoyoteProcessor.java,v 1.3 2002/02/01 17:13:48 >remm Exp $ > - * $Revision: 1.3 $ > - * $Date: 2002/02/01 17:13:48 $ > +/* * $Header: >/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/ >coyote/tomcat4/CoyoteProcessor.java,v 1.4 2002/02/27 08:24:08 >remm Exp $ > + * $Revision: 1.4 $ > + * $Date: 2002/02/27 08:24:08 $ > * > * >==================================================================== > * > @@ -111,7 +111,7 @@ > * > * @author Craig R. McClanahan > * @author Remy Maucherat > - * @version $Revision: 1.3 $ $Date: 2002/02/01 17:13:48 $ > + * @version $Revision: 1.4 $ $Date: 2002/02/27 08:24:08 $ > */ > > final class CoyoteProcessor > @@ -282,6 +282,31 @@ > private int status = Constants.PROCESSOR_IDLE; > > > + // >-------------------------------------------------------- >Adapter Methods > + > + > + /** > + * Service method. > + */ > + public void service(Request req, Response res) > + throws Exception { > + > + // Wrapping the Coyote requests > + request.setCoyoteRequest(req); > + response.setCoyoteResponse(res); > + > + try { > + // Calling the container > + connector.getContainer().invoke(request, response); > + } finally { > + // Recycle the wrapper request and response > + request.recycle(); > + response.recycle(); > + } > + > + } > + > + > // >--------------------------------------------------------- >Public Methods > > > @@ -360,35 +385,6 @@ > > > /** > - * Log a message on the Logger associated with our >Container (if any) > - * > - * @param message Message to be logged > - */ > - private void log(String message) { > - > - Logger logger = connector.getContainer().getLogger(); > - if (logger != null) > - logger.log(threadName + " " + message); > - > - } > - > - > - /** > - * Log a message on the Logger associated with our >Container (if any) > - * > - * @param message Message to be logged > - * @param throwable Associated exception > - */ > - private void log(String message, Throwable throwable) { > - > - Logger logger = connector.getContainer().getLogger(); > - if (logger != null) > - logger.log(threadName + " " + message, throwable); > - > - } > - > - > - /** > * Process an incoming HTTP request on the Socket that >has been assigned > * to this Processor. Any exceptions that occur during >processing must be > * swallowed and dealt with. > @@ -400,6 +396,7 @@ > InputStream input = null; > OutputStream output = null; > > + // Process requests > try { > input = socket.getInputStream(); > output = socket.getOutputStream(); > @@ -408,15 +405,18 @@ > log(sm.getString("coyoteProcessor.process"), t); > } > > + // Consuming leftover bytes > try { > int available = input.available(); > // skip any unread (bogus) bytes > if (available > 0) { > input.skip(available); > } > - } catch (Exception e) { > + } catch (IOException e) { > ; > } > + > + // Closing the socket > try { > socket.close(); > } catch (IOException e) { > @@ -428,23 +428,30 @@ > > > /** > - * Service method. > + * Log a message on the Logger associated with our >Container (if any) > + * > + * @param message Message to be logged > */ > - public void service(Request req, Response res) > - throws Exception { > + private void log(String message) { > > - // Wrapping the Coyote requests > - request.setCoyoteRequest(req); > - response.setCoyoteResponse(res); > + Logger logger = connector.getContainer().getLogger(); > + if (logger != null) > + logger.log(threadName + " " + message); > + > + } > > - try { > - // Calling the container > - //connector.getContainer().invoke(request, response); > - } finally { > - // Recycle the wrapper request and response > - request.recycle(); > - response.recycle(); > - } > + > + /** > + * Log a message on the Logger associated with our >Container (if any) > + * > + * @param message Message to be logged > + * @param throwable Associated exception > + */ > + private void log(String message, Throwable throwable) { > + > + Logger logger = connector.getContainer().getLogger(); > + if (logger != null) > + logger.log(threadName + " " + message, throwable); > > } > > @@ -466,8 +473,16 @@ > if (socket == null) > continue; > > + status = Constants.PROCESSOR_ACTIVE; > + > // Process the request from this socket > - process(socket); > + try { > + process(socket); > + } catch (Throwable t) { > + log(sm.getString("coyoteProcessor.run"), t); > + } finally { > + status = Constants.PROCESSOR_IDLE; > + } > > // Finish up this request > connector.recycle(this); > @@ -577,10 +592,11 @@ > String className = connector.getProcessorClassName(); > try { > Class clazz = Class.forName(className); > - processor = (Processor) clazz.newInstance(); > + processor = (Processor) clazz.newInstance(); > } catch (Exception e) { > throw new LifecycleException > - >(sm.getString("coyoteProcessor.processorInstantiationFailed", e)); > + (sm.getString > + >("coyoteProcessor.processorInstantiationFailed", e)); > } > processor.setAdapter(this); > > > > > >-- >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
