Javadoc updates and code cleanups

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@766758 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2009-04-20 17:15:05 +00:00
parent af182ce5e9
commit 4f51cdcf24
15 changed files with 150 additions and 232 deletions

View File

@ -36,28 +36,20 @@
import net.jcip.annotations.NotThreadSafe; import net.jcip.annotations.NotThreadSafe;
/** /**
* Basic implementation of {@link EofSensorWatcher EofSensorWatcher}. * Basic implementation of {@link EofSensorWatcher}. The underlying connection
* The underlying connection is released on close or EOF. * is released on close or EOF.
*
*
*
* <!-- empty lines to avoid svn diff problems -->
* @version $Revision$
* *
* @since 4.0 * @since 4.0
*/ */
@NotThreadSafe @NotThreadSafe
public class BasicEofSensorWatcher implements EofSensorWatcher { public class BasicEofSensorWatcher implements EofSensorWatcher {
/** The connection to auto-release. */ /** The connection to auto-release. */
protected final ManagedClientConnection managedConn; protected final ManagedClientConnection managedConn;
/** Whether to keep the connection alive. */ /** Whether to keep the connection alive. */
protected final boolean attemptReuse; protected final boolean attemptReuse;
/** /**
* Creates a new watcher for auto-releasing a connection. * Creates a new watcher for auto-releasing a connection.
* *
@ -74,8 +66,6 @@ public BasicEofSensorWatcher(ManagedClientConnection conn,
attemptReuse = reuse; attemptReuse = reuse;
} }
// non-javadoc, see interface EofSensorWatcher
public boolean eofDetected(InputStream wrapped) public boolean eofDetected(InputStream wrapped)
throws IOException { throws IOException {
@ -92,8 +82,6 @@ public boolean eofDetected(InputStream wrapped)
return false; return false;
} }
// non-javadoc, see interface EofSensorWatcher
public boolean streamClosed(InputStream wrapped) public boolean streamClosed(InputStream wrapped)
throws IOException { throws IOException {
@ -110,8 +98,6 @@ public boolean streamClosed(InputStream wrapped)
return false; return false;
} }
// non-javadoc, see interface EofSensorWatcher
public boolean streamAbort(InputStream wrapped) public boolean streamAbort(InputStream wrapped)
throws IOException { throws IOException {
@ -119,4 +105,4 @@ public boolean streamAbort(InputStream wrapped)
return false; return false;
} }
} // class BasicEofSensorWatcher }

View File

@ -39,18 +39,12 @@
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.entity.HttpEntityWrapper; import org.apache.http.entity.HttpEntityWrapper;
/** /**
* An entity that releases a {@link ManagedClientConnection connection}. * An entity that releases a {@link ManagedClientConnection connection}.
* A {@link ManagedClientConnection} will * A {@link ManagedClientConnection} will
* typically <i>not</i> return a managed entity, but you can replace * typically <i>not</i> return a managed entity, but you can replace
* the unmanaged entity in the response with a managed one. * the unmanaged entity in the response with a managed one.
* *
*
*
* <!-- empty lines to avoid svn diff problems -->
* @version $Revision$
*
* @since 4.0 * @since 4.0
*/ */
@NotThreadSafe @NotThreadSafe
@ -63,7 +57,6 @@ public class BasicManagedEntity extends HttpEntityWrapper
/** Whether to keep the connection alive. */ /** Whether to keep the connection alive. */
protected final boolean attemptReuse; protected final boolean attemptReuse;
/** /**
* Creates a new managed entity that can release a connection. * Creates a new managed entity that can release a connection.
* *
@ -87,26 +80,18 @@ public BasicManagedEntity(HttpEntity entity,
this.attemptReuse = reuse; this.attemptReuse = reuse;
} }
// non-javadoc, see interface HttpEntity
@Override @Override
public boolean isRepeatable() { public boolean isRepeatable() {
return false; return false;
} }
// non-javadoc, see interface HttpEntity
@Override @Override
public InputStream getContent() throws IOException { public InputStream getContent() throws IOException {
return new EofSensorInputStream(wrappedEntity.getContent(), this); return new EofSensorInputStream(wrappedEntity.getContent(), this);
} }
// non-javadoc, see interface HttpEntity
@Override @Override
public void consumeContent() throws IOException { public void consumeContent() throws IOException {
if (managedConn == null) if (managedConn == null)
return; return;
@ -121,26 +106,17 @@ public void consumeContent() throws IOException {
} }
} }
// non-javadoc, see interface HttpEntity
@Override @Override
public void writeTo(final OutputStream outstream) throws IOException { public void writeTo(final OutputStream outstream) throws IOException {
super.writeTo(outstream); super.writeTo(outstream);
consumeContent(); consumeContent();
} }
public void releaseConnection() throws IOException {
// non-javadoc, see interface ConnectionReleaseTrigger
public void releaseConnection()
throws IOException {
this.consumeContent(); this.consumeContent();
} }
public void abortConnection() throws IOException {
// non-javadoc, see interface ConnectionReleaseTrigger
public void abortConnection()
throws IOException {
if (managedConn != null) { if (managedConn != null) {
try { try {
@ -151,11 +127,7 @@ public void abortConnection()
} }
} }
public boolean eofDetected(InputStream wrapped) throws IOException {
// non-javadoc, see interface EofSensorWatcher
public boolean eofDetected(InputStream wrapped)
throws IOException {
try { try {
if (attemptReuse && (managedConn != null)) { if (attemptReuse && (managedConn != null)) {
// there may be some cleanup required, such as // there may be some cleanup required, such as
@ -169,11 +141,7 @@ public boolean eofDetected(InputStream wrapped)
return false; return false;
} }
public boolean streamClosed(InputStream wrapped) throws IOException {
// non-javadoc, see interface EofSensorWatcher
public boolean streamClosed(InputStream wrapped)
throws IOException {
try { try {
if (attemptReuse && (managedConn != null)) { if (attemptReuse && (managedConn != null)) {
// this assumes that closing the stream will // this assumes that closing the stream will
@ -187,18 +155,13 @@ public boolean streamClosed(InputStream wrapped)
return false; return false;
} }
public boolean streamAbort(InputStream wrapped) throws IOException {
// non-javadoc, see interface EofSensorWatcher
public boolean streamAbort(InputStream wrapped)
throws IOException {
if (managedConn != null) { if (managedConn != null) {
managedConn.abortConnection(); managedConn.abortConnection();
} }
return false; return false;
} }
/** /**
* Releases the connection gracefully. * Releases the connection gracefully.
* The connection attribute will be nullified. * The connection attribute will be nullified.
@ -219,4 +182,4 @@ protected void releaseManagedConnection()
} }
} }
} // class BasicManagedEntity }

View File

@ -31,19 +31,17 @@
package org.apache.http.conn; package org.apache.http.conn;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.http.conn.routing.HttpRoute; import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.scheme.SchemeRegistry; import org.apache.http.conn.scheme.SchemeRegistry;
/** /**
* Management interface for {@link ManagedClientConnection client connections}. * Management interface for {@link ManagedClientConnection client connections}.
* * The purpose of an HTTP connection manager is to serve as a factory for new
* * HTTP connections, manage persistent connections and synchronize access to
* * persistent connections making sure that only one thread of execution can
* <!-- empty lines to avoid svn diff problems --> * have access to a connection at a time.
* @version $Revision$
* *
* @since 4.0 * @since 4.0
*/ */
@ -54,18 +52,14 @@ public interface ClientConnectionManager {
* *
* @return the scheme registry, never <code>null</code> * @return the scheme registry, never <code>null</code>
*/ */
SchemeRegistry getSchemeRegistry() SchemeRegistry getSchemeRegistry();
;
/** /**
* Returns a new {@link ClientConnectionRequest}, from which a * Returns a new {@link ClientConnectionRequest}, from which a
* {@link ManagedClientConnection} can be obtained or the request can be * {@link ManagedClientConnection} can be obtained or the request can be
* aborted. * aborted.
*/ */
ClientConnectionRequest requestConnection(HttpRoute route, Object state) ClientConnectionRequest requestConnection(HttpRoute route, Object state);
;
/** /**
* Releases a connection for use by others. * Releases a connection for use by others.
@ -83,9 +77,7 @@ ClientConnectionRequest requestConnection(HttpRoute route, Object state)
* *
* @see #closeExpiredConnections() * @see #closeExpiredConnections()
*/ */
void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit);
;
/** /**
* Closes idle connections in the pool. * Closes idle connections in the pool.
@ -101,8 +93,7 @@ void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUni
* *
* @see #closeExpiredConnections() * @see #closeExpiredConnections()
*/ */
void closeIdleConnections(long idletime, TimeUnit tunit) void closeIdleConnections(long idletime, TimeUnit tunit);
;
/** /**
* Closes all expired connections in the pool. * Closes all expired connections in the pool.
@ -118,8 +109,6 @@ void closeIdleConnections(long idletime, TimeUnit tunit)
* This includes closing all connections, whether they are currently * This includes closing all connections, whether they are currently
* used or not. * used or not.
*/ */
void shutdown() void shutdown();
;
}
} // interface ClientConnectionManager

View File

@ -33,6 +33,7 @@
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.Socket;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.conn.scheme.SocketFactory; import org.apache.http.conn.scheme.SocketFactory;
@ -40,11 +41,10 @@
import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpContext;
/** /**
* Interface for opening {@link OperatedClientConnection connections}. * ClientConnectionOperator represents a strategy for creating
* This interface encapsulates the logic to create sockets and to * {@link OperatedClientConnection} instances and updating the underlying
* open or update the connection with the new socket. * {@link Socket} of those objects. Implementations will most likely make use
* Implementations will most likely make use of * of {@link SocketFactory}s to create {@link Socket} instances.
* {@link SocketFactory socket factories}.
* <br/> * <br/>
* The methods in this interface allow the creation of plain and layered * The methods in this interface allow the creation of plain and layered
* sockets. Creating a tunnelled connection through a proxy, however, * sockets. Creating a tunnelled connection through a proxy, however,

View File

@ -33,13 +33,11 @@
import java.io.IOException; import java.io.IOException;
/** /**
* Interface for releasing a connection. * Interface for releasing a connection. This can be implemented by various
* This can be implemented by various "trigger" objects which are * "trigger" objects which are associated with a connection, for example
* associated with a connection, for example * a {@link EofSensorInputStream stream} or an {@link BasicManagedEntity entity}
* a {@link EofSensorInputStream stream}
* or an {@link BasicManagedEntity entity}
* or the {@link ManagedClientConnection connection} itself. * or the {@link ManagedClientConnection connection} itself.
* <br/> * <p>
* The methods in this interface can safely be called multiple times. * The methods in this interface can safely be called multiple times.
* The first invocation releases the connection, subsequent calls * The first invocation releases the connection, subsequent calls
* are ignored. * are ignored.

View File

@ -34,8 +34,8 @@
import java.io.IOException; import java.io.IOException;
/** /**
* A watcher for {@link EofSensorInputStream EofSensorInputStream}. * A watcher for {@link EofSensorInputStream}. Each stream will notify its
* Each stream will notify its watcher at most once. * watcher at most once.
* *
* @since 4.0 * @since 4.0
*/ */

View File

@ -53,7 +53,6 @@
public interface ManagedClientConnection extends public interface ManagedClientConnection extends
HttpClientConnection, HttpInetConnection, ConnectionReleaseTrigger { HttpClientConnection, HttpInetConnection, ConnectionReleaseTrigger {
/** /**
* Indicates whether this connection is secure. * Indicates whether this connection is secure.
* The return value is well-defined only while the connection is open. * The return value is well-defined only while the connection is open.

View File

@ -34,11 +34,8 @@
--> -->
</head> </head>
<body> <body>
The client-side connection management and handling API The client-side connection management and handling API that provides interfaces
at the heart of what is referred to as <i>HttpConn</i>. and implementations for opening and managing client side HTTP connections.
This component provides interfaces and implementations for
opening and managing connections.
<p> <p>
The lowest layer of connection handling is comprised of The lowest layer of connection handling is comprised of
{@link org.apache.http.conn.OperatedClientConnection OperatedClientConnection} {@link org.apache.http.conn.OperatedClientConnection OperatedClientConnection}
@ -46,41 +43,37 @@
{@link org.apache.http.conn.ClientConnectionOperator ClientConnectionOperator}. {@link org.apache.http.conn.ClientConnectionOperator ClientConnectionOperator}.
The connection interface extends the core The connection interface extends the core
{@link org.apache.http.HttpClientConnection HttpClientConnection} {@link org.apache.http.HttpClientConnection HttpClientConnection}
by operations to set and update a socket. by operations to set and update a socket. An operator encapsulates the logic to
An operator encapsulates the logic to open and layer sockets, open and layer sockets, typically using a
typically using a {@link org.apache.http.conn.scheme.SocketFactory SocketFactory}. {@link org.apache.http.conn.scheme.SocketFactory}. The socket factory for
The socket factory for a protocol a protocol {@link org.apache.http.conn.scheme.Scheme} such as "http" or "https"
{@link org.apache.http.conn.scheme.Scheme Scheme} can be looked up in a {@link org.apache.http.conn.scheme.SchemeRegistry}.
such as "http" or "https" can be looked up in a Applications without a need for sophisticated connection management can use
{@link org.apache.http.conn.scheme.SchemeRegistry SchemeRegistry}. this layer directly.
Applications without a need for sophisticated connection management
can use this layer directly.
</p> </p>
<p> <p>
On top of that lies the connection management layer. A On top of that lies the connection management layer. A
{@link org.apache.http.conn.ClientConnectionManager ClientConnectionManager} {@link org.apache.http.conn.ClientConnectionManager} internally manages
internally manages operated connections, but hands out instances of operated connections, but hands out instances of
{@link org.apache.http.conn.ManagedClientConnection ManagedClientConnection}. {@link org.apache.http.conn.ManagedClientConnection}.
This interface abstracts from the underlying socket operations and This interface abstracts from the underlying socket operations and
provides convenient methods for opening and updating sockets in order provides convenient methods for opening and updating sockets in order
to establish a {@link org.apache.http.conn.routing.HttpRoute route}. to establish a {@link org.apache.http.conn.routing.HttpRoute route}.
The operator is encapsulated by the connection manager and called The operator is encapsulated by the connection manager and called
automatically. automatically.
</p>
<br/> <p>
Connections obtained from a manager have to be returned after use. Connections obtained from a manager have to be returned after use.
This can be {@link org.apache.http.conn.ConnectionReleaseTrigger triggered} This can be {@link org.apache.http.conn.ConnectionReleaseTrigger triggered}
on various levels, either by releasing the on various levels, either by releasing the
{@link org.apache.http.conn.ManagedClientConnection {@link org.apache.http.conn.ManagedClientConnection connection} directly,
connection} or by calling a method on
directly, or by calling a method on an an {@link org.apache.http.conn.BasicManagedEntity entity} received from
{@link org.apache.http.conn.BasicManagedEntity entity} the connection, or by closing the
received from the connection, or by closing the {@link org.apache.http.conn.EofSensorInputStream stream} from which
{@link org.apache.http.conn.EofSensorInputStream stream} that entity is being read.
from which that entity is being read. </p>
<p>
Connection managers will try to keep returned connections alive in Connection managers will try to keep returned connections alive in
order to re-use them for subsequent requests along the same route. order to re-use them for subsequent requests along the same route.
The managed connection interface and all triggers for connection release The managed connection interface and all triggers for connection release

View File

@ -34,7 +34,7 @@
--> -->
</head> </head>
<body> <body>
Parameters for configuring <i>HttpConn</i>. Parameters for configuring HTTP connection and connection management
related classes.
</body> </body>
</html> </html>

View File

@ -34,8 +34,7 @@
--> -->
</head> </head>
<body> <body>
The client-side route representation and tracking API, part of <i>HttpConn</i>. The client-side route representation and tracking API.
<p> <p>
An {@link org.apache.http.conn.routing.HttpRoute HttpRoute} An {@link org.apache.http.conn.routing.HttpRoute HttpRoute}
is the path along which a request has to be sent to the server. is the path along which a request has to be sent to the server.
@ -48,15 +47,11 @@
{@link org.apache.http.conn.routing.HttpRouteDirector HttpRouteDirector} {@link org.apache.http.conn.routing.HttpRouteDirector HttpRouteDirector}
determines the next step to take. determines the next step to take.
</p> </p>
<p> <p>
The {@link org.apache.http.conn.routing.HttpRoutePlanner HttpRoutePlanner} The {@link org.apache.http.conn.routing.HttpRoutePlanner HttpRoutePlanner}
is responsible for determining a route to a given target host. is responsible for determining a route to a given target host.
Implementations must know about proxies to use, and about exemptions Implementations must know about proxies to use, and about exemptions
for hosts that should be contacted directly without a proxy. for hosts that should be contacted directly without a proxy.
</p> </p>
</body> </body>
</html> </html>

View File

@ -0,0 +1,42 @@
<html>
<head>
<!--
/*
* $HeadURL:$
* $Revision:$
* $Date:$
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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/>.
*
*/
-->
</head>
<body>
{@link org.apache.http.conn.scheme.Scheme} class represents a protocol
scheme such as "http" or "https" and contains a number of protocol properties
such as the default port and the socket factory to be used to creating
{@link java.net.Socket}s for the given protocol
</body>
</html>

View File

@ -30,7 +30,6 @@
package org.apache.http.impl.conn; package org.apache.http.impl.conn;
import java.io.IOException; import java.io.IOException;
import java.io.InterruptedIOException; import java.io.InterruptedIOException;
import java.net.InetAddress; import java.net.InetAddress;
@ -49,7 +48,6 @@
import org.apache.http.conn.ManagedClientConnection; import org.apache.http.conn.ManagedClientConnection;
import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.ClientConnectionManager;
/** /**
* Abstract adapter from {@link OperatedClientConnection operated} to * Abstract adapter from {@link OperatedClientConnection operated} to
* {@link ManagedClientConnection managed} client connections. * {@link ManagedClientConnection managed} client connections.
@ -58,26 +56,20 @@
* by derived classes. Operations for querying the connection state * by derived classes. Operations for querying the connection state
* are delegated to the wrapped connection if there is one, or * are delegated to the wrapped connection if there is one, or
* return a default value if there is none. * return a default value if there is none.
* <br/> * <p>
* This adapter tracks the checkpoints for reusable communication states, * This adapter tracks the checkpoints for reusable communication states,
* as indicated by {@link #markReusable markReusable} and queried by * as indicated by {@link #markReusable markReusable} and queried by
* {@link #isMarkedReusable isMarkedReusable}. * {@link #isMarkedReusable isMarkedReusable}.
* All send and receive operations will automatically clear the mark. * All send and receive operations will automatically clear the mark.
* <br/> * <p>
* Connection release calls are delegated to the connection manager, * Connection release calls are delegated to the connection manager,
* if there is one. {@link #abortConnection abortConnection} will * if there is one. {@link #abortConnection abortConnection} will
* clear the reusability mark first. The connection manager is * clear the reusability mark first. The connection manager is
* expected to tolerate multiple calls to the release method. * expected to tolerate multiple calls to the release method.
* *
*
*
* <!-- empty lines to avoid svn diff problems -->
* @version $Revision$ $Date$
*
* @since 4.0 * @since 4.0
*/ */
public abstract class AbstractClientConnAdapter public abstract class AbstractClientConnAdapter implements ManagedClientConnection {
implements ManagedClientConnection {
/** Thread that requested this connection. */ /** Thread that requested this connection. */
private final Thread executionThread; private final Thread executionThread;
@ -163,7 +155,6 @@ protected final void assertValid(
} }
} }
// non-javadoc, see interface HttpConnection
public boolean isOpen() { public boolean isOpen() {
OperatedClientConnection conn = getWrappedConnection(); OperatedClientConnection conn = getWrappedConnection();
if (conn == null) if (conn == null)
@ -172,8 +163,6 @@ public boolean isOpen() {
return conn.isOpen(); return conn.isOpen();
} }
// non-javadoc, see interface HttpConnection
public boolean isStale() { public boolean isStale() {
if (aborted) if (aborted)
return true; return true;
@ -184,32 +173,24 @@ public boolean isStale() {
return conn.isStale(); return conn.isStale();
} }
// non-javadoc, see interface HttpConnection
public void setSocketTimeout(int timeout) { public void setSocketTimeout(int timeout) {
OperatedClientConnection conn = getWrappedConnection(); OperatedClientConnection conn = getWrappedConnection();
assertValid(conn); assertValid(conn);
conn.setSocketTimeout(timeout); conn.setSocketTimeout(timeout);
} }
// non-javadoc, see interface HttpConnection
public int getSocketTimeout() { public int getSocketTimeout() {
OperatedClientConnection conn = getWrappedConnection(); OperatedClientConnection conn = getWrappedConnection();
assertValid(conn); assertValid(conn);
return conn.getSocketTimeout(); return conn.getSocketTimeout();
} }
// non-javadoc, see interface HttpConnection
public HttpConnectionMetrics getMetrics() { public HttpConnectionMetrics getMetrics() {
OperatedClientConnection conn = getWrappedConnection(); OperatedClientConnection conn = getWrappedConnection();
assertValid(conn); assertValid(conn);
return conn.getMetrics(); return conn.getMetrics();
} }
// non-javadoc, see interface HttpClientConnection
public void flush() public void flush()
throws IOException { throws IOException {
@ -220,8 +201,6 @@ public void flush()
conn.flush(); conn.flush();
} }
// non-javadoc, see interface HttpClientConnection
public boolean isResponseAvailable(int timeout) public boolean isResponseAvailable(int timeout)
throws IOException { throws IOException {
@ -232,8 +211,6 @@ public boolean isResponseAvailable(int timeout)
return conn.isResponseAvailable(timeout); return conn.isResponseAvailable(timeout);
} }
// non-javadoc, see interface HttpClientConnection
public void receiveResponseEntity(HttpResponse response) public void receiveResponseEntity(HttpResponse response)
throws HttpException, IOException { throws HttpException, IOException {
@ -245,8 +222,6 @@ public void receiveResponseEntity(HttpResponse response)
conn.receiveResponseEntity(response); conn.receiveResponseEntity(response);
} }
// non-javadoc, see interface HttpClientConnection
public HttpResponse receiveResponseHeader() public HttpResponse receiveResponseHeader()
throws HttpException, IOException { throws HttpException, IOException {
@ -258,8 +233,6 @@ public HttpResponse receiveResponseHeader()
return conn.receiveResponseHeader(); return conn.receiveResponseHeader();
} }
// non-javadoc, see interface HttpClientConnection
public void sendRequestEntity(HttpEntityEnclosingRequest request) public void sendRequestEntity(HttpEntityEnclosingRequest request)
throws HttpException, IOException { throws HttpException, IOException {
@ -271,8 +244,6 @@ public void sendRequestEntity(HttpEntityEnclosingRequest request)
conn.sendRequestEntity(request); conn.sendRequestEntity(request);
} }
// non-javadoc, see interface HttpClientConnection
public void sendRequestHeader(HttpRequest request) public void sendRequestHeader(HttpRequest request)
throws HttpException, IOException { throws HttpException, IOException {
@ -284,44 +255,36 @@ public void sendRequestHeader(HttpRequest request)
conn.sendRequestHeader(request); conn.sendRequestHeader(request);
} }
// non-javadoc, see interface HttpInetConnection
public InetAddress getLocalAddress() { public InetAddress getLocalAddress() {
OperatedClientConnection conn = getWrappedConnection(); OperatedClientConnection conn = getWrappedConnection();
assertValid(conn); assertValid(conn);
return conn.getLocalAddress(); return conn.getLocalAddress();
} }
// non-javadoc, see interface HttpInetConnection
public int getLocalPort() { public int getLocalPort() {
OperatedClientConnection conn = getWrappedConnection(); OperatedClientConnection conn = getWrappedConnection();
assertValid(conn); assertValid(conn);
return conn.getLocalPort(); return conn.getLocalPort();
} }
// non-javadoc, see interface HttpInetConnection
public InetAddress getRemoteAddress() { public InetAddress getRemoteAddress() {
OperatedClientConnection conn = getWrappedConnection(); OperatedClientConnection conn = getWrappedConnection();
assertValid(conn); assertValid(conn);
return conn.getRemoteAddress(); return conn.getRemoteAddress();
} }
// non-javadoc, see interface HttpInetConnection
public int getRemotePort() { public int getRemotePort() {
OperatedClientConnection conn = getWrappedConnection(); OperatedClientConnection conn = getWrappedConnection();
assertValid(conn); assertValid(conn);
return conn.getRemotePort(); return conn.getRemotePort();
} }
// non-javadoc, see interface ManagedClientConnection
public boolean isSecure() { public boolean isSecure() {
OperatedClientConnection conn = getWrappedConnection(); OperatedClientConnection conn = getWrappedConnection();
assertValid(conn); assertValid(conn);
return conn.isSecure(); return conn.isSecure();
} }
// non-javadoc, see interface ManagedClientConnection
public SSLSession getSSLSession() { public SSLSession getSSLSession() {
OperatedClientConnection conn = getWrappedConnection(); OperatedClientConnection conn = getWrappedConnection();
assertValid(conn); assertValid(conn);
@ -336,17 +299,14 @@ public SSLSession getSSLSession() {
return result; return result;
} }
// non-javadoc, see interface ManagedClientConnection
public void markReusable() { public void markReusable() {
markedReusable = true; markedReusable = true;
} }
// non-javadoc, see interface ManagedClientConnection
public void unmarkReusable() { public void unmarkReusable() {
markedReusable = false; markedReusable = false;
} }
// non-javadoc, see interface ManagedClientConnection
public boolean isMarkedReusable() { public boolean isMarkedReusable() {
return markedReusable; return markedReusable;
} }
@ -359,14 +319,12 @@ public void setIdleDuration(long duration, TimeUnit unit) {
} }
} }
// non-javadoc, see interface ConnectionReleaseTrigger
public void releaseConnection() { public void releaseConnection() {
if (connManager != null) { if (connManager != null) {
connManager.releaseConnection(this, duration, TimeUnit.MILLISECONDS); connManager.releaseConnection(this, duration, TimeUnit.MILLISECONDS);
} }
} }
// non-javadoc, see interface ConnectionReleaseTrigger
public void abortConnection() { public void abortConnection() {
if (aborted) { if (aborted) {
return; return;
@ -395,4 +353,4 @@ public void abortConnection() {
} }
} }
} // class AbstractClientConnAdapter }

View File

@ -30,7 +30,6 @@
package org.apache.http.impl.conn; package org.apache.http.impl.conn;
import java.io.IOException; import java.io.IOException;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
@ -41,8 +40,6 @@
import org.apache.http.conn.ClientConnectionOperator; import org.apache.http.conn.ClientConnectionOperator;
import org.apache.http.conn.OperatedClientConnection; import org.apache.http.conn.OperatedClientConnection;
/** /**
* A pool entry for use by connection manager implementations. * A pool entry for use by connection manager implementations.
* Pool entries work in conjunction with an * Pool entries work in conjunction with an
@ -52,16 +49,11 @@
* {@link HttpRoute route} established. * {@link HttpRoute route} established.
* The adapter delegates methods for establishing the route to * The adapter delegates methods for establishing the route to
* its pool entry. * its pool entry.
* <br/> * <p>
* If the managed connections is released or revoked, the adapter * If the managed connections is released or revoked, the adapter
* gets disconnected, but the pool entry still contains the * gets disconnected, but the pool entry still contains the
* underlying connection and the established route. * underlying connection and the established route.
* *
*
*
* <!-- empty lines to avoid svn diff problems -->
* @version $Revision$
*
* @since 4.0 * @since 4.0
*/ */
public abstract class AbstractPoolEntry { public abstract class AbstractPoolEntry {
@ -176,8 +168,7 @@ public void open(HttpRoute route,
localTracker.connectProxy(proxy, this.connection.isSecure()); localTracker.connectProxy(proxy, this.connection.isSecure());
} }
} // open }
/** /**
* Tracks tunnelling of the connection to the target. * Tracks tunnelling of the connection to the target.
@ -209,9 +200,7 @@ public void tunnelTarget(boolean secure, HttpParams params)
this.connection.update(null, tracker.getTargetHost(), this.connection.update(null, tracker.getTargetHost(),
secure, params); secure, params);
this.tracker.tunnelTarget(secure); this.tracker.tunnelTarget(secure);
}
} // tunnelTarget
/** /**
* Tracks tunnelling of the connection to a chained proxy. * Tracks tunnelling of the connection to a chained proxy.
@ -245,13 +234,9 @@ public void tunnelProxy(HttpHost next, boolean secure, HttpParams params)
throw new IllegalStateException("Connection not open."); throw new IllegalStateException("Connection not open.");
} }
// LOG.debug?
this.connection.update(null, next, secure, params); this.connection.update(null, next, secure, params);
this.tracker.tunnelProxy(next, secure); this.tracker.tunnelProxy(next, secure);
}
} // tunnelProxy
/** /**
* Layers a protocol on top of an established tunnel. * Layers a protocol on top of an established tunnel.
@ -296,8 +281,7 @@ public void layerProtocol(HttpContext context, HttpParams params)
this.tracker.layerProtocol(this.connection.isSecure()); this.tracker.layerProtocol(this.connection.isSecure());
} // layerProtocol }
/** /**
* Shuts down the entry. * Shuts down the entry.
@ -310,6 +294,5 @@ protected void shutdownEntry() {
state = null; state = null;
} }
}
} // class AbstractPoolEntry

View File

@ -30,7 +30,6 @@
package org.apache.http.impl.conn; package org.apache.http.impl.conn;
import java.io.IOException; import java.io.IOException;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
@ -40,8 +39,6 @@
import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.OperatedClientConnection; import org.apache.http.conn.OperatedClientConnection;
/** /**
* Abstract adapter from pool {@link AbstractPoolEntry entries} to * Abstract adapter from pool {@link AbstractPoolEntry entries} to
* {@link org.apache.http.conn.ManagedClientConnection managed} * {@link org.apache.http.conn.ManagedClientConnection managed}
@ -52,11 +49,6 @@
* will clear the tracked route in the pool entry and call the * will clear the tracked route in the pool entry and call the
* respective method of the wrapped connection. * respective method of the wrapped connection.
* *
*
*
* <!-- empty lines to avoid svn diff problems -->
* @version $Revision$ $Date$
*
* @since 4.0 * @since 4.0
*/ */
public abstract class AbstractPooledConnAdapter extends AbstractClientConnAdapter { public abstract class AbstractPooledConnAdapter extends AbstractClientConnAdapter {
@ -64,7 +56,6 @@ public abstract class AbstractPooledConnAdapter extends AbstractClientConnAdapte
/** The wrapped pool entry. */ /** The wrapped pool entry. */
protected volatile AbstractPoolEntry poolEntry; protected volatile AbstractPoolEntry poolEntry;
/** /**
* Creates a new connection adapter. * Creates a new connection adapter.
* *
@ -77,7 +68,6 @@ protected AbstractPooledConnAdapter(ClientConnectionManager manager,
this.poolEntry = entry; this.poolEntry = entry;
} }
/** /**
* Asserts that this adapter is still attached. * Asserts that this adapter is still attached.
* *
@ -100,8 +90,6 @@ protected void detach() {
poolEntry = null; poolEntry = null;
} }
// non-javadoc, see interface ManagedHttpConnection
public HttpRoute getRoute() { public HttpRoute getRoute() {
assertAttached(); assertAttached();
@ -109,7 +97,6 @@ public HttpRoute getRoute() {
null : poolEntry.tracker.toRoute(); null : poolEntry.tracker.toRoute();
} }
// non-javadoc, see interface ManagedHttpConnection
public void open(HttpRoute route, public void open(HttpRoute route,
HttpContext context, HttpParams params) HttpContext context, HttpParams params)
throws IOException { throws IOException {
@ -118,8 +105,6 @@ public void open(HttpRoute route,
poolEntry.open(route, context, params); poolEntry.open(route, context, params);
} }
// non-javadoc, see interface ManagedHttpConnection
public void tunnelTarget(boolean secure, HttpParams params) public void tunnelTarget(boolean secure, HttpParams params)
throws IOException { throws IOException {
@ -127,8 +112,6 @@ public void tunnelTarget(boolean secure, HttpParams params)
poolEntry.tunnelTarget(secure, params); poolEntry.tunnelTarget(secure, params);
} }
// non-javadoc, see interface ManagedHttpConnection
public void tunnelProxy(HttpHost next, boolean secure, HttpParams params) public void tunnelProxy(HttpHost next, boolean secure, HttpParams params)
throws IOException { throws IOException {
@ -136,8 +119,6 @@ public void tunnelProxy(HttpHost next, boolean secure, HttpParams params)
poolEntry.tunnelProxy(next, secure, params); poolEntry.tunnelProxy(next, secure, params);
} }
// non-javadoc, see interface ManagedHttpConnection
public void layerProtocol(HttpContext context, HttpParams params) public void layerProtocol(HttpContext context, HttpParams params)
throws IOException { throws IOException {
@ -145,9 +126,6 @@ public void layerProtocol(HttpContext context, HttpParams params)
poolEntry.layerProtocol(context, params); poolEntry.layerProtocol(context, params);
} }
// non-javadoc, see interface HttpConnection
public void close() throws IOException { public void close() throws IOException {
if (poolEntry != null) if (poolEntry != null)
poolEntry.shutdownEntry(); poolEntry.shutdownEntry();
@ -158,7 +136,6 @@ public void close() throws IOException {
} }
} }
// non-javadoc, see interface HttpConnection
public void shutdown() throws IOException { public void shutdown() throws IOException {
if (poolEntry != null) if (poolEntry != null)
poolEntry.shutdownEntry(); poolEntry.shutdownEntry();
@ -169,19 +146,14 @@ public void shutdown() throws IOException {
} }
} }
// non-javadoc, see interface ManagedClientConnection
public Object getState() { public Object getState() {
assertAttached(); assertAttached();
return poolEntry.getState(); return poolEntry.getState();
} }
// non-javadoc, see interface ManagedClientConnection
public void setState(final Object state) { public void setState(final Object state) {
assertAttached(); assertAttached();
poolEntry.setState(state); poolEntry.setState(state);
} }
} // class AbstractPooledConnAdapter }

View File

@ -0,0 +1,40 @@
<html>
<head>
<!--
/*
* $HeadURL:$
* $Revision:$
* $Date:$
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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/>.
*
*/
-->
</head>
<body>
Default implementations for interfaces in
{@link org.apache.http.impl.conn org.apache.http.impl.conn} and related classes.
</body>
</html>