com.ning.http.client
Interface ConnectionsPool<U,V>

All Known Implementing Classes:
NettyConnectionsPool

public interface ConnectionsPool<U,V>

An interface used by an AsyncHttpProvider for caching http connections.


Method Summary
 boolean addConnection(U uri, V connection)
          Add a connection tpo the pool
 boolean canCacheConnection()
          Return true if a connection can be cached.
 void destroy()
          Destroy all connections that has been cached by this instance.
 V getConnection(U uri)
          Return the connection associated with the uri
 boolean removeAllConnections(V connection)
          Remove all connections from the cache.
 V removeConnection(U uri)
          Remove the connection associated with the uri.
 

Method Detail

addConnection

boolean addConnection(U uri,
                      V connection)
Add a connection tpo the pool

Parameters:
uri - a uri used to retrieve the cached connection
connection - an I/O connection
Returns:
true if added.

getConnection

V getConnection(U uri)
Return the connection associated with the uri

Parameters:
uri - the uri used when invoking addConnection
Returns:
the connection associated with the uri

removeConnection

V removeConnection(U uri)
Remove the connection associated with the uri.

Parameters:
uri - the uri used when invoking addConnection
Returns:
the connection associated with the uri

removeAllConnections

boolean removeAllConnections(V connection)
Remove all connections from the cache. A connection might have been associated with several uri.

Parameters:
connection - a connection
Returns:
the true if the connection has been removed

canCacheConnection

boolean canCacheConnection()
Return true if a connection can be cached. A implementation can decide based on some rules to allow caching Calling this method is equivalent of checking the returned value of addConnection(Object, Object)

Returns:
true if a connection can be cached.

destroy

void destroy()
Destroy all connections that has been cached by this instance.



Copyright © 2010. All Rights Reserved.