Package org.jboss.resteasy.client.jaxrs
Class ResteasyClientBuilder
- java.lang.Object
-
- javax.ws.rs.client.ClientBuilder
-
- org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder
-
- All Implemented Interfaces:
javax.ws.rs.core.Configurable<javax.ws.rs.client.ClientBuilder>
- Direct Known Subclasses:
ResteasyClientBuilderImpl
public abstract class ResteasyClientBuilder extends javax.ws.rs.client.ClientBuilder
Abstraction for creating Clients. Allows SSL configuration. Uses Apache Http Client under the covers. If used with other ClientHttpEngines though, all configuration options are ignored.- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ResteasyClientBuilder.HostnameVerificationPolicy
-
Field Summary
Fields Modifier and Type Field Description static String
PROPERTY_PROXY_HOST
Client properties to enable proxy.static String
PROPERTY_PROXY_PORT
Proxy port property name (integer).static String
PROPERTY_PROXY_SCHEME
Proxy scheme property name (string).
-
Constructor Summary
Constructors Constructor Description ResteasyClientBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract ResteasyClient
build()
abstract ResteasyClientBuilder
connectionCheckoutTimeout(long timeout, TimeUnit unit)
If connection pooling is enabled, how long will we wait to get a connection?abstract ResteasyClientBuilder
connectionPoolSize(int connectionPoolSize)
Number of connections allowed to pool.abstract ResteasyClientBuilder
connectionTTL(long ttl, TimeUnit unit)
If there is a connection pool, set the time to live in the pool.abstract ResteasyClientBuilder
connectTimeout(long timeout, TimeUnit unit)
abstract ResteasyClientBuilder
defaultProxy(String hostname)
Specify a default proxy.abstract ResteasyClientBuilder
defaultProxy(String hostname, int port)
Specify a default proxy host and port.abstract ResteasyClientBuilder
defaultProxy(String hostname, int port, String scheme)
Specify default proxy.abstract ResteasyClientBuilder
disableAutomaticRetries()
boolean, notify apache to disable its automatic retries.abstract ResteasyClientBuilder
disableTrustManager()
Disable trust management and hostname verification.abstract ResteasyClientBuilder
enableCookieManagement()
Enable state (cookie) management.abstract ResteasyClientBuilder
executorService(ExecutorService executorService)
abstract ResteasyClientBuilder
executorService(ExecutorService executorService, boolean cleanupExecutor)
abstract long
getConnectionCheckoutTimeout(TimeUnit unit)
abstract int
getConnectionPoolSize()
abstract long
getConnectionTimeout(TimeUnit unit)
abstract long
getConnectionTTL(TimeUnit unit)
abstract String
getDefaultProxyHostname()
abstract int
getDefaultProxyPort()
abstract String
getDefaultProxyScheme()
abstract ResteasyClientBuilder.HostnameVerificationPolicy
getHostnameVerification()
abstract HostnameVerifier
getHostnameVerifier()
abstract ClientHttpEngine
getHttpEngine()
abstract KeyStore
getKeyStore()
abstract String
getKeyStorePassword()
abstract int
getMaxPooledPerRoute()
abstract ResteasyProviderFactory
getProviderFactory()
abstract long
getReadTimeout(TimeUnit unit)
abstract int
getResponseBufferSize()
abstract List<String>
getSniHostNames()
abstract SSLContext
getSSLContext()
abstract KeyStore
getTrustStore()
abstract ResteasyClientBuilder
hostnameVerification(ResteasyClientBuilder.HostnameVerificationPolicy policy)
SSL policy used to verify hostnamesabstract ResteasyClientBuilder
hostnameVerifier(HostnameVerifier verifier)
abstract ResteasyClientBuilder
httpEngine(ClientHttpEngine httpEngine)
Negates all ssl and connection specific configurationabstract boolean
isCookieManagementEnabled()
abstract boolean
isDisableAutomaticRetries()
abstract boolean
isFollowRedirects()
abstract boolean
isTrustManagerDisabled()
abstract boolean
isTrustSelfSignedCertificates()
abstract boolean
isUseAsyncHttpEngine()
abstract ResteasyClientBuilder
keyStore(KeyStore keyStore, char[] password)
abstract ResteasyClientBuilder
keyStore(KeyStore keyStore, String password)
abstract ResteasyClientBuilder
maxPooledPerRoute(int maxPooledPerRoute)
If connection pooling enabled, how many connections to pool per url?abstract ResteasyClientBuilder
providerFactory(ResteasyProviderFactory providerFactory)
Changing the providerFactory will wipe clean any registered components or properties.abstract ResteasyClientBuilder
readTimeout(long timeout, TimeUnit unit)
abstract ResteasyClientBuilder
responseBufferSize(int size)
Response stream is wrapped in a BufferedInputStream.abstract ResteasyClientBuilder
scheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
abstract ResteasyClientBuilder
setFollowRedirects(boolean followRedirects)
Follow redirects added for MicroProfile-rest-client but can be used by tradition clients as well.abstract void
setIsTrustSelfSignedCertificates(boolean b)
When the user is not using a TrustManager (see disableTrustManager) and does not define an SSLContext object but they want all defined trustStores to use the TrustSelfSignedCertificates trust strategy set this value to true.abstract ResteasyClientBuilder
sniHostNames(String... sniHostNames)
Adds a TLS/SSL SNI Host Name for authentication.abstract ResteasyClientBuilder
sslContext(SSLContext sslContext)
abstract ResteasyClientBuilder
trustStore(KeyStore trustStore)
abstract ResteasyClientBuilder
useAsyncHttpEngine()
abstract ResteasyClientBuilder
withConfig(javax.ws.rs.core.Configuration config)
-
-
-
Field Detail
-
PROPERTY_PROXY_HOST
public static final String PROPERTY_PROXY_HOST
Client properties to enable proxy. Proxy host property name (string).- See Also:
- Constant Field Values
-
PROPERTY_PROXY_PORT
public static final String PROPERTY_PROXY_PORT
Proxy port property name (integer).- See Also:
- Constant Field Values
-
PROPERTY_PROXY_SCHEME
public static final String PROPERTY_PROXY_SCHEME
Proxy scheme property name (string).- See Also:
- Constant Field Values
-
-
Method Detail
-
providerFactory
public abstract ResteasyClientBuilder providerFactory(ResteasyProviderFactory providerFactory)
Changing the providerFactory will wipe clean any registered components or properties.- Parameters:
providerFactory
- provider factory- Returns:
- an updated client builder instance
-
getProviderFactory
public abstract ResteasyProviderFactory getProviderFactory()
-
connectionTTL
public abstract ResteasyClientBuilder connectionTTL(long ttl, TimeUnit unit)
If there is a connection pool, set the time to live in the pool.- Parameters:
ttl
- time to liveunit
- the time unit of the ttl argument- Returns:
- an updated client builder instance
-
getConnectionTTL
public abstract long getConnectionTTL(TimeUnit unit)
-
maxPooledPerRoute
public abstract ResteasyClientBuilder maxPooledPerRoute(int maxPooledPerRoute)
If connection pooling enabled, how many connections to pool per url?- Parameters:
maxPooledPerRoute
- max pool size per url- Returns:
- an updated client builder instance
-
getMaxPooledPerRoute
public abstract int getMaxPooledPerRoute()
-
connectionCheckoutTimeout
public abstract ResteasyClientBuilder connectionCheckoutTimeout(long timeout, TimeUnit unit)
If connection pooling is enabled, how long will we wait to get a connection?- Parameters:
timeout
- the timeoutunit
- the units the timeout is in- Returns:
- an updated client builder instance
-
getConnectionCheckoutTimeout
public abstract long getConnectionCheckoutTimeout(TimeUnit unit)
-
connectionPoolSize
public abstract ResteasyClientBuilder connectionPoolSize(int connectionPoolSize)
Number of connections allowed to pool.- Parameters:
connectionPoolSize
- connection pool size- Returns:
- an updated client builder instance
-
getConnectionPoolSize
public abstract int getConnectionPoolSize()
-
responseBufferSize
public abstract ResteasyClientBuilder responseBufferSize(int size)
Response stream is wrapped in a BufferedInputStream. Default is 8192. Value of 0 will not wrap it. Value of -1 will use a SelfExpandingBufferedInputStream.- Parameters:
size
- response buffer size- Returns:
- an updated client builder instance
-
getResponseBufferSize
public abstract int getResponseBufferSize()
-
disableTrustManager
public abstract ResteasyClientBuilder disableTrustManager()
Disable trust management and hostname verification. NOTE this is a security hole, so only set this option if you cannot or do not want to verify the identity of the host you are communicating with.- Returns:
- an updated client builder instance
-
isTrustManagerDisabled
public abstract boolean isTrustManagerDisabled()
-
setIsTrustSelfSignedCertificates
public abstract void setIsTrustSelfSignedCertificates(boolean b)
When the user is not using a TrustManager (see disableTrustManager) and does not define an SSLContext object but they want all defined trustStores to use the TrustSelfSignedCertificates trust strategy set this value to true.- Parameters:
b
- A value of true assigns trust strategy TrustSelfSignedCertificates to the trustStores. A value of false assigns a null to the trust strategy. The default value is true in order to maintain backward compatibility.
-
isTrustSelfSignedCertificates
public abstract boolean isTrustSelfSignedCertificates()
-
hostnameVerification
public abstract ResteasyClientBuilder hostnameVerification(ResteasyClientBuilder.HostnameVerificationPolicy policy)
SSL policy used to verify hostnames- Parameters:
policy
- SSL policy- Returns:
- an updated client builder instance
-
getHostnameVerification
public abstract ResteasyClientBuilder.HostnameVerificationPolicy getHostnameVerification()
-
httpEngine
public abstract ResteasyClientBuilder httpEngine(ClientHttpEngine httpEngine)
Negates all ssl and connection specific configuration- Parameters:
httpEngine
- http engine- Returns:
- an updated client builder instance
-
getHttpEngine
public abstract ClientHttpEngine getHttpEngine()
-
useAsyncHttpEngine
public abstract ResteasyClientBuilder useAsyncHttpEngine()
-
isUseAsyncHttpEngine
public abstract boolean isUseAsyncHttpEngine()
-
sniHostNames
public abstract ResteasyClientBuilder sniHostNames(String... sniHostNames)
Adds a TLS/SSL SNI Host Name for authentication.- Parameters:
sniHostNames
- host names- Returns:
- an updated client builder instance
-
defaultProxy
public abstract ResteasyClientBuilder defaultProxy(String hostname)
Specify a default proxy. Default port and schema will be used.- Parameters:
hostname
- host name- Returns:
- an updated client builder instance
-
getDefaultProxyHostname
public abstract String getDefaultProxyHostname()
-
getDefaultProxyPort
public abstract int getDefaultProxyPort()
-
getDefaultProxyScheme
public abstract String getDefaultProxyScheme()
-
defaultProxy
public abstract ResteasyClientBuilder defaultProxy(String hostname, int port)
Specify a default proxy host and port. Default schema will be used.- Parameters:
hostname
- host nameport
- port- Returns:
- an updated client builder instance
-
defaultProxy
public abstract ResteasyClientBuilder defaultProxy(String hostname, int port, String scheme)
Specify default proxy.- Parameters:
hostname
- host nameport
- portscheme
- scheme- Returns:
- an updated client builder instance
-
enableCookieManagement
public abstract ResteasyClientBuilder enableCookieManagement()
Enable state (cookie) management.- Returns:
- the updated client builder instance
-
isCookieManagementEnabled
public abstract boolean isCookieManagementEnabled()
-
getSSLContext
public abstract SSLContext getSSLContext()
-
getKeyStore
public abstract KeyStore getKeyStore()
-
getKeyStorePassword
public abstract String getKeyStorePassword()
-
getTrustStore
public abstract KeyStore getTrustStore()
-
getHostnameVerifier
public abstract HostnameVerifier getHostnameVerifier()
-
getReadTimeout
public abstract long getReadTimeout(TimeUnit unit)
-
getConnectionTimeout
public abstract long getConnectionTimeout(TimeUnit unit)
-
disableAutomaticRetries
public abstract ResteasyClientBuilder disableAutomaticRetries()
boolean, notify apache to disable its automatic retries.
-
isDisableAutomaticRetries
public abstract boolean isDisableAutomaticRetries()
-
executorService
public abstract ResteasyClientBuilder executorService(ExecutorService executorService, boolean cleanupExecutor)
-
build
public abstract ResteasyClient build()
- Specified by:
build
in classjavax.ws.rs.client.ClientBuilder
-
withConfig
public abstract ResteasyClientBuilder withConfig(javax.ws.rs.core.Configuration config)
- Specified by:
withConfig
in classjavax.ws.rs.client.ClientBuilder
-
sslContext
public abstract ResteasyClientBuilder sslContext(SSLContext sslContext)
- Specified by:
sslContext
in classjavax.ws.rs.client.ClientBuilder
-
keyStore
public abstract ResteasyClientBuilder keyStore(KeyStore keyStore, char[] password)
- Specified by:
keyStore
in classjavax.ws.rs.client.ClientBuilder
-
keyStore
public abstract ResteasyClientBuilder keyStore(KeyStore keyStore, String password)
- Overrides:
keyStore
in classjavax.ws.rs.client.ClientBuilder
-
trustStore
public abstract ResteasyClientBuilder trustStore(KeyStore trustStore)
- Specified by:
trustStore
in classjavax.ws.rs.client.ClientBuilder
-
hostnameVerifier
public abstract ResteasyClientBuilder hostnameVerifier(HostnameVerifier verifier)
- Specified by:
hostnameVerifier
in classjavax.ws.rs.client.ClientBuilder
-
executorService
public abstract ResteasyClientBuilder executorService(ExecutorService executorService)
- Specified by:
executorService
in classjavax.ws.rs.client.ClientBuilder
-
scheduledExecutorService
public abstract ResteasyClientBuilder scheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
- Specified by:
scheduledExecutorService
in classjavax.ws.rs.client.ClientBuilder
-
connectTimeout
public abstract ResteasyClientBuilder connectTimeout(long timeout, TimeUnit unit)
- Specified by:
connectTimeout
in classjavax.ws.rs.client.ClientBuilder
-
readTimeout
public abstract ResteasyClientBuilder readTimeout(long timeout, TimeUnit unit)
- Specified by:
readTimeout
in classjavax.ws.rs.client.ClientBuilder
-
setFollowRedirects
public abstract ResteasyClientBuilder setFollowRedirects(boolean followRedirects)
Follow redirects added for MicroProfile-rest-client but can be used by tradition clients as well.- Parameters:
followRedirects
-- Returns:
-
isFollowRedirects
public abstract boolean isFollowRedirects()
-
-