org.apache.http.impl.conn
Class DefaultClientConnectionOperator

java.lang.Object
  extended by org.apache.http.impl.conn.DefaultClientConnectionOperator
All Implemented Interfaces:
ClientConnectionOperator

@ThreadSafe
public class DefaultClientConnectionOperator
extends Object
implements ClientConnectionOperator

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

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

Since:
4.0

Field Summary
protected  SchemeRegistry schemeRegistry
          The scheme registry for looking up socket factories.
 
Constructor Summary
DefaultClientConnectionOperator(SchemeRegistry schemes)
          Creates a new client connection operator for the given scheme registry.
 
Method Summary
 OperatedClientConnection createConnection()
          Creates a new connection that can be operated.
 void openConnection(OperatedClientConnection conn, HttpHost target, InetAddress local, HttpContext context, HttpParams params)
          Opens a connection to the given target host.
protected  void prepareSocket(Socket sock, HttpContext context, HttpParams params)
          Performs standard initializations on a newly created socket.
 void updateSecureConnection(OperatedClientConnection conn, HttpHost target, HttpContext context, HttpParams params)
          Updates a connection with a layered secure connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schemeRegistry

protected final SchemeRegistry schemeRegistry
The scheme registry for looking up socket factories.

Constructor Detail

DefaultClientConnectionOperator

public DefaultClientConnectionOperator(SchemeRegistry schemes)
Creates a new client connection operator for the given scheme registry.

Parameters:
schemes - the scheme registry
Method Detail

createConnection

public OperatedClientConnection createConnection()
Description copied from interface: ClientConnectionOperator
Creates a new connection that can be operated.

Specified by:
createConnection in interface ClientConnectionOperator
Returns:
a new, unopened connection for use with this operator

openConnection

public void openConnection(OperatedClientConnection conn,
                           HttpHost target,
                           InetAddress local,
                           HttpContext context,
                           HttpParams params)
                    throws IOException
Description copied from interface: ClientConnectionOperator
Opens a connection to the given target host.

Specified by:
openConnection in interface ClientConnectionOperator
Parameters:
conn - the connection to open
target - the target host to connect to
local - the local address to route from, or null for the default
context - the context for the connection
params - the parameters for the connection
Throws:
IOException - in case of a problem

updateSecureConnection

public void updateSecureConnection(OperatedClientConnection conn,
                                   HttpHost target,
                                   HttpContext context,
                                   HttpParams params)
                            throws IOException
Description copied from interface: ClientConnectionOperator
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).

Specified by:
updateSecureConnection in interface ClientConnectionOperator
Parameters:
conn - the open connection to update
target - 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 - the context for the connection
params - the parameters for the updated connection
Throws:
IOException - in case of a problem

prepareSocket

protected void prepareSocket(Socket sock,
                             HttpContext context,
                             HttpParams params)
                      throws IOException
Performs standard initializations on a newly created socket.

Parameters:
sock - the socket to prepare
context - the context for the connection
params - the parameters from which to prepare the socket
Throws:
IOException - in case of an IO problem


Copyright © 1999-2010 Apache Software Foundation. All Rights Reserved.