[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpcomponents-commits
Subject:    svn commit: r234116 - in /jakarta/httpclient/trunk/coyote-httpconnector/src:
From:       olegk () apache ! org
Date:       2005-08-20 19:27:46
Message-ID: 20050820192748.67874.qmail () minotaur ! apache ! org
[Download RAW message or body]

Author: olegk
Date: Sat Aug 20 12:27:30 2005
New Revision: 234116

URL: http://svn.apache.org/viewcvs?rev=234116&view=rev
Log:
HTTP connector changed to support two modes of operation: NIO and OldIO

Added:
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListenerFactory.java \
(with props)  jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataReceiverFactory.java \
(with props)  jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataTransmitterFactory.java \
(with props)  jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultConnectionListenerFactory.java \
(with props)  jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/NIOConnectionListener.java
                
      - copied, changed from r233344, \
jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListener.java
  jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/OldIOConnectionListener.java \
(with props) Removed:
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListener.java
 Modified:
    jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpConnectionFactory.java
  jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java
  jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpConnection.java
  jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultHttpConnectionFactory.java
  jakarta/httpclient/trunk/coyote-httpconnector/src/tests/server.xml

Added: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListenerFactory.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListenerFactory.java?rev=234116&view=auto
 ==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListenerFactory.java \
                (added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListenerFactory.java \
Sat Aug 20 12:27:30 2005 @@ -0,0 +1,48 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.coyote;
+
+import java.io.IOException;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
+public interface ConnectionListenerFactory {
+
+	IOProcessor newConnectionListener(
+			int port,
+			HttpConnectionFactory connfactory,
+			HttpConnectionManager connmanager) throws IOException;
+    
+}

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListenerFactory.java
                
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListenerFactory.java
                
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListenerFactory.java
                
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpConnectionFactory.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/j \
ava/org/apache/http/coyote/HttpConnectionFactory.java?rev=234116&r1=234115&r2=234116&view=diff
 ==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpConnectionFactory.java \
                (original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpConnectionFactory.java \
Sat Aug 20 12:27:30 2005 @@ -33,7 +33,6 @@
 import java.net.Socket;
 
 import org.apache.http.HttpServerConnection;
-import org.apache.http.params.HttpParams;
 
 /**
  * <p>
@@ -44,7 +43,6 @@
  */
 public interface HttpConnectionFactory {
 
-    HttpServerConnection newConnection(Socket socket, HttpParams params)
-        throws IOException;
+    HttpServerConnection newConnection(Socket socket) throws IOException;
     
 }

Modified: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/j \
ava/org/apache/http/coyote/HttpProtocolHandler.java?rev=234116&r1=234115&r2=234116&view=diff
 ==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java \
                (original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java \
Sat Aug 20 12:27:30 2005 @@ -39,6 +39,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.coyote.Adapter;
 import org.apache.coyote.ProtocolHandler;
+import org.apache.http.coyote.impl.DefaultConnectionListenerFactory;
 import org.apache.http.coyote.impl.DefaultHttpConnectionFactory;
 import org.apache.http.coyote.impl.DefaultHttpConnectionManager;
 import org.apache.http.coyote.impl.DefaultThreadFactory;
@@ -67,8 +68,9 @@
 	private Adapter adapter = null;
 	private int minThreads = 25;
 	private int maxThreads = 150;
+	private boolean useNIO;
     
-	private ConnectionListener listener = null;
+	private IOProcessor listener = null;
 	private ExecutorService listenerExecutor = null;
 	private ThreadGroup listenertg = null;
     private HttpConnectionManager connmanager = null;
@@ -140,8 +142,32 @@
     public void setTcpNoDelay(boolean b) {
         HttpConnectionParams.setTcpNoDelay(this.params, b);
     }
+
+	public String getMode() {
+		if (this.useNIO) {
+			return "NIO";
+		} else {
+			return "OldIO";
+		}
+	}
+
+	public void setMode(final String mode) {
+		if ("NIO".equalsIgnoreCase(mode)) {
+			this.useNIO = true;
+		} else if ("OldIO".equalsIgnoreCase(mode)) {
+			this.useNIO = false;
+		} else {
+			if (LOG.isWarnEnabled()) {
+				LOG.warn("Illegal mode: " + mode);
+			}
+		}
+	}
     
 	public void init() throws Exception {
+		if (this.useNIO) {
+            this.params.setParameter(HttpConnectionParams.SO_TIMEOUT, null);
+		}
+		
 		this.conntg = new ThreadGroup("Connection thread group");
 		
         this.requestExecutor = new ThreadPoolExecutor(
@@ -163,10 +189,16 @@
                 new LinkedBlockingQueue<Runnable>(),
                 new DefaultThreadFactory(this.listenertg, "HttpListener-" + \
getPort()));  
-        this.listener = new ConnectionListener(
-                new DefaultHttpConnectionFactory(), 
-                this.connmanager,
-                this.params);
+        ConnectionListenerFactory listenerfactory = new \
DefaultConnectionListenerFactory( +        		this.useNIO);
+        
+        HttpConnectionFactory connfactory = new DefaultHttpConnectionFactory(
+        		this.params);
+        
+        this.listener = listenerfactory.newConnectionListener(
+        		CoyoteParams.getPort(this.params),
+        		connfactory, 
+                this.connmanager);
 	}
 
     public void destroy() throws Exception {

Modified: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpConnection.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/j \
ava/org/apache/http/coyote/impl/CoyoteHttpConnection.java?rev=234116&r1=234115&r2=234116&view=diff
 ==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpConnection.java \
                (original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpConnection.java \
Sat Aug 20 12:27:30 2005 @@ -54,6 +54,8 @@
     public CoyoteHttpConnection() {
         super();
         this.name = "No Connection"; 
+        setReceiverFactory(new CoyoteHttpDataReceiverFactory());
+        setTransmitterFactory(new CoyoteHttpDataTransmitterFactory());
     }
 
     @Override

Added: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataReceiverFactory.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/j \
ava/org/apache/http/coyote/impl/CoyoteHttpDataReceiverFactory.java?rev=234116&view=auto
 ==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataReceiverFactory.java \
                (added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataReceiverFactory.java \
Sat Aug 20 12:27:30 2005 @@ -0,0 +1,61 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.coyote.impl;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import org.apache.http.impl.io.NIOSocketHttpDataReceiver;
+import org.apache.http.impl.io.OldIOSocketHttpDataReceiver;
+import org.apache.http.io.HttpDataReceiver;
+import org.apache.http.io.HttpDataReceiverFactory;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
+public class CoyoteHttpDataReceiverFactory implements HttpDataReceiverFactory {
+
+	public HttpDataReceiver create(final Socket socket) throws IOException {
+		if (socket == null) {
+			throw new IllegalArgumentException("Socket may not be null");
+		}
+		if (socket.getChannel() != null) {
+			return new NIOSocketHttpDataReceiver(socket);
+		} else {
+			return new OldIOSocketHttpDataReceiver(socket);
+		}
+	}
+
+    
+}

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataReceiverFactory.java
                
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataReceiverFactory.java
                
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataReceiverFactory.java
                
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataTransmitterFactory.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/j \
ava/org/apache/http/coyote/impl/CoyoteHttpDataTransmitterFactory.java?rev=234116&view=auto
 ==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataTransmitterFactory.java \
                (added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataTransmitterFactory.java \
Sat Aug 20 12:27:30 2005 @@ -0,0 +1,60 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.coyote.impl;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import org.apache.http.impl.io.NIOSocketHttpDataTransmitter;
+import org.apache.http.impl.io.OldIOSocketHttpDataTransmitter;
+import org.apache.http.io.HttpDataTransmitter;
+import org.apache.http.io.HttpDataTransmitterFactory;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
+public class CoyoteHttpDataTransmitterFactory implements HttpDataTransmitterFactory \
{ +
+	public HttpDataTransmitter create(final Socket socket) throws IOException {
+		if (socket == null) {
+			throw new IllegalArgumentException("Socket may not be null");
+		}
+		if (socket.getChannel() != null) {
+			return new NIOSocketHttpDataTransmitter(socket);
+		} else {
+			return new OldIOSocketHttpDataTransmitter(socket);
+		}
+	}
+
+}

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataTransmitterFactory.java
                
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataTransmitterFactory.java
                
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/CoyoteHttpDataTransmitterFactory.java
                
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultConnectionListenerFactory.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/j \
ava/org/apache/http/coyote/impl/DefaultConnectionListenerFactory.java?rev=234116&view=auto
 ==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultConnectionListenerFactory.java \
                (added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultConnectionListenerFactory.java \
Sat Aug 20 12:27:30 2005 @@ -0,0 +1,66 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.coyote.impl;
+
+import java.io.IOException;
+
+import org.apache.http.coyote.ConnectionListenerFactory;
+import org.apache.http.coyote.HttpConnectionFactory;
+import org.apache.http.coyote.HttpConnectionManager;
+import org.apache.http.coyote.IOProcessor;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
+public class DefaultConnectionListenerFactory implements ConnectionListenerFactory {
+
+	final boolean useNIO;
+	
+    public DefaultConnectionListenerFactory(boolean useNIO) {
+        super();
+        this.useNIO = useNIO;
+    }
+    
+    public IOProcessor newConnectionListener(
+			int port,
+			HttpConnectionFactory connfactory,
+			HttpConnectionManager connmanager) throws IOException {
+    	if (this.useNIO) {
+    		return new NIOConnectionListener(port, connfactory, connmanager);
+    	} else {
+    		return new OldIOConnectionListener(port, connfactory, connmanager);
+    	}
+    }
+    
+}

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultConnectionListenerFactory.java
                
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultConnectionListenerFactory.java
                
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultConnectionListenerFactory.java
                
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultHttpConnectionFactory.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/j \
ava/org/apache/http/coyote/impl/DefaultHttpConnectionFactory.java?rev=234116&r1=234115&r2=234116&view=diff
 ==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultHttpConnectionFactory.java \
                (original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/DefaultHttpConnectionFactory.java \
Sat Aug 20 12:27:30 2005 @@ -45,11 +45,17 @@
  */
 public class DefaultHttpConnectionFactory implements HttpConnectionFactory {
 
-    public DefaultHttpConnectionFactory() {
+	final HttpParams params;
+	
+    public DefaultHttpConnectionFactory(final HttpParams params) {
         super();
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        this.params = params;
     }
     
-    public HttpServerConnection newConnection(final Socket socket, final HttpParams \
params) +    public HttpServerConnection newConnection(final Socket socket)
             throws IOException {
         HttpServerConnection conn = new CoyoteHttpConnection();
         conn.bind(socket, params);

Copied: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/NIOConnectionListener.java \
(from r233344, jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListener.java)
                
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/j \
ava/org/apache/http/coyote/impl/NIOConnectionListener.java?p2=jakarta/httpclient/trunk \
/coyote-httpconnector/src/java/org/apache/http/coyote/impl/NIOConnectionListener.java& \
p1=jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListener.java&r1=233344&r2=234116&rev=234116&view=diff
 ==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/ConnectionListener.java \
                (original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/NIOConnectionListener.java \
Sat Aug 20 12:27:30 2005 @@ -27,7 +27,7 @@
  *
  */
 
-package org.apache.http.coyote;
+package org.apache.http.coyote.impl;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
@@ -38,8 +38,9 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.HttpServerConnection;
-import org.apache.http.coyote.params.CoyoteParams;
-import org.apache.http.params.HttpParams;
+import org.apache.http.coyote.HttpConnectionFactory;
+import org.apache.http.coyote.HttpConnectionManager;
+import org.apache.http.coyote.IOProcessor;
 
 /**
  * <p>
@@ -48,21 +49,20 @@
  *
  * @version $Revision$
  */
-public class ConnectionListener implements IOProcessor {
+public class NIOConnectionListener implements IOProcessor {
 
-    private static Log LOG = LogFactory.getLog(ConnectionListener.class);
+    private static Log LOG = LogFactory.getLog(NIOConnectionListener.class);
 	
     private volatile boolean destroyed = false;
     
     private final HttpConnectionFactory connfactory;
     private final HttpConnectionManager connmanager;
-    private final HttpParams params;
     private final ServerSocketChannel serverchannel;
         
-    public ConnectionListener(
+    public NIOConnectionListener(
+    		int port,
             final HttpConnectionFactory connfactory,
-            final HttpConnectionManager connmanager,
-            final HttpParams params) throws IOException {
+            final HttpConnectionManager connmanager) throws IOException {
     	super();
         if (connfactory == null) {
             throw new IllegalArgumentException("Connection factory may not be \
null"); @@ -70,15 +70,9 @@
         if (connmanager == null) {
             throw new IllegalArgumentException("Connection manager may not be \
null");  }
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
         this.connmanager = connmanager;
         this.connfactory = connfactory;
-        this.params = params;
         this.serverchannel = ServerSocketChannel.open();
-        
-        int port = CoyoteParams.getPort(this.params);
         this.serverchannel.socket().bind(new InetSocketAddress(port));
     }
 
@@ -96,8 +90,7 @@
                         LOG.debug("Incoming HTTP connection from " + 
                         		socket.getRemoteSocketAddress());
                     }
-                    HttpServerConnection conn = this.connfactory.newConnection(
-                            socket, this.params);
+                    HttpServerConnection conn = \
this.connfactory.newConnection(socket);  this.connmanager.process(conn);
                 } catch (IOException ex) {
                 	if (LOG.isInfoEnabled()) {

Added: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/OldIOConnectionListener.java
                
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/j \
ava/org/apache/http/coyote/impl/OldIOConnectionListener.java?rev=234116&view=auto \
                ==============================================================================
                
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/OldIOConnectionListener.java \
                (added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/OldIOConnectionListener.java \
Sat Aug 20 12:27:30 2005 @@ -0,0 +1,126 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.coyote.impl;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpServerConnection;
+import org.apache.http.coyote.HttpConnectionFactory;
+import org.apache.http.coyote.HttpConnectionManager;
+import org.apache.http.coyote.IOProcessor;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
+public class OldIOConnectionListener implements IOProcessor {
+
+    private static Log LOG = LogFactory.getLog(OldIOConnectionListener.class);
+	
+    private volatile boolean destroyed = false;
+    
+    private final HttpConnectionFactory connfactory;
+    private final HttpConnectionManager connmanager;
+    private final ServerSocket serversocket;
+        
+    public OldIOConnectionListener(
+    		int port,
+            final HttpConnectionFactory connfactory,
+            final HttpConnectionManager connmanager) throws IOException {
+    	super();
+        if (connfactory == null) {
+            throw new IllegalArgumentException("Connection factory may not be \
null"); +        }
+        if (connmanager == null) {
+            throw new IllegalArgumentException("Connection manager may not be \
null"); +        }
+        this.connmanager = connmanager;
+        this.connfactory = connfactory;
+        this.serversocket = new ServerSocket(port);
+    }
+
+    public void run() {
+    	if (LOG.isInfoEnabled()) {
+            LOG.info("Listening on port " + this.serversocket.getLocalPort());
+    	}
+        try {
+            while (!this.serversocket.isClosed() && !Thread.interrupted()) {
+                try {
+                    LOG.debug("Waiting for incoming HTTP connection");
+                    Socket socket = this.serversocket.accept();
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Incoming HTTP connection from " + 
+                        		socket.getRemoteSocketAddress());
+                    }
+                    HttpServerConnection conn = \
this.connfactory.newConnection(socket); +                    \
this.connmanager.process(conn); +                } catch (IOException ex) {
+                	if (LOG.isInfoEnabled()) {
+                        LOG.info("Connection listener terminated due to an I/O \
error: " +  +                        		ex.getMessage());
+                	}
+                    break;
+                } catch (Throwable ex) {
+                    LOG.error("Connection listener terminated due to a runtime \
error", ex); +                    break;
+                }
+            }
+        } finally {
+            destroy();
+        }
+    }
+    
+	public void close() throws IOException {
+        this.serversocket.close();
+	}
+    
+    public void destroy() {
+        this.destroyed = true;
+        try {
+            close();
+        } catch (IOException ex) {
+            if (LOG.isWarnEnabled()) {
+                LOG.warn("I/O error closing listener", ex);
+            }
+        }
+    }
+
+    public boolean isDestroyed() {
+        return this.destroyed;
+    }
+    
+}

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/OldIOConnectionListener.java
                
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/OldIOConnectionListener.java
                
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/impl/OldIOConnectionListener.java
                
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpclient/trunk/coyote-httpconnector/src/tests/server.xml
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/tests/server.xml?rev=234116&r1=234115&r2=234116&view=diff
 ==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/tests/server.xml (original)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/tests/server.xml Sat Aug 20 \
12:27:30 2005 @@ -27,7 +27,7 @@
     <Connector port="8888" protocol="org.apache.http.coyote.HttpProtocolHandler"
    	           receiveBuffer="8192" sendBuffer="8192"
                minThreads="25" maxThreads="150" 
-               socketTimeout="20000" tcpNoDelay="true" />
+               mode="OldIO" socketTimeout="20000" tcpNoDelay="true" />
 
     <Engine name="Catalina" defaultHost="localhost">
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic