## org.apache.http.impl.conn
Class AbstractPooledConnAdapter

    java.lang.Object
      org.apache.http.impl.conn.AbstractClientConnAdapter
          org.apache.http.impl.conn.AbstractPooledConnAdapter

All Implemented Interfaces:
  ConnectionReleaseTrigger, HttpRoutedConnection, ManagedClientConnection, HttpClientConnection, HttpConnection, HttpInetConnection, HttpContext

Direct Known Subclasses:
  BasicPooledConnAdapter, SingleClientConnManager.ConnAdapter

    public abstract class AbstractPooledConnAdapter

extends AbstractClientConnAdapter

Abstract adapter from pool `entries` to `managed` client connections. The connection in the pool entry is used to initialize the base class. In addition, methods to establish a route are delegated to the pool entry. `shutdown` and `close` will clear the tracked route in the pool entry and call the respective method of the wrapped connection.

Since:
  4.0

Field Summary
`protected AbstractPoolEntry` `poolEntry` The wrapped pool entry.

Fields inherited from interface org.apache.http.protocol.HttpContext
`RESERVED_PREFIX`

Constructor Summary
`protected` `AbstractPooledConnAdapter(ClientConnectionManager manager, AbstractPoolEntry entry)` Creates a new connection adapter.

Method Summary
`protected void` `assertAttached()` Deprecated. use `assertValid(AbstractPoolEntry)`
`protected void` `assertValid(AbstractPoolEntry entry)` Asserts that there is a valid pool entry.
`void` `close()`
`protected void` `detach()` Detaches this adapter from the wrapped connection.
`protected AbstractPoolEntry` `getPoolEntry()` Obtains the pool entry.
`HttpRoute` `getRoute()` Obtains the current route of this connection.
`Object` `getState()` Returns the state object associated with this connection.
`void` `layerProtocol(HttpContext context, HttpParams params)` Layers a new protocol on top of a `tunnelled` connection.
`void` `open(HttpRoute route, HttpContext context, HttpParams params)` Opens this connection according to the given route.
`void` `setState(Object state)` Assigns a state object to this connection.
`void` `shutdown()`
`void` `tunnelProxy(HttpHost next, boolean secure, HttpParams params)` Indicates that a tunnel to an intermediate proxy has been established.
`void` `tunnelTarget(boolean secure, HttpParams params)` Indicates that a tunnel to the target has been established.

Methods inherited from class org.apache.http.impl.conn.AbstractClientConnAdapter

`abortConnection, assertNotAborted, assertValid, flush, getAttribute, getLocalAddress, getLocalPort, getManager, getMetrics, getRemoteAddress, getRemotePort, getSocketTimeout, getSSLSession, getWrappedConnection, isMarkedReusable, isOpen, isReleased, isResponseAvailable, isSecure, isStale, markReusable, receiveResponseEntity, receiveResponseHeader, releaseConnection, removeAttribute, sendRequestEntity, sendRequestHeader, setAttribute, setIdleDuration, setSocketTimeout, unmarkReusable`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### poolEntry

    protected volatile AbstractPoolEntry poolEntry

  The wrapped pool entry.

Constructor Detail

### AbstractPooledConnAdapter

    protected AbstractPooledConnAdapter(ClientConnectionManager manager,
                                        AbstractPoolEntry entry)

  Creates a new connection adapter.

  Parameters:
    `manager` - the connection manager
    `entry` - the pool entry for the connection being wrapped

Method Detail

### getPoolEntry

    protected AbstractPoolEntry getPoolEntry()

  Obtains the pool entry.

  Returns:
    the pool entry, or `null` if detached

### assertValid

    protected void assertValid(AbstractPoolEntry entry)

  Asserts that there is a valid pool entry.

  Throws:
    `ConnectionShutdownException` - if there is no pool entry or connection has been aborted
  See Also:
    `AbstractClientConnAdapter.assertValid(OperatedClientConnection)`

### assertAttached

    @Deprecated
    protected final void assertAttached()

  Deprecated. use `assertValid(AbstractPoolEntry)`

### detach

    protected void detach()

  Detaches this adapter from the wrapped connection. This adapter becomes useless.

  Overrides:
    `detach` in class `AbstractClientConnAdapter`

### getRoute

    public HttpRoute getRoute()

  Description copied from interface: `HttpRoutedConnection`
  Obtains the current route of this connection.

  Returns:
    the route established so far, or `null` if not connected

### open

    public void open(HttpRoute route,
                     HttpContext context,
                     HttpParams params)
              throws IOException

  Description copied from interface: `ManagedClientConnection`
  Opens this connection according to the given route.

  Parameters:
    `route` - the route along which to open. It will be opened to the first proxy if present, or directly to the target.
    `context` - the context for opening this connection
    `params` - the parameters for opening this connection
  Throws:
    `IOException` - in case of a problem

### tunnelTarget

    public void tunnelTarget(boolean secure,
                             HttpParams params)
                      throws IOException

  Description copied from interface: `ManagedClientConnection`
  Indicates that a tunnel to the target has been established. The route is the one previously passed to `open`. Subsequently, `layerProtocol` can be called to layer the TLS/SSL protocol on top of the tunnelled connection.
  Note: In HttpClient 3, a call to the corresponding method would automatically trigger the layering of the TLS/SSL protocol. This is not the case anymore, you can establish a tunnel without layering a new protocol over the connection.

  Parameters:
    `secure` - `true` if the tunnel should be considered secure, `false` otherwise
    `params` - the parameters for tunnelling this connection
  Throws:
    `IOException` - in case of a problem

### tunnelProxy

    public void tunnelProxy(HttpHost next,
                            boolean secure,
                            HttpParams params)
                     throws IOException

  Description copied from interface: `ManagedClientConnection`
  Indicates that a tunnel to an intermediate proxy has been established. This is used exclusively for so-called proxy chains, where a request has to pass through multiple proxies before reaching the target. In that case, all proxies but the last need to be tunnelled when establishing the connection. Tunnelling of the last proxy to the target is optional and would be indicated via `ManagedClientConnection.tunnelTarget(boolean, org.apache.http.params.HttpParams)`.

  Parameters:
    `next` - the proxy to which the tunnel was established. This is not the proxy through which the tunnel was established, but the new end point of the tunnel. The tunnel does not yet reach to the target, use `ManagedClientConnection.tunnelTarget(boolean, org.apache.http.params.HttpParams)` to indicate an end-to-end tunnel.
    `secure` - `true` if the connection should be considered secure, `false` otherwise
    `params` - the parameters for tunnelling this connection
  Throws:
    `IOException` - in case of a problem

### layerProtocol

    public void layerProtocol(HttpContext context,
                              HttpParams params)
                       throws IOException

  Description copied from interface: `ManagedClientConnection`
  Layers a new protocol on top of a `tunnelled` connection. This is typically used to create a TLS/SSL connection through a proxy. The route is the one previously passed to `open`. It is not guaranteed that the layered connection is `secure`.

  Parameters:
    `context` - the context for layering on top of this connection
    `params` - the parameters for layering on top of this connection
  Throws:
    `IOException` - in case of a problem

### close

    public void close()
               throws IOException

  Throws:
    `IOException`

### shutdown

    public void shutdown()
                  throws IOException

  Throws:
    `IOException`

### getState

    public Object getState()

  Description copied from interface: `ManagedClientConnection`
  Returns the state object associated with this connection.

  Returns:
    The state object

### setState

    public void setState(Object state)

  Description copied from interface: `ManagedClientConnection`
  Assigns a state object to this connection. Connection managers may make use of the connection state when allocating persistent connections.

  Parameters:
    `state` - The state object

Copyright © 1999-2011 The Apache Software Foundation. All Rights Reserved.