public class ConnectionManager extends Object
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 and Description |
|---|
ConnectionManager(long keepAliveTimeout) |
| Modifier and Type | Method and Description |
|---|---|
Connection |
getConnection(String host,
int port,
String localHost,
SSLProvider sslProvider,
int connectTimeout) |
Connection |
getConnection(String host,
int port,
String localHost,
SSLProvider sslProvider,
int connectTimeout,
String sniServerName,
ProxyConfiguration proxy,
SSLContext proxySSLContext) |
int |
getNumberInPool() |
void |
releaseConnection(Connection connection) |
void |
shutdownWhenDone() |
String |
toString() |
public Connection getConnection(String host, int port, String localHost, SSLProvider sslProvider, int connectTimeout, @Nullable String sniServerName, @Nullable ProxyConfiguration proxy, @Nullable SSLContext proxySSLContext) throws UnknownHostException, IOException
UnknownHostExceptionIOExceptionpublic Connection getConnection(String host, int port, String localHost, SSLProvider sslProvider, int connectTimeout) throws UnknownHostException, IOException
UnknownHostExceptionIOExceptionpublic void releaseConnection(Connection connection)
public void shutdownWhenDone()
public int getNumberInPool()
Copyright © 2021. All Rights Reserved.