Class DefaultHttpClientHandler
- java.lang.Object
-
- co.arago.hiro.client.connection.httpclient.DefaultHttpClientHandler
-
- All Implemented Interfaces:
HttpClientHandler,java.lang.AutoCloseable
public class DefaultHttpClientHandler extends java.lang.Object implements HttpClientHandler
Class for API httpRequests that contains a HttpClient and a HttpLogger. Wraps around the HttpClient for easier handling on cleanup and using common default parameters.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultHttpClientHandler.Builderstatic classDefaultHttpClientHandler.Conf<T extends DefaultHttpClientHandler.Conf<T>>static classDefaultHttpClientHandler.DefaultProxySpecA simple data class for a proxy-
Nested classes/interfaces inherited from interface co.arago.hiro.client.connection.httpclient.HttpClientHandler
HttpClientHandler.ConfTemplate<T extends HttpClientHandler.ConfTemplate<T>>, HttpClientHandler.ProxySpec
-
-
Field Summary
Fields Modifier and Type Field Description protected static intDEFAULT_MAX_BINARY_LOG_LENGTHprotected static intDEFAULT_MAX_CONNECTION_POOLprotected static longDEFAULT_SHUTDOWN_TIMEOUT
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultHttpClientHandler(DefaultHttpClientHandler.Conf<?> builder)Protected Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Shut thehttpClientdown by shutting down its ExecutorService.HttpLoggergetHttpLogger()java.net.http.HttpClientgetOrBuildClient()ReturnhttpClientor the httpClient of a sharedConnectionHandler if available.static DefaultHttpClientHandler.BuildernewBuilder()
-
-
-
Field Detail
-
DEFAULT_SHUTDOWN_TIMEOUT
protected static final long DEFAULT_SHUTDOWN_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_MAX_BINARY_LOG_LENGTH
protected static final int DEFAULT_MAX_BINARY_LOG_LENGTH
- See Also:
- Constant Field Values
-
DEFAULT_MAX_CONNECTION_POOL
protected static final int DEFAULT_MAX_CONNECTION_POOL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultHttpClientHandler
protected DefaultHttpClientHandler(DefaultHttpClientHandler.Conf<?> builder)
Protected Constructor. Attributes shall be filled via builders.- Parameters:
builder- The builder to use.
-
-
Method Detail
-
newBuilder
public static DefaultHttpClientHandler.Builder newBuilder()
-
getOrBuildClient
public java.net.http.HttpClient getOrBuildClient()
ReturnhttpClientor the httpClient of a sharedConnectionHandler if available. Build a new client if necessary.- Specified by:
getOrBuildClientin interfaceHttpClientHandler- Returns:
- The cached HttpClient
-
close
public void close()
Shut the
httpClientdown by shutting down its ExecutorService. This call will be ignored ifhttpClientAutoCloseis set to false (this happens by default, whenhttpClienthas been provided externally and autoClose is not set manually).Be aware, that there is a shutdown timeout so the Java 11 HttpClient can clean itself up properly. See
DefaultHttpClientHandler.Conf.setShutdownTimeout(long).- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceHttpClientHandler
-
getHttpLogger
public HttpLogger getHttpLogger()
- Specified by:
getHttpLoggerin interfaceHttpClientHandler- Returns:
- The HttpLogger to use with this class.
-
-