You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2005/07/31 21:00:27 UTC
svn commit: r226679 - in
/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote:
HttpProtocolHandler.java NotImplementedException.java
Author: olegk
Date: Sun Jul 31 12:00:20 2005
New Revision: 226679
URL: http://svn.apache.org/viewcvs?rev=226679&view=rev
Log:
Made some of the connector's settings configurable
Added:
jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/NotImplementedException.java (with props)
Modified:
jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/HttpProtocolHandler.java
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/java/org/apache/http/coyote/HttpProtocolHandler.java?rev=226679&r1=226678&r2=226679&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 Sun Jul 31 12:00:20 2005
@@ -31,7 +31,8 @@
import java.util.Iterator;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
@@ -39,6 +40,7 @@
import org.apache.coyote.Adapter;
import org.apache.coyote.ProtocolHandler;
import org.apache.http.impl.DefaultHttpParams;
+import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
/**
@@ -52,7 +54,14 @@
private static Log LOG = LogFactory.getLog(HttpProtocolHandler.class);
+ private static final int SHUTDOWN_GRACE_PERIOD = 5000; // ms
+
private final HttpParams params;
+
+ private Adapter adapter = null;
+ private int port = 8080;
+ private int minThreads = 0;
+ private int maxThreads = 20;
private ConnectionListener listener = null;
private ExecutorService listenerExecutor = null;
@@ -62,20 +71,57 @@
public HttpProtocolHandler() {
super();
this.params = new DefaultHttpParams();
+ HttpConnectionParams.setSoTimeout(this.params, 5000);
+ }
+
+ public int getPort() {
+ return this.port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public int getMinThreads() {
+ return this.minThreads;
+ }
+
+ public void setMinThreads(int minThreads) {
+ this.minThreads = minThreads;
+ }
+
+ public int getMaxThreads() {
+ return this.maxThreads;
+ }
+
+ public void setMaxThreads(int maxThreads) {
+ this.maxThreads = maxThreads;
}
+ public int getSocketTimeout() {
+ return HttpConnectionParams.getSoTimeout(this.params);
+ }
+
+ public void setSocketTimeout(int timeout) {
+ HttpConnectionParams.setSoTimeout(this.params, timeout);
+ }
+
public void init() throws Exception {
- this.requestExecutor = Executors.newFixedThreadPool(20);
+ this.requestExecutor = new ThreadPoolExecutor(this.minThreads, this.maxThreads,
+ 0L, TimeUnit.MILLISECONDS,
+ new LinkedBlockingQueue<Runnable>());
this.connmanager = new DefaultHttpConnectionManager(this.params, this.requestExecutor);
- this.listenerExecutor = Executors.newSingleThreadExecutor();
- this.listener = new ConnectionListener(8080, this.connmanager);
+ this.listenerExecutor = new ThreadPoolExecutor(1, 1,
+ 0L, TimeUnit.MILLISECONDS,
+ new LinkedBlockingQueue<Runnable>());
+ this.listener = new ConnectionListener(this.port, this.connmanager);
}
public void destroy() throws Exception {
// Attempt to terminate the listener nicely
LOG.info("Shut down the listener");
this.listenerExecutor.shutdownNow();
- this.listenerExecutor.awaitTermination(5000, TimeUnit.MILLISECONDS);
+ this.listenerExecutor.awaitTermination(SHUTDOWN_GRACE_PERIOD, TimeUnit.MILLISECONDS);
if (!this.listenerExecutor.isTerminated()) {
// Terminate the listener forcibly
LOG.info("Force shut down the listener");
@@ -86,7 +132,7 @@
// Attempt to terminate the active processors nicely
LOG.info("Shut down HTTP processors");
this.requestExecutor.shutdownNow();
- this.requestExecutor.awaitTermination(5000, TimeUnit.MILLISECONDS);
+ this.requestExecutor.awaitTermination(SHUTDOWN_GRACE_PERIOD, TimeUnit.MILLISECONDS);
if (!this.requestExecutor.isTerminated()) {
// Terminate the active processors forcibly
LOG.info("Force shut down HTTP processors");
@@ -102,29 +148,36 @@
}
public void pause() throws Exception {
- // Not implemented. What is it for, anyway?
+ // Does not seem to used by Tomcat 5.5
+ throw new NotImplementedException("Method not implemented");
}
public void resume() throws Exception {
- // Not implemented. What is it for, anyway?
+ // Does not seem to used by Tomcat 5.5
+ throw new NotImplementedException("Method not implemented");
}
public Adapter getAdapter() {
- return null;
+ return this.adapter;
}
- public Object getAttribute(String name) {
- return null;
+ public void setAdapter(final Adapter adapter) {
+ this.adapter = adapter;
}
- public Iterator getAttributeNames() {
- return null;
+ public Object getAttribute(String name) {
+ // Does not seem to used by Tomcat 5.5
+ throw new NotImplementedException("Method not implemented");
}
- public void setAdapter(Adapter adapter) {
+ public Iterator getAttributeNames() {
+ // Does not seem to used by Tomcat 5.5
+ throw new NotImplementedException("Method not implemented");
}
public void setAttribute(String name, Object value) {
+ // Does not seem to used by Tomcat 5.5
+ throw new NotImplementedException("Method not implemented");
}
}
Added: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/NotImplementedException.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/NotImplementedException.java?rev=226679&view=auto
==============================================================================
--- jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/NotImplementedException.java (added)
+++ jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/NotImplementedException.java Sun Jul 31 12:00:20 2005
@@ -0,0 +1,59 @@
+/*
+ * $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;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
+public class NotImplementedException extends RuntimeException {
+
+ static final long serialVersionUID = -8555154653813633804L;
+
+ /**
+ * Creates a NotImplementedException with a <tt>null</tt> detail message.
+ */
+ public NotImplementedException() {
+ super();
+ }
+
+ /**
+ * Creates a NotImplementedException with the specified detail message.
+ *
+ * @param message The exception detail message
+ */
+ public NotImplementedException(final String message) {
+ super(message);
+ }
+
+}
Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/NotImplementedException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/NotImplementedException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpclient/trunk/coyote-httpconnector/src/java/org/apache/http/coyote/NotImplementedException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain