com.ning.http.client.providers.grizzly
Class GrizzlyConnectionsPool

java.lang.Object
  extended by com.ning.http.client.providers.grizzly.GrizzlyConnectionsPool
All Implemented Interfaces:
ConnectionsPool<String,org.glassfish.grizzly.Connection>

public class GrizzlyConnectionsPool
extends Object
implements ConnectionsPool<String,org.glassfish.grizzly.Connection>

ConnectionsPool implementation.

Since:
1.7.0
Author:
The Grizzly Team

Nested Class Summary
static class GrizzlyConnectionsPool.DelayedExecutor
           
 
Constructor Summary
GrizzlyConnectionsPool(AsyncHttpClientConfig config)
           
GrizzlyConnectionsPool(boolean cacheSSLConnections, int timeout, int maxConnectionLifeTimeInMs, int maxConnectionsPerHost, int maxConnections, GrizzlyConnectionsPool.DelayedExecutor delayedExecutor)
           
 
Method Summary
 boolean canCacheConnection()
          Return true if a connection can be cached.
 void destroy()
          Destroy all connections that has been cached by this instance.
 boolean offer(String uri, org.glassfish.grizzly.Connection connection)
          Add a connection tpo the pool
 org.glassfish.grizzly.Connection poll(String uri)
          Remove the connection associated with the uri.
 boolean removeAll(org.glassfish.grizzly.Connection connection)
          Remove all connections from the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GrizzlyConnectionsPool

public GrizzlyConnectionsPool(boolean cacheSSLConnections,
                              int timeout,
                              int maxConnectionLifeTimeInMs,
                              int maxConnectionsPerHost,
                              int maxConnections,
                              GrizzlyConnectionsPool.DelayedExecutor delayedExecutor)

GrizzlyConnectionsPool

public GrizzlyConnectionsPool(AsyncHttpClientConfig config)
Method Detail

offer

public boolean offer(String uri,
                     org.glassfish.grizzly.Connection connection)
Add a connection tpo the pool

Specified by:
offer in interface ConnectionsPool<String,org.glassfish.grizzly.Connection>
Parameters:
uri - a uri used to retrieve the cached connection
connection - an I/O connection
Returns:
true if added.

poll

public org.glassfish.grizzly.Connection poll(String uri)
Remove the connection associated with the uri.

Specified by:
poll in interface ConnectionsPool<String,org.glassfish.grizzly.Connection>
Parameters:
uri - the uri used when invoking addConnection
Returns:
the connection associated with the uri

removeAll

public boolean removeAll(org.glassfish.grizzly.Connection connection)
Remove all connections from the cache. A connection might have been associated with several uri.

Specified by:
removeAll in interface ConnectionsPool<String,org.glassfish.grizzly.Connection>
Parameters:
connection - a connection
Returns:
the true if the connection has been removed

canCacheConnection

public 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 ConnectionsPool.offer(Object, Object)

Specified by:
canCacheConnection in interface ConnectionsPool<String,org.glassfish.grizzly.Connection>
Returns:
true if a connection can be cached.

destroy

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

Specified by:
destroy in interface ConnectionsPool<String,org.glassfish.grizzly.Connection>


Copyright © 2014. All Rights Reserved.