Class ConnectionManager
java.lang.Object
com.predic8.membrane.core.transport.http.ConnectionManager
Pools TCP/IP connections, holding them open for a configurable number of milliseconds.
With keep-alive use as follows:
Connection connection = connectionManager.getConnection(...);
try {
...
} finally {
connection.release();
}
Without keep-alive replace Connection.release() by Connection.close().
Note that you should call Connection.release() exactly once, or alternatively
Connection.close() at least once.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetConnection(String host, int port, String localHost, SSLProvider sslProvider, int connectTimeout) getConnection(String host, int port, String localHost, SSLProvider sslProvider, int connectTimeout, String sniServerName, ProxyConfiguration proxy, SSLContext proxySSLContext, String[] applicationProtocols) intvoidreleaseConnection(Connection connection) voidtoString()
-
Constructor Details
-
ConnectionManager
- Parameters:
keepAliveTimeout- milliseconds to keep idle connections around fortimerManager- a TimerManager instance to use to close idle connections. Providing a TimerManager instance prevents the ConnectionManager from creating its own Timer (and TimerManager). Can be null.
-
-
Method Details
-
getConnection
public Connection getConnection(String host, int port, String localHost, SSLProvider sslProvider, int connectTimeout, @Nullable String sniServerName, @Nullable ProxyConfiguration proxy, @Nullable SSLContext proxySSLContext, @Nullable String[] applicationProtocols) throws UnknownHostException, IOException - Throws:
UnknownHostExceptionIOException
-
getConnection
public Connection getConnection(String host, int port, String localHost, SSLProvider sslProvider, int connectTimeout) throws UnknownHostException, IOException - Throws:
UnknownHostExceptionIOException
-
releaseConnection
-
shutdownWhenDone
public void shutdownWhenDone() -
getNumberInPool
public int getNumberInPool() -
toString
-