Package co.arago.hiro.client.connection
Class AbstractAPIHandler.Conf<T extends AbstractAPIHandler.Conf<T>>
- java.lang.Object
-
- co.arago.hiro.client.connection.AbstractAPIHandler.Conf<T>
-
- Type Parameters:
T- The type of the Builder
- All Implemented Interfaces:
HttpClientHandler.ConfTemplate<T>
- Direct Known Subclasses:
AbstractVersionAPIHandler.Conf
- Enclosing class:
- AbstractAPIHandler
public abstract static class AbstractAPIHandler.Conf<T extends AbstractAPIHandler.Conf<T>> extends java.lang.Object implements HttpClientHandler.ConfTemplate<T>
The basic configuration for all APIHAndler. This also integrates the configuration for a default HttpClientHandler.
-
-
Constructor Summary
Constructors Constructor Description Conf()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract AbstractAPIHandlerbuild()java.lang.BooleangetAcceptAllCerts()java.lang.LonggetConnectTimeout()java.net.CookieManagergetCookieManager()java.net.http.HttpClientgetHttpClient()java.lang.BooleangetHttpClientAutoClose()HttpClientHandlergetHttpClientHandler()java.lang.LonggetHttpRequestTimeout()intgetMaxBinaryLogLength()intgetMaxConnectionPool()intgetMaxRetries()HttpClientHandler.ProxySpecgetProxy()java.net.URIgetRootApiURI()longgetShutdownTimeout()javax.net.ssl.SSLContextgetSslContext()javax.net.ssl.SSLParametersgetSslParameters()java.lang.StringgetUserAgent()java.net.URIgetWebSocketURI()booleanisFollowRedirects()protected abstract Tself()TsetAcceptAllCerts(java.lang.Boolean acceptAllCerts)Skip SSL certificate verification.TsetConnectTimeout(java.lang.Long connectTimeout)TsetCookieManager(java.net.CookieManager cookieManager)Instance of an externally configured CookieManager.TsetFollowRedirects(boolean followRedirects)TsetHttpClient(java.net.http.HttpClient httpClient)Instance of an externally configured http client.TsetHttpClientAutoClose(boolean httpClientAutoClose)Close internal httpClient automatically, even when it has been set externally.TsetHttpClientHandler(HttpClientHandler httpClientHandler)Sets the httpClientHandler for the backend connection.TsetHttpRequestTimeout(java.lang.Long httpRequestTimeout)TsetMaxBinaryLogLength(int maxBinaryLogLength)Maximum size to log binary data in logfiles.TsetMaxConnectionPool(int maxConnectionPool)Set the maximum of open connections for this HttpClient (This sets the fixedThreadPool for the Executor of the HttpClient).TsetMaxRetries(int maxRetries)TsetProxy(HttpClientHandler.ProxySpec proxy)TsetRootApiURI(java.lang.String rootApiURI)TsetRootApiURI(java.net.URI rootApiURI)TsetShutdownTimeout(long shutdownTimeout)TsetSslContext(javax.net.ssl.SSLContext sslContext)TsetSslParameters(javax.net.ssl.SSLParameters sslParameters)TsetUserAgent(java.lang.String userAgent)For header "User-Agent".TsetWebSocketURI(java.lang.String webSocketURI)TsetWebSocketURI(java.net.URI apiURI)
-
-
-
Method Detail
-
getRootApiURI
public java.net.URI getRootApiURI()
-
getWebSocketURI
public java.net.URI getWebSocketURI()
-
setRootApiURI
public T setRootApiURI(java.lang.String rootApiURI) throws java.net.URISyntaxException
- Parameters:
rootApiURI- The root url for the API- Returns:
self()- Throws:
java.net.URISyntaxException- When the rootApiURI is malformed.
-
setRootApiURI
public T setRootApiURI(java.net.URI rootApiURI)
- Parameters:
rootApiURI- The root uri for the API- Returns:
self()
-
setWebSocketURI
public T setWebSocketURI(java.lang.String webSocketURI) throws java.net.URISyntaxException
- Parameters:
webSocketURI- The root uri for the WebSockets. If this is missing, the uri will be constructed from an apiUrl.- Returns:
self()- Throws:
java.net.URISyntaxException- When the webSocketURI is a malformed URI.
-
setWebSocketURI
public T setWebSocketURI(java.net.URI apiURI)
- Parameters:
apiURI- The root url for the WebSockets- Returns:
self()
-
getUserAgent
public java.lang.String getUserAgent()
-
setUserAgent
public T setUserAgent(java.lang.String userAgent)
For header "User-Agent". Default is determined by the package.- Parameters:
userAgent- The line for the User-Agent header.- Returns:
self()
-
getHttpRequestTimeout
public java.lang.Long getHttpRequestTimeout()
-
setHttpRequestTimeout
public T setHttpRequestTimeout(java.lang.Long httpRequestTimeout)
- Parameters:
httpRequestTimeout- Request timeout in ms.- Returns:
self()
-
getMaxRetries
public int getMaxRetries()
-
setMaxRetries
public T setMaxRetries(int maxRetries)
- Parameters:
maxRetries- Max amount of retries when http errors are received. The default is 0.- Returns:
self()
-
getHttpClientHandler
public HttpClientHandler getHttpClientHandler()
-
setHttpClientHandler
public T setHttpClientHandler(HttpClientHandler httpClientHandler)
Sets the httpClientHandler for the backend connection. This handler will be shared among all APIHandlers that use this configuration instance.
Setting this handler means, that no DefaultHttpClientHandler will be created internally. All configuration options that are used for the internal handler will be ignored.
- Parameters:
httpClientHandler- The connection handler to use.- Returns:
self()- See Also:
HttpClientHandler.ConfTemplate
-
getProxy
public HttpClientHandler.ProxySpec getProxy()
- Specified by:
getProxyin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>
-
setProxy
public T setProxy(HttpClientHandler.ProxySpec proxy)
- Specified by:
setProxyin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>- Parameters:
proxy- Simple proxy with one address and port- Returns:
self()- Implementation Note:
- Configuration option for an internal DefaultHttpClientHandler. Will be ignored if the
httpClientHandleris set directly viasetHttpClientHandler(HttpClientHandler).
-
isFollowRedirects
public boolean isFollowRedirects()
- Specified by:
isFollowRedirectsin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>
-
setFollowRedirects
public T setFollowRedirects(boolean followRedirects)
- Specified by:
setFollowRedirectsin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>- Parameters:
followRedirects- Enable Redirect.NORMAL. Default is true.- Returns:
self()- Implementation Note:
- Configuration option for an internal DefaultHttpClientHandler. Will be ignored if the
httpClientHandleris set directly viasetHttpClientHandler(HttpClientHandler).
-
getConnectTimeout
public java.lang.Long getConnectTimeout()
- Specified by:
getConnectTimeoutin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>
-
setConnectTimeout
public T setConnectTimeout(java.lang.Long connectTimeout)
- Specified by:
setConnectTimeoutin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>- Parameters:
connectTimeout- Connect timeout in milliseconds.- Returns:
self()- Implementation Note:
- Configuration option for an internal DefaultHttpClientHandler. Will be ignored if the
httpClientHandleris set directly viasetHttpClientHandler(HttpClientHandler).
-
getShutdownTimeout
public long getShutdownTimeout()
- Specified by:
getShutdownTimeoutin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>
-
setShutdownTimeout
public T setShutdownTimeout(long shutdownTimeout)
- Specified by:
setShutdownTimeoutin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>- Parameters:
shutdownTimeout- Time to wait in milliseconds for a complete shutdown of the Java 11 HttpClientImpl. If this is set to a value too low, you might need to wait elsewhere for the HttpClient to shut down properly. Default is 3000ms.- Returns:
self()- Implementation Note:
- Configuration option for an internal DefaultHttpClientHandler. Will be ignored if the
httpClientHandleris set directly viasetHttpClientHandler(HttpClientHandler).
-
getAcceptAllCerts
public java.lang.Boolean getAcceptAllCerts()
- Specified by:
getAcceptAllCertsin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>
-
setAcceptAllCerts
public T setAcceptAllCerts(java.lang.Boolean acceptAllCerts)
Skip SSL certificate verification. Leave this unset to use the default in HttpClient. Setting this to true installs a permissive SSLContext, setting it to false removes the SSLContext to use the default.- Specified by:
setAcceptAllCertsin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>- Parameters:
acceptAllCerts- the toggle- Returns:
self()- Implementation Note:
- Configuration option for an internal DefaultHttpClientHandler. Will be ignored if the
httpClientHandleris set directly viasetHttpClientHandler(HttpClientHandler).
-
getSslContext
public javax.net.ssl.SSLContext getSslContext()
- Specified by:
getSslContextin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>
-
setSslContext
public T setSslContext(javax.net.ssl.SSLContext sslContext)
- Specified by:
setSslContextin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>- Parameters:
sslContext- The specific SSLContext to use.- Returns:
self()- See Also:
setAcceptAllCerts(Boolean)- Implementation Note:
- Configuration option for an internal DefaultHttpClientHandler. Will be ignored if the
httpClientHandleris set directly viasetHttpClientHandler(HttpClientHandler).
-
getSslParameters
public javax.net.ssl.SSLParameters getSslParameters()
- Specified by:
getSslParametersin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>
-
setSslParameters
public T setSslParameters(javax.net.ssl.SSLParameters sslParameters)
- Specified by:
setSslParametersin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>- Parameters:
sslParameters- The specific SSLParameters to use.- Returns:
self()- Implementation Note:
- Configuration option for an internal DefaultHttpClientHandler. Will be ignored if the
httpClientHandleris set directly viasetHttpClientHandler(HttpClientHandler).
-
getHttpClient
public java.net.http.HttpClient getHttpClient()
- Specified by:
getHttpClientin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>
-
setHttpClient
public T setHttpClient(java.net.http.HttpClient httpClient)
Instance of an externally configured http client. An internal HttpClient will be built with parameters given by this Builder if this is not set.- Specified by:
setHttpClientin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>- Parameters:
httpClient- Instance of an HttpClient.- Returns:
self()- Implementation Note:
- Configuration option for an internal DefaultHttpClientHandler. Will be ignored if the
httpClientHandleris set directly viasetHttpClientHandler(HttpClientHandler).
Be aware, that any httpClient given via this method will set AutoClose to false and has to be closed externally, unlesssetHttpClientAutoClose(boolean)is used. A call toHttpClientHandler.close()with AutoClose set to false will have no effect.
-
getCookieManager
public java.net.CookieManager getCookieManager()
- Specified by:
getCookieManagerin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>
-
setCookieManager
public T setCookieManager(java.net.CookieManager cookieManager)
Instance of an externally configured CookieManager. An internal CookieManager will be built if this is not set.- Specified by:
setCookieManagerin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>- Parameters:
cookieManager- Instance of a CookieManager.- Returns:
self()- Implementation Note:
- Configuration option for an internal DefaultHttpClientHandler. Will be ignored if the
httpClientHandleris set directly viasetHttpClientHandler(HttpClientHandler).
-
getMaxConnectionPool
public int getMaxConnectionPool()
- Specified by:
getMaxConnectionPoolin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>
-
setMaxConnectionPool
public T setMaxConnectionPool(int maxConnectionPool)
Set the maximum of open connections for this HttpClient (This sets the fixedThreadPool for the Executor of the HttpClient).- Specified by:
setMaxConnectionPoolin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>- Parameters:
maxConnectionPool- Maximum size of the pool. Default is 8.- Returns:
self()- Implementation Note:
- Configuration option for an internal DefaultHttpClientHandler. Will be ignored if the
httpClientHandleris set directly viasetHttpClientHandler(HttpClientHandler).
-
getMaxBinaryLogLength
public int getMaxBinaryLogLength()
- Specified by:
getMaxBinaryLogLengthin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>
-
setMaxBinaryLogLength
public T setMaxBinaryLogLength(int maxBinaryLogLength)
Maximum size to log binary data in logfiles. Default is 1024.- Specified by:
setMaxBinaryLogLengthin interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>- Parameters:
maxBinaryLogLength- Size in bytes- Returns:
self()- Implementation Note:
- Configuration option for an internal DefaultHttpClientHandler. Will be ignored if the
httpClientHandleris set directly viasetHttpClientHandler(HttpClientHandler).
-
getHttpClientAutoClose
public java.lang.Boolean getHttpClientAutoClose()
- Specified by:
getHttpClientAutoClosein interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>
-
setHttpClientAutoClose
public T setHttpClientAutoClose(boolean httpClientAutoClose)
Close internal httpClient automatically, even when it has been set externally.
The default is to close the internal httpClient when it has been created internally and to not close the internal httpClient when it has been set via
setHttpClient(HttpClient)- Specified by:
setHttpClientAutoClosein interfaceHttpClientHandler.ConfTemplate<T extends AbstractAPIHandler.Conf<T>>- Parameters:
httpClientAutoClose- true: enable, false: disable.- Returns:
self()- Implementation Note:
- Configuration option for an internal DefaultHttpClientHandler. Will be ignored if the
httpClientHandleris set directly viasetHttpClientHandler(HttpClientHandler).
-
self
protected abstract T self()
-
build
public abstract AbstractAPIHandler build()
-
-