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.ClientBuilderAbstraction 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 classResteasyClientBuilder.HostnameVerificationPolicy
-
Field Summary
Fields Modifier and Type Field Description static StringPROPERTY_PROXY_HOSTClient properties to enable proxy.static StringPROPERTY_PROXY_PORTProxy port property name (integer).static StringPROPERTY_PROXY_SCHEMEProxy scheme property name (string).
-
Constructor Summary
Constructors Constructor Description ResteasyClientBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract ResteasyClientbuild()abstract ResteasyClientBuilderconnectionCheckoutTimeout(long timeout, TimeUnit unit)If connection pooling is enabled, how long will we wait to get a connection?abstract ResteasyClientBuilderconnectionPoolSize(int connectionPoolSize)Number of connections allowed to pool.abstract ResteasyClientBuilderconnectionTTL(long ttl, TimeUnit unit)If there is a connection pool, set the time to live in the pool.abstract ResteasyClientBuilderconnectTimeout(long timeout, TimeUnit unit)abstract ResteasyClientBuilderdefaultProxy(String hostname)Specify a default proxy.abstract ResteasyClientBuilderdefaultProxy(String hostname, int port)Specify a default proxy host and port.abstract ResteasyClientBuilderdefaultProxy(String hostname, int port, String scheme)Specify default proxy.abstract ResteasyClientBuilderdisableAutomaticRetries()boolean, notify apache to disable its automatic retries.abstract ResteasyClientBuilderdisableTrustManager()Disable trust management and hostname verification.abstract ResteasyClientBuilderenableCookieManagement()Enable state (cookie) management.abstract ResteasyClientBuilderexecutorService(ExecutorService executorService)abstract ResteasyClientBuilderexecutorService(ExecutorService executorService, boolean cleanupExecutor)abstract longgetConnectionCheckoutTimeout(TimeUnit unit)abstract intgetConnectionPoolSize()abstract longgetConnectionTimeout(TimeUnit unit)abstract longgetConnectionTTL(TimeUnit unit)abstract StringgetDefaultProxyHostname()abstract intgetDefaultProxyPort()abstract StringgetDefaultProxyScheme()abstract ResteasyClientBuilder.HostnameVerificationPolicygetHostnameVerification()abstract HostnameVerifiergetHostnameVerifier()abstract ClientHttpEnginegetHttpEngine()abstract KeyStoregetKeyStore()abstract StringgetKeyStorePassword()abstract intgetMaxPooledPerRoute()abstract ResteasyProviderFactorygetProviderFactory()abstract longgetReadTimeout(TimeUnit unit)abstract intgetResponseBufferSize()abstract List<String>getSniHostNames()abstract SSLContextgetSSLContext()abstract KeyStoregetTrustStore()abstract ResteasyClientBuilderhostnameVerification(ResteasyClientBuilder.HostnameVerificationPolicy policy)SSL policy used to verify hostnamesabstract ResteasyClientBuilderhostnameVerifier(HostnameVerifier verifier)abstract ResteasyClientBuilderhttpEngine(ClientHttpEngine httpEngine)Negates all ssl and connection specific configurationabstract booleanisCookieManagementEnabled()abstract booleanisDisableAutomaticRetries()abstract booleanisFollowRedirects()abstract booleanisTrustManagerDisabled()abstract booleanisTrustSelfSignedCertificates()abstract booleanisUseAsyncHttpEngine()abstract ResteasyClientBuilderkeyStore(KeyStore keyStore, char[] password)abstract ResteasyClientBuilderkeyStore(KeyStore keyStore, String password)abstract ResteasyClientBuildermaxPooledPerRoute(int maxPooledPerRoute)If connection pooling enabled, how many connections to pool per url?abstract ResteasyClientBuilderproviderFactory(ResteasyProviderFactory providerFactory)Changing the providerFactory will wipe clean any registered components or properties.abstract ResteasyClientBuilderreadTimeout(long timeout, TimeUnit unit)abstract ResteasyClientBuilderresponseBufferSize(int size)Response stream is wrapped in a BufferedInputStream.abstract ResteasyClientBuilderscheduledExecutorService(ScheduledExecutorService scheduledExecutorService)abstract ResteasyClientBuildersetFollowRedirects(boolean followRedirects)Follow redirects added for MicroProfile-rest-client but can be used by tradition clients as well.abstract voidsetIsTrustSelfSignedCertificates(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 ResteasyClientBuildersniHostNames(String... sniHostNames)Adds a TLS/SSL SNI Host Name for authentication.abstract ResteasyClientBuildersslContext(SSLContext sslContext)abstract ResteasyClientBuildertrustStore(KeyStore trustStore)abstract ResteasyClientBuilderuseAsyncHttpEngine()abstract ResteasyClientBuilderwithConfig(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:
buildin classjavax.ws.rs.client.ClientBuilder
-
withConfig
public abstract ResteasyClientBuilder withConfig(javax.ws.rs.core.Configuration config)
- Specified by:
withConfigin classjavax.ws.rs.client.ClientBuilder
-
sslContext
public abstract ResteasyClientBuilder sslContext(SSLContext sslContext)
- Specified by:
sslContextin classjavax.ws.rs.client.ClientBuilder
-
keyStore
public abstract ResteasyClientBuilder keyStore(KeyStore keyStore, char[] password)
- Specified by:
keyStorein classjavax.ws.rs.client.ClientBuilder
-
keyStore
public abstract ResteasyClientBuilder keyStore(KeyStore keyStore, String password)
- Overrides:
keyStorein classjavax.ws.rs.client.ClientBuilder
-
trustStore
public abstract ResteasyClientBuilder trustStore(KeyStore trustStore)
- Specified by:
trustStorein classjavax.ws.rs.client.ClientBuilder
-
hostnameVerifier
public abstract ResteasyClientBuilder hostnameVerifier(HostnameVerifier verifier)
- Specified by:
hostnameVerifierin classjavax.ws.rs.client.ClientBuilder
-
executorService
public abstract ResteasyClientBuilder executorService(ExecutorService executorService)
- Specified by:
executorServicein classjavax.ws.rs.client.ClientBuilder
-
scheduledExecutorService
public abstract ResteasyClientBuilder scheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
- Specified by:
scheduledExecutorServicein classjavax.ws.rs.client.ClientBuilder
-
connectTimeout
public abstract ResteasyClientBuilder connectTimeout(long timeout, TimeUnit unit)
- Specified by:
connectTimeoutin classjavax.ws.rs.client.ClientBuilder
-
readTimeout
public abstract ResteasyClientBuilder readTimeout(long timeout, TimeUnit unit)
- Specified by:
readTimeoutin 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()
-
-