Top Description Fields Constructors Methods
org.apache.http.impl.conn

public Class DefaultClientConnectionOperator

extends Object
implements ClientConnectionOperator
Class Inheritance
All Implemented Interfaces
org.apache.http.conn.ClientConnectionOperator
Annotations
@Deprecated
@Contract
threading:SAFE_CONDITIONAL
Imports
java.io.IOException, java.net.ConnectException, .InetAddress, .InetSocketAddress, .Socket, .UnknownHostException, org.apache.commons.logging.Log, .LogFactory, org.apache.http.HttpHost, org.apache.http.annotation.Contract, .ThreadingBehavior, org.apache.http.client.protocol.ClientContext, org.apache.http.conn.ClientConnectionOperator, .ConnectTimeoutException, .DnsResolver, .HttpInetSocketAddress, .OperatedClientConnection, org.apache.http.conn.scheme.Scheme, .SchemeLayeredSocketFactory, .SchemeRegistry, .SchemeSocketFactory, org.apache.http.params.HttpConnectionParams, .HttpParams, org.apache.http.protocol.HttpContext, org.apache.http.util.Args, .Asserts

Deprecated

(4.3) use PoolingHttpClientConnectionManager.

Default implementation of a ClientConnectionOperator. It uses a SchemeRegistry to look up SchemeSocketFactory objects.

This connection operator is multihome network aware and will attempt to retry failed connects against all known IP addresses sequentially until the connect is successful or all known addresses fail to respond. Please note the same org.apache.http.params.CoreConnectionPNames#CONNECTION_TIMEOUT value will be used for each connection attempt, so in the worst case the total elapsed time before timeout can be CONNECTION_TIMEOUT * n where n is the number of IP addresses of the given host. One can disable multihome support by overriding the resolveHostname(String) method and returning only one IP address for the given host name.

The following parameters can be used to customize the behavior of this class:

Since
4.0

Field Summary

Modifier and TypeField and Description
protected final DnsResolver
dnsResolver

the custom-configured DNS lookup mechanism.

private final Log
protected final SchemeRegistry
schemeRegistry

The scheme registry for looking up socket factories.

Constructor Summary

AccessConstructor and Description
public
DefaultClientConnectionOperator(final SchemeRegistry
the scheme registry
schemes
)

Deprecated as a consequence of SchemeRegistry being deprecated.
Creates a new client connection operator for the given scheme registry.
public
DefaultClientConnectionOperator(final SchemeRegistry
the scheme registry
schemes
,
final DnsResolver
the custom DNS lookup mechanism
dnsResolver
)

Deprecated as a consequence of SchemeRegistry being deprecated.
Creates a new client connection operator for the given scheme registry and the given custom DNS lookup mechanism.

Method Summary

Modifier and TypeMethod and Description
public OperatedClientConnection
createConnection()

Implements org.apache.http.conn.ClientConnectionOperator.createConnection.

Deprecated as a consequence of OperatedClientConnection being deprecated.
Creates a new connection that can be operated.
private SchemeRegistry
getSchemeRegistry(final HttpContext context)

Deprecated as a consequence of SchemeRegistry being deprecated.
public void
openConnection(final OperatedClientConnection
the connection to open
conn
,
final HttpHost
the target host to connect to
target
,
final InetAddress
the local address to route from, or null for the default
local
,
final HttpContext
the context for the connection
context
,
final HttpParams
the parameters for the connection
params
)

Implements org.apache.http.conn.ClientConnectionOperator.openConnection.

Deprecated as a consequence of OperatedClientConnection and HttpParams being deprecated.
Opens a connection to the given target host.
protected void
prepareSocket(final Socket
the socket to prepare
sock
,
final HttpContext
the context for the connection
context
,
final HttpParams
the parameters from which to prepare the socket
params
)

Deprecated as a consequence of HttpParams being deprecated.
Performs standard initializations on a newly created socket.
protected InetAddress[]

Returns:

array of IP addresses
resolveHostname
(final String
host name to resolve
host
)

Resolves the given host name to an array of corresponding IP addresses, based on the configured name service on the provided DNS resolver.

public void
updateSecureConnection(final OperatedClientConnection
the open connection to update
conn
,
final HttpHost
the target host for the updated connection. The connection must already be open or tunnelled to the host and port, but the scheme of the target will be used to create a layered connection.
target
,
final HttpContext
the context for the connection
context
,
final HttpParams
the parameters for the updated connection
params
)

Implements org.apache.http.conn.ClientConnectionOperator.updateSecureConnection.

Deprecated as a consequence of OperatedClientConnection and HttpParams being deprecated.
Updates a connection with a layered secure connection.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dnsResolverback to summary
protected final DnsResolver dnsResolver

the custom-configured DNS lookup mechanism.

logback to summary
private final Log log
schemeRegistryback to summary
protected final SchemeRegistry schemeRegistry

Deprecated

as a consequence of SchemeRegistry being deprecated. See corresponding docs for further information.

The scheme registry for looking up socket factories.

Constructor Detail

DefaultClientConnectionOperatorback to summary
public DefaultClientConnectionOperator(final SchemeRegistry schemes)

Deprecated

as a consequence of SchemeRegistry being deprecated. See corresponding docs for further information.

Creates a new client connection operator for the given scheme registry.

Parameters
schemes:SchemeRegistry

the scheme registry

Since
4.2
DefaultClientConnectionOperatorback to summary
public DefaultClientConnectionOperator(final SchemeRegistry schemes, final DnsResolver dnsResolver)

Deprecated

as a consequence of SchemeRegistry being deprecated. See corresponding docs for further information.

Creates a new client connection operator for the given scheme registry and the given custom DNS lookup mechanism.

Parameters
schemes:SchemeRegistry

the scheme registry

dnsResolver:DnsResolver

the custom DNS lookup mechanism

Method Detail

createConnectionback to summary
public OperatedClientConnection createConnection()

Implements org.apache.http.conn.ClientConnectionOperator.createConnection.

Doc from org.apache.http.conn.ClientConnectionOperator.createConnection.

Deprecated

as a consequence of OperatedClientConnection being deprecated. See corresponding docs for further information.

Creates a new connection that can be operated.

Returns:OperatedClientConnection

a new, unopened connection for use with this operator

Annotations
@Override
getSchemeRegistryback to summary
private SchemeRegistry getSchemeRegistry(final HttpContext context)

Deprecated

as a consequence of SchemeRegistry being deprecated. See corresponding docs for further information.

openConnectionback to summary
public void openConnection(final OperatedClientConnection conn, final HttpHost target, final InetAddress local, final HttpContext context, final HttpParams params) throws IOException

Implements org.apache.http.conn.ClientConnectionOperator.openConnection.

Doc from org.apache.http.conn.ClientConnectionOperator.openConnection.

Deprecated

as a consequence of OperatedClientConnection and HttpParams being deprecated. See corresponding docs for further information.

Opens a connection to the given target host.

Parameters
conn:OperatedClientConnection

the connection to open

target:HttpHost

the target host to connect to

local:InetAddress

the local address to route from, or null for the default

context:HttpContext

the context for the connection

params:HttpParams

the parameters for the connection

Annotations
@Override
Exceptions
IOException:
in case of a problem
prepareSocketback to summary
protected void prepareSocket(final Socket sock, final HttpContext context, final HttpParams params) throws IOException

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

Performs standard initializations on a newly created socket.

Parameters
sock:Socket

the socket to prepare

context:HttpContext

the context for the connection

params:HttpParams

the parameters from which to prepare the socket

Exceptions
IOException:
in case of an IO problem
resolveHostnameback to summary
protected InetAddress[] resolveHostname(final String host) throws UnknownHostException

Resolves the given host name to an array of corresponding IP addresses, based on the configured name service on the provided DNS resolver. If one wasn't provided, the system configuration is used.

Parameters
host:String

host name to resolve

Returns:InetAddress[]

array of IP addresses

Exceptions
UnknownHostException:
if no IP address for the host could be determined.
Since
4.1
See Also
DnsResolver, SystemDefaultDnsResolver
updateSecureConnectionback to summary
public void updateSecureConnection(final OperatedClientConnection conn, final HttpHost target, final HttpContext context, final HttpParams params) throws IOException

Implements org.apache.http.conn.ClientConnectionOperator.updateSecureConnection.

Doc from org.apache.http.conn.ClientConnectionOperator.updateSecureConnection.

Deprecated

as a consequence of OperatedClientConnection and HttpParams being deprecated. See corresponding docs for further information.

Updates a connection with a layered secure connection. The typical use of this method is to update a tunnelled plain connection (HTTP) to a secure TLS/SSL connection (HTTPS).

Parameters
conn:OperatedClientConnection

the open connection to update

target:HttpHost

the target host for the updated connection. The connection must already be open or tunnelled to the host and port, but the scheme of the target will be used to create a layered connection.

context:HttpContext

the context for the connection

params:HttpParams

the parameters for the updated connection

Annotations
@Override
Exceptions
IOException:
in case of a problem