public class DefaultConnection extends Object implements PooledConnection
Connection implementation based on HttpClient.| Modifier and Type | Field and Description |
|---|---|
protected org.apache.http.impl.client.CloseableHttpClient |
httpClient |
protected org.apache.http.client.config.RequestConfig |
requestConfig |
| Constructor and Description |
|---|
DefaultConnection() |
DefaultConnection(int connectTimeout,
int socketTimeout)
Creates a new connection with the given timeouts, the default number of maximum connections, no proxy and the default HTTPS protocols.
|
DefaultConnection(int connectTimeout,
int socketTimeout,
int maxConnections)
Creates a new connection with the given timeouts and number of maximum connections, no proxy and the default HTTPS protocols.
|
DefaultConnection(int connectTimeout,
int socketTimeout,
int maxConnections,
ProxyConfiguration proxyConfiguration)
Creates a new connection with the given timeouts, number of maximum connections and proxy configuration, and the default HTTPS protocols.
|
DefaultConnection(int connectTimeout,
int socketTimeout,
int maxConnections,
ProxyConfiguration proxyConfiguration,
Set<String> httpsProtocols)
Creates a new connection with the given timeouts, number of maximum connections, proxy configuration and HTTPS protocols.
|
DefaultConnection(int connectTimeout,
int socketTimeout,
int maxConnections,
ProxyConfiguration proxyConfiguration,
org.apache.http.conn.ssl.SSLConnectionSocketFactory sslConnectionSocketFactory)
Creates a new connection with the given timeouts, number of maximum connections, proxy configuration and SSL connection socket factory.
|
DefaultConnection(int connectTimeout,
int socketTimeout,
ProxyConfiguration proxyConfiguration)
Creates a new connection with the given timeouts and proxy configuration, the default number of maximum connections and the default HTTPS protocols.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addHeaders(org.apache.http.client.methods.HttpRequestBase httpRequestBase,
List<RequestHeader> requestHeaders) |
void |
close()
Releases any system resources associated with this object.
|
void |
closeExpiredConnections()
Closes all expired HTTP connections.
|
void |
closeIdleConnections(long idleTime,
TimeUnit timeUnit)
Closes all HTTP connections that have been idle for the specified time.
|
<R> R |
delete(URI uri,
List<RequestHeader> requestHeaders,
ResponseHandler<R> responseHandler)
Send a DELETE request to the Online Payments platform.
|
void |
disableLogging()
Turns off logging.
|
void |
enableLogging(CommunicatorLogger communicatorLogger)
Turns on logging using the given communicator logger.
|
protected <R> R |
executeRequest(org.apache.http.client.methods.HttpUriRequest request,
ResponseHandler<R> responseHandler) |
<R> R |
get(URI uri,
List<RequestHeader> requestHeaders,
ResponseHandler<R> responseHandler)
Send a GET request to the Online Payments platform.
|
protected List<ResponseHeader> |
getHeaders(org.apache.http.HttpResponse httpResponse) |
<R> R |
post(URI uri,
List<RequestHeader> requestHeaders,
String body,
ResponseHandler<R> responseHandler)
Send a POST request to the Online Payments platform.
|
<R> R |
put(URI uri,
List<RequestHeader> requestHeaders,
String body,
ResponseHandler<R> responseHandler)
Send a PUT request to the Online Payments platform.
|
protected final org.apache.http.impl.client.CloseableHttpClient httpClient
protected final org.apache.http.client.config.RequestConfig requestConfig
public DefaultConnection()
public DefaultConnection(int connectTimeout,
int socketTimeout)
public DefaultConnection(int connectTimeout,
int socketTimeout,
int maxConnections)
public DefaultConnection(int connectTimeout,
int socketTimeout,
ProxyConfiguration proxyConfiguration)
public DefaultConnection(int connectTimeout,
int socketTimeout,
int maxConnections,
ProxyConfiguration proxyConfiguration)
public DefaultConnection(int connectTimeout,
int socketTimeout,
int maxConnections,
ProxyConfiguration proxyConfiguration,
Set<String> httpsProtocols)
public DefaultConnection(int connectTimeout,
int socketTimeout,
int maxConnections,
ProxyConfiguration proxyConfiguration,
org.apache.http.conn.ssl.SSLConnectionSocketFactory sslConnectionSocketFactory)
public void close()
throws IOException
Connectionclose in interface Connectionclose in interface Closeableclose in interface AutoCloseableIOExceptionpublic <R> R get(URI uri, List<RequestHeader> requestHeaders, ResponseHandler<R> responseHandler)
Connectionget in interface Connectionuri - The URI to call, including any necessary query parameters.requestHeaders - An optional list of request headers.responseHandler - A handler for the response.public <R> R delete(URI uri, List<RequestHeader> requestHeaders, ResponseHandler<R> responseHandler)
Connectiondelete in interface Connectionuri - The URI to call, including any necessary query parameters.requestHeaders - An optional list of request headers.responseHandler - A handler for the response.public <R> R post(URI uri, List<RequestHeader> requestHeaders, String body, ResponseHandler<R> responseHandler)
Connectionpost in interface Connectionuri - The URI to call, including any necessary query parameters.requestHeaders - An optional list of request headers.body - The optional body to send.responseHandler - A handler for the response.public <R> R put(URI uri, List<RequestHeader> requestHeaders, String body, ResponseHandler<R> responseHandler)
Connectionput in interface Connectionuri - The URI to call, including any necessary query parameters.requestHeaders - An optional list of request headers.body - The optional body to send.responseHandler - A handler for the response.protected <R> R executeRequest(org.apache.http.client.methods.HttpUriRequest request,
ResponseHandler<R> responseHandler)
protected void addHeaders(org.apache.http.client.methods.HttpRequestBase httpRequestBase,
List<RequestHeader> requestHeaders)
protected List<ResponseHeader> getHeaders(org.apache.http.HttpResponse httpResponse)
public void closeIdleConnections(long idleTime,
TimeUnit timeUnit)
PooledConnectioncloseIdleConnections in interface PooledConnectionPooledConnection.closeExpiredConnections()public void closeExpiredConnections()
PooledConnectioncloseExpiredConnections in interface PooledConnectionpublic void enableLogging(CommunicatorLogger communicatorLogger)
LoggingCapableenableLogging in interface LoggingCapablepublic void disableLogging()
LoggingCapabledisableLogging in interface LoggingCapableCopyright © 2023 Worldline Online Payments Direct. All rights reserved.