Upgraded HttpCore to version 4.2-alpha2

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1174627 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2011-09-23 09:53:42 +00:00
parent eab98043c4
commit 9ee4a41aa3
4 changed files with 37 additions and 17 deletions

View File

@ -31,10 +31,10 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log;
import org.apache.http.HttpConnection;
import org.apache.http.conn.OperatedClientConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.pool.AbstractConnPool;
import org.apache.http.pool.ConnFactory;
/**
* @since 4.2
@ -50,33 +50,24 @@ class HttpConnPool extends AbstractConnPool<HttpRoute, OperatedClientConnection,
public HttpConnPool(final Log log,
final int defaultMaxPerRoute, final int maxTotal,
final long timeToLive, final TimeUnit tunit) {
super(defaultMaxPerRoute, maxTotal);
super(new InternalConnFactory(), defaultMaxPerRoute, maxTotal);
this.log = log;
this.timeToLive = timeToLive;
this.tunit = tunit;
}
@Override
protected OperatedClientConnection createConnection(final HttpRoute route) throws IOException {
return new DefaultClientConnection();
}
@Override
protected HttpPoolEntry createEntry(final HttpRoute route, final OperatedClientConnection conn) {
String id = Long.toString(COUNTER.getAndIncrement());
return new HttpPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
}
@Override
protected void closeEntry(final HttpPoolEntry entry) {
HttpConnection conn = entry.getConnection();
try {
conn.shutdown();
} catch (IOException ex) {
if (this.log.isDebugEnabled()) {
this.log.debug("I/O error shutting down connection", ex);
}
static class InternalConnFactory implements ConnFactory<HttpRoute, OperatedClientConnection> {
public OperatedClientConnection create(final HttpRoute route) throws IOException {
return new DefaultClientConnection();
}
}
}

View File

@ -26,6 +26,7 @@
*/
package org.apache.http.impl.conn;
import java.io.IOException;
import java.util.Date;
import java.util.concurrent.TimeUnit;
@ -75,4 +76,20 @@ class HttpPoolEntry extends PoolEntry<HttpRoute, OperatedClientConnection> {
return this.tracker.toRoute();
}
@Override
public boolean isClosed() {
OperatedClientConnection conn = getConnection();
return !conn.isOpen();
}
@Override
public void close() {
OperatedClientConnection conn = getConnection();
try {
conn.close();
} catch (IOException ex) {
this.log.debug("I/O error closing connection", ex);
}
}
}

View File

@ -310,14 +310,26 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
this.pool.closeExpired();
}
public int getMaxTotal() {
return this.pool.getMaxTotal();
}
public void setMaxTotal(int max) {
this.pool.setMaxTotal(max);
}
public int getDefaultMaxPerRoute() {
return this.pool.getDefaultMaxPerRoute();
}
public void setDefaultMaxPerRoute(int max) {
this.pool.setDefaultMaxPerRoute(max);
}
public int getMaxPerRoute(final HttpRoute route) {
return this.pool.getMaxPerRoute(route);
}
public void setMaxPerRoute(final HttpRoute route, int max) {
this.pool.setMaxPerRoute(route, max);
}

View File

@ -67,7 +67,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<httpcore.version>4.2-alpha1</httpcore.version>
<httpcore.version>4.2-alpha2</httpcore.version>
<commons-logging.version>1.1.1</commons-logging.version>
<commons-codec.version>1.4</commons-codec.version>
<ehcache.version>2.2.0</ehcache.version>