Class ConnectionFactory
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static CloseableHttpConnectioncreateHttpConnection(HttpURLConnection httpConnection, HttpMethod requestMethod, Map<String, String> requestProperties) Create a HTTP or HTTPS connection TherequestMethodandrequestPropertiesare set onto the connection.private static CloseableHttpConnectioncreateHttpConnection(HttpURLConnection httpConnection, HttpMethod requestMethod, Map<String, String> requestProperties, int httpConnectTimeout, int httpReadTimeout) Create a HTTP or HTTPS connection TherequestMethodandrequestPropertiesare set onto the connection.static CloseableConnectionopenConnection(URL url) Opens a connection to an URL.static CloseableConnectionopenConnection(URL url, HttpMethod requestMethod, Map<String, String> requestProperties) Opens a connection to a URL.static CloseableConnectionopenConnection(URL url, HttpMethod requestMethod, Map<String, String> requestProperties, int httpConnectTimeout, int httpReadTimeout) Opens a connection to a URL.static CloseableHttpConnectionopenHttpConnection(URL url, HttpMethod requestMethod, Map<String, String> requestProperties) Opens a connection to a URL.static CloseableHttpConnectionopenHttpConnection(URL url, HttpMethod requestMethod, Map<String, String> requestProperties, int httpConnectTimeout, int httpReadTimeout) Opens a connection to a URL.
-
Constructor Details
-
ConnectionFactory
private ConnectionFactory()
-
-
Method Details
-
openConnection
Opens a connection to an URL.- Parameters:
url- the url to which to open a connection.- Returns:
- the established connection.
- Throws:
IOException- if an I/O exception occurs.
-
openConnection
public static CloseableConnection openConnection(URL url, HttpMethod requestMethod, Map<String, String> requestProperties) throws IOExceptionOpens a connection to a URL.If the URL has HTTP or HTTPS as its protocol than
HttpURLConnectionis opened and therequestMethodandrequestPropertiesare set onto the connection. Otherwise therequestMethodandrequestPropertiesare ignored.- Parameters:
url- the url to which to open a connection. Must have protocol HTTP or HTTPSrequestMethod- the HTTP method to use for the connection.requestProperties- properties to set on the connection.- Returns:
- the established connection.
- Throws:
IOException- if an I/O exception occurs.
-
openConnection
public static CloseableConnection openConnection(URL url, HttpMethod requestMethod, Map<String, String> requestProperties, int httpConnectTimeout, int httpReadTimeout) throws IOExceptionOpens a connection to a URL.If the URL has HTTP or HTTPS as its protocol than
HttpURLConnectionis opened and therequestMethodandrequestPropertiesare set onto the connection. Otherwise therequestMethodandrequestPropertiesare ignored.- Parameters:
url- the url to which to open a connection. Must have protocol HTTP or HTTPSrequestMethod- the HTTP method to use for the connection.requestProperties- properties to set on the connection.httpConnectTimeout-httpReadTimeout-- Returns:
- the established connection.
- Throws:
IOException- if an I/O exception occurs.
-
openHttpConnection
public static CloseableHttpConnection openHttpConnection(URL url, HttpMethod requestMethod, Map<String, String> requestProperties) throws IOExceptionOpens a connection to a URL.If the URL has not HTTP or HTTPS as its protocol a
IllegalArgumentExceptionis thrown. Otherwise therequestMethodandrequestPropertiesare set onto the connection.- Parameters:
url- the url to which to open a connection. Must have protocol HTTP or HTTPSrequestMethod- the HTTP method to use for the connection.requestProperties- properties to set on the connection.- Returns:
- the established connection.
- Throws:
IOException- if an I/O exception occurs.
-
openHttpConnection
public static CloseableHttpConnection openHttpConnection(URL url, HttpMethod requestMethod, Map<String, String> requestProperties, int httpConnectTimeout, int httpReadTimeout) throws IOExceptionOpens a connection to a URL.If the URL has not HTTP or HTTPS as its protocol a
IllegalArgumentExceptionis thrown. Otherwise therequestMethodandrequestPropertiesare set onto the connection.- Parameters:
url- the url to which to open a connection. Must have protocol HTTP or HTTPSrequestMethod- the HTTP method to use for the connection.requestProperties- properties to set on the connection.httpConnectTimeout-httpReadTimeout-- Returns:
- the established connection.
- Throws:
IOException- if an I/O exception occurs.
-
createHttpConnection
private static CloseableHttpConnection createHttpConnection(HttpURLConnection httpConnection, HttpMethod requestMethod, Map<String, String> requestProperties) throws IOExceptionCreate a HTTP or HTTPS connection TherequestMethodandrequestPropertiesare set onto the connection.- Parameters:
httpConnection- the connection to wrap.requestMethod- the HTTP method to use for the connection.requestProperties- properties to set on the connection.- Returns:
- the established connection.
- Throws:
IOException- if an I/O exception occurs.
-
createHttpConnection
private static CloseableHttpConnection createHttpConnection(HttpURLConnection httpConnection, HttpMethod requestMethod, Map<String, String> requestProperties, int httpConnectTimeout, int httpReadTimeout) throws IOExceptionCreate a HTTP or HTTPS connection TherequestMethodandrequestPropertiesare set onto the connection.- Parameters:
httpConnection- the connection to wrap.requestMethod- the HTTP method to use for the connection.requestProperties- properties to set on the connection.httpConnectTimeout-httpReadTimeout-- Returns:
- the established connection.
- Throws:
IOException- if an I/O exception occurs.
-