java.lang.Object
de.cuioss.portal.restclient.CuiRestClientBuilder
Builder for a JAVA MicroProfile based REST client.
To enable log debugging / tracing set package de.cuioss.portal.core.restclient to TRACE level in your logger configuration.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCuiRestClientBuilder(de.cuioss.tools.logging.CuiLogger logger) Creates a REST client builder. -
Method Summary
Modifier and TypeMethodDescriptionAdds the credentials for basic-authbearerAuthToken(String token) Adds the credentials for bearer-auth<T extends Closeable>
TCreate an implementation of the service interface T using the rest client.connectionMetadata(de.cuioss.portal.configuration.connections.impl.ConnectionMetadata connectionMeta) Sets various properties based on the givenconnectionMeta.connectTimeout(long amount, TimeUnit timeUnit) Adds the connection timeoutstatic voiddebugResponse(Response response, de.cuioss.tools.logging.CuiLogger log) Debugs a given Response to the given loggerDisables the RestEasy default exception mapper for this MP REST client.Enables the RestEasy default exception mapper for this MP REST client.followRedirects(boolean followRedirects) Adds the followRedirectshostnameVerifier(HostnameVerifier hostnameVerifier) Adds the hostnameVerifierproxyAddress(String host, int port) Adds the proxy addressqueryParamStyle(org.eclipse.microprofile.rest.client.ext.QueryParamStyle queryParamStyle) Adds the QueryParamStylereadTimeout(long amount, TimeUnit timeUnit) Adds the read timeoutregisterExceptionMapper(org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper<?> mapper) Adds the ResponseExceptionMappersslContext(SSLContext sslContext) Adds the sslContexttraceLogEnabled(boolean value) Adds the target uriAdds the target urlAdds the target url
-
Field Details
-
RESPONSE_EXCEPTION_MAPPER
- See Also:
-
-
Constructor Details
-
CuiRestClientBuilder
Creates a REST client builder.Enables the trace-logging, if either the given logger or the
CuiRestClientBuilderlogger returns true forCuiLogger.isTraceEnabled().- Parameters:
logger- for trace-logging.
-
-
Method Details
-
debugResponse
Debugs a given Response to the given logger- Parameters:
response- must not be nulllog- must not be null
-
connectionMetadata
public CuiRestClientBuilder connectionMetadata(de.cuioss.portal.configuration.connections.impl.ConnectionMetadata connectionMeta) Sets various properties based on the givenconnectionMeta.- service url
- tracing enabled
- ssl context
- login credentials
- context map
- hostname verifier
- connection timeout
- read timeout
- Returns:
- this builder
-
traceLogEnabled
- Parameters:
value- Enable|Disable trace logging capabilities for this REST client. Defaults toCuiLogger.isTraceEnabled()for the given logger. This is unrelated to the distributed tracing capabilities.- Returns:
- this builder
- See Also:
-
LogClientRequestFilterLogReaderInterceptor
-
register
- Parameters:
component- to be registered- Returns:
- this builder
- See Also:
-
register
- Parameters:
component- to be registeredpriority- overwrite value for the componentsPriority- Returns:
- this builder
- See Also:
-
property
- Parameters:
key- property key to be registeredvalue- property value to be registered- Returns:
- this builder
- See Also:
-
enableDefaultExceptionHandler
Enables the RestEasy default exception mapper for this MP REST client. Per default, this exception mapper is disabled. It registers it with priorityInteger.MIN_VALUE, instead ofInteger.MAX_VALUE, to allow trace-logging of responses.Effect: Every response code of >=400 throws a general
WebApplicationException.- Returns:
- this builder
-
disableDefaultExceptionHandler
Disables the RestEasy default exception mapper for this MP REST client. Per default, this exception mapper is disabled.Effect: Exceptions like
BadRequestExceptionare thrown instead of a generalWebApplicationException.- Returns:
- this builder
-
url
Adds the target url- Parameters:
url- to be passed to he contained builder- Returns:
- this builder
-
url
Adds the target url- Parameters:
url- to be passed to he contained builder- Returns:
- this builder
-
uri
Adds the target uri- Parameters:
uri- to be passed to he contained builder- Returns:
- this builder
-
basicAuth
Adds the credentials for basic-auth- Parameters:
username- to be passed to he contained builderpassword- to be passed to he contained builder- Returns:
- this builder
-
bearerAuthToken
Adds the credentials for bearer-auth- Parameters:
token- to be passed to he contained builder- Returns:
- this builder
-
registerExceptionMapper
public CuiRestClientBuilder registerExceptionMapper(org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper<?> mapper) Adds the ResponseExceptionMapper- Parameters:
mapper- to be passed to he contained builder- Returns:
- this builder
-
sslContext
Adds the sslContext- Parameters:
sslContext- to be passed to he contained builder- Returns:
- this builder
-
connectTimeout
Adds the connection timeout- Parameters:
amount- to be passed to he contained buildertimeUnit- to be passed to he contained builder- Returns:
- this builder
-
readTimeout
Adds the read timeout- Parameters:
amount- to be passed to he contained buildertimeUnit- to be passed to he contained builder- Returns:
- this builder
-
queryParamStyle
public CuiRestClientBuilder queryParamStyle(org.eclipse.microprofile.rest.client.ext.QueryParamStyle queryParamStyle) Adds the QueryParamStyle- Parameters:
queryParamStyle- to be passed to he contained builder- Returns:
- this builder
-
proxyAddress
Adds the proxy address- Parameters:
host- to be passed to he contained builderport- to be passed to he contained builder- Returns:
- this builder
-
followRedirects
Adds the followRedirects- Parameters:
followRedirects- to be passed to he contained builder- Returns:
- this builder
-
hostnameVerifier
Adds the hostnameVerifier- Parameters:
hostnameVerifier- to be passed to he contained builder- Returns:
- this builder
-
getConfiguration
- Returns:
- the current configuration of the contained builder
-
build
Create an implementation of the service interface T using the rest client.- Type Parameters:
T- the service type- Parameters:
clazz- the service interface which also must extendCloseable- Returns:
- T the service class
-