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>
public 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 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classResteasyClientBuilder.HostnameVerificationPolicy
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.ExecutorServiceasyncExecutorprotected booleancleanupExecutorprotected java.security.KeyStoreclientKeyStoreprotected java.lang.StringclientPrivateKeyPasswordprotected intconnectionCheckoutTimeoutMsprotected intconnectionPoolSizeprotected longconnectionTTLprotected java.util.concurrent.TimeUnitconnectionTTLUnitprotected org.apache.http.HttpHostdefaultProxyprotected booleandisableTrustManagerprotected longestablishConnectionTimeoutprotected java.util.concurrent.TimeUnitestablishConnectionTimeoutUnitsprotected ClientHttpEnginehttpEngineprotected intmaxPooledPerRouteprotected ResteasyClientBuilder.HostnameVerificationPolicypolicyprotected java.util.Map<java.lang.String,java.lang.Object>propertiesprotected ResteasyProviderFactoryproviderFactoryprotected intresponseBufferSizeprotected java.util.List<java.lang.String>sniHostNamesprotected longsocketTimeoutprotected java.util.concurrent.TimeUnitsocketTimeoutUnitsprotected javax.net.ssl.SSLContextsslContextprotected java.security.KeyStoretruststoreprotected javax.net.ssl.HostnameVerifierverifier
-
Constructor Summary
Constructors Constructor Description ResteasyClientBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ResteasyClientBuilderasyncExecutor(java.util.concurrent.ExecutorService asyncExecutor)Executor to use to run AsyncInvoker invocationsResteasyClientBuilderasyncExecutor(java.util.concurrent.ExecutorService asyncExecutor, boolean cleanupExecutor)Executor to use to run AsyncInvoker invocationsResteasyClientbuild()ResteasyClientbuildOld()Deprecated.ResteasyClientBuilderconnectionCheckoutTimeout(long timeout, java.util.concurrent.TimeUnit unit)If connection pooling is enabled, how long will we wait to get a connection?ResteasyClientBuilderconnectionPoolSize(int connectionPoolSize)Number of connections allowed to poolResteasyClientBuilderconnectionTTL(long ttl, java.util.concurrent.TimeUnit unit)If there is a connection pool, set the time to live in the pool.ResteasyClientBuilderdefaultProxy(java.lang.String hostname)Specify a default proxy.ResteasyClientBuilderdefaultProxy(java.lang.String hostname, int port)Specify a default proxy host and port.ResteasyClientBuilderdefaultProxy(java.lang.String hostname, int port, java.lang.String scheme)Specify default proxy.ResteasyClientBuilderdisableTrustManager()Disable trust management and hostname verification.ResteasyClientBuilderestablishConnectionTimeout(long timeout, java.util.concurrent.TimeUnit unit)When trying to make an initial socket connection, what is the timeout?javax.ws.rs.core.ConfigurationgetConfiguration()protected ResteasyProviderFactorygetProviderFactory()ResteasyClientBuilderhostnameVerification(ResteasyClientBuilder.HostnameVerificationPolicy policy)SSL policy used to verify hostnamesResteasyClientBuilderhostnameVerifier(javax.net.ssl.HostnameVerifier verifier)ResteasyClientBuilderhttpEngine(ClientHttpEngine httpEngine)Negates all ssl and connection specific configurationResteasyClientBuilderkeyStore(java.security.KeyStore keyStore, char[] password)ResteasyClientBuilderkeyStore(java.security.KeyStore keyStore, java.lang.String password)ResteasyClientBuildermaxPooledPerRoute(int maxPooledPerRoute)If connection pooling enabled, how many connections to pool per url?protected voidprepareSocketForSni(javax.net.ssl.SSLSocket socket)ResteasyClientBuilderproperty(java.lang.String name, java.lang.Object value)ResteasyClientBuilderproviderFactory(ResteasyProviderFactory providerFactory)Changing the providerFactory will wipe clean any registered components or properties.ResteasyClientBuilderregister(java.lang.Class<?> componentClass)ResteasyClientBuilderregister(java.lang.Class<?> componentClass, int priority)ResteasyClientBuilderregister(java.lang.Class<?> componentClass, java.lang.Class<?>... contracts)ResteasyClientBuilderregister(java.lang.Class<?> componentClass, java.util.Map<java.lang.Class<?>,java.lang.Integer> contracts)ResteasyClientBuilderregister(java.lang.Object component)ResteasyClientBuilderregister(java.lang.Object component, int priority)ResteasyClientBuilderregister(java.lang.Object component, java.lang.Class<?>... contracts)ResteasyClientBuilderregister(java.lang.Object component, java.util.Map<java.lang.Class<?>,java.lang.Integer> contracts)ResteasyClientBuilderresponseBufferSize(int size)Response stream is wrapped in a BufferedInputStream.ResteasyClientBuildersniHostNames(java.lang.String... sniHostNames)Adds a TLS/SSL SNI Host Name for authentication.ResteasyClientBuildersocketTimeout(long timeout, java.util.concurrent.TimeUnit unit)The timeout for waiting for data.ResteasyClientBuildersslContext(javax.net.ssl.SSLContext sslContext)ResteasyClientBuildertrustStore(java.security.KeyStore truststore)ResteasyClientBuilderwithConfig(javax.ws.rs.core.Configuration config)
-
-
-
Field Detail
-
truststore
protected java.security.KeyStore truststore
-
clientKeyStore
protected java.security.KeyStore clientKeyStore
-
clientPrivateKeyPassword
protected java.lang.String clientPrivateKeyPassword
-
disableTrustManager
protected boolean disableTrustManager
-
policy
protected ResteasyClientBuilder.HostnameVerificationPolicy policy
-
providerFactory
protected ResteasyProviderFactory providerFactory
-
asyncExecutor
protected java.util.concurrent.ExecutorService asyncExecutor
-
cleanupExecutor
protected boolean cleanupExecutor
-
sslContext
protected javax.net.ssl.SSLContext sslContext
-
properties
protected java.util.Map<java.lang.String,java.lang.Object> properties
-
httpEngine
protected ClientHttpEngine httpEngine
-
connectionPoolSize
protected int connectionPoolSize
-
maxPooledPerRoute
protected int maxPooledPerRoute
-
connectionTTL
protected long connectionTTL
-
connectionTTLUnit
protected java.util.concurrent.TimeUnit connectionTTLUnit
-
socketTimeout
protected long socketTimeout
-
socketTimeoutUnits
protected java.util.concurrent.TimeUnit socketTimeoutUnits
-
establishConnectionTimeout
protected long establishConnectionTimeout
-
establishConnectionTimeoutUnits
protected java.util.concurrent.TimeUnit establishConnectionTimeoutUnits
-
connectionCheckoutTimeoutMs
protected int connectionCheckoutTimeoutMs
-
verifier
protected javax.net.ssl.HostnameVerifier verifier
-
defaultProxy
protected org.apache.http.HttpHost defaultProxy
-
responseBufferSize
protected int responseBufferSize
-
sniHostNames
protected java.util.List<java.lang.String> sniHostNames
-
-
Method Detail
-
providerFactory
public ResteasyClientBuilder providerFactory(ResteasyProviderFactory providerFactory)
Changing the providerFactory will wipe clean any registered components or properties.- Parameters:
providerFactory-- Returns:
-
asyncExecutor
public ResteasyClientBuilder asyncExecutor(java.util.concurrent.ExecutorService asyncExecutor)
Executor to use to run AsyncInvoker invocations- Parameters:
asyncExecutor-- Returns:
-
asyncExecutor
public ResteasyClientBuilder asyncExecutor(java.util.concurrent.ExecutorService asyncExecutor, boolean cleanupExecutor)
Executor to use to run AsyncInvoker invocations- Parameters:
asyncExecutor-cleanupExecutor- true if the Client should close the executor when it is closed- Returns:
-
connectionTTL
public ResteasyClientBuilder connectionTTL(long ttl, java.util.concurrent.TimeUnit unit)
If there is a connection pool, set the time to live in the pool.- Parameters:
ttl-unit-- Returns:
-
socketTimeout
public ResteasyClientBuilder socketTimeout(long timeout, java.util.concurrent.TimeUnit unit)
The timeout for waiting for data. A timeout value of zero is interpreted as an infinite timeout- Parameters:
timeout-unit-- Returns:
-
establishConnectionTimeout
public ResteasyClientBuilder establishConnectionTimeout(long timeout, java.util.concurrent.TimeUnit unit)
When trying to make an initial socket connection, what is the timeout?- Parameters:
timeout-unit-- Returns:
-
maxPooledPerRoute
public ResteasyClientBuilder maxPooledPerRoute(int maxPooledPerRoute)
If connection pooling enabled, how many connections to pool per url?- Parameters:
maxPooledPerRoute-- Returns:
-
connectionCheckoutTimeout
public ResteasyClientBuilder connectionCheckoutTimeout(long timeout, java.util.concurrent.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:
- this builder
-
connectionPoolSize
public ResteasyClientBuilder connectionPoolSize(int connectionPoolSize)
Number of connections allowed to pool- Parameters:
connectionPoolSize-- Returns:
-
responseBufferSize
public 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-- Returns:
-
disableTrustManager
public 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.
-
hostnameVerification
public ResteasyClientBuilder hostnameVerification(ResteasyClientBuilder.HostnameVerificationPolicy policy)
SSL policy used to verify hostnames- Parameters:
policy-- Returns:
-
httpEngine
public ResteasyClientBuilder httpEngine(ClientHttpEngine httpEngine)
Negates all ssl and connection specific configuration- Parameters:
httpEngine-- Returns:
-
sslContext
public ResteasyClientBuilder sslContext(javax.net.ssl.SSLContext sslContext)
- Specified by:
sslContextin classjavax.ws.rs.client.ClientBuilder
-
trustStore
public ResteasyClientBuilder trustStore(java.security.KeyStore truststore)
- Specified by:
trustStorein classjavax.ws.rs.client.ClientBuilder
-
keyStore
public ResteasyClientBuilder keyStore(java.security.KeyStore keyStore, java.lang.String password)
- Overrides:
keyStorein classjavax.ws.rs.client.ClientBuilder
-
keyStore
public ResteasyClientBuilder keyStore(java.security.KeyStore keyStore, char[] password)
- Specified by:
keyStorein classjavax.ws.rs.client.ClientBuilder
-
property
public ResteasyClientBuilder property(java.lang.String name, java.lang.Object value)
-
sniHostNames
public ResteasyClientBuilder sniHostNames(java.lang.String... sniHostNames)
Adds a TLS/SSL SNI Host Name for authentication.- Parameters:
sniHostNames-- Returns:
-
defaultProxy
public ResteasyClientBuilder defaultProxy(java.lang.String hostname)
Specify a default proxy. Default port and schema will be used- Parameters:
hostname-- Returns:
-
defaultProxy
public ResteasyClientBuilder defaultProxy(java.lang.String hostname, int port)
Specify a default proxy host and port. Default schema will be used- Parameters:
hostname-port-- Returns:
-
defaultProxy
public ResteasyClientBuilder defaultProxy(java.lang.String hostname, int port, java.lang.String scheme)
Specify default proxy.- Parameters:
hostname-port-scheme-- Returns:
-
getProviderFactory
protected ResteasyProviderFactory getProviderFactory()
-
buildOld
@Deprecated public ResteasyClient buildOld()
Deprecated.
-
build
public ResteasyClient build()
- Specified by:
buildin classjavax.ws.rs.client.ClientBuilder
-
prepareSocketForSni
protected void prepareSocketForSni(javax.net.ssl.SSLSocket socket)
-
hostnameVerifier
public ResteasyClientBuilder hostnameVerifier(javax.net.ssl.HostnameVerifier verifier)
- Specified by:
hostnameVerifierin classjavax.ws.rs.client.ClientBuilder
-
getConfiguration
public javax.ws.rs.core.Configuration getConfiguration()
-
register
public ResteasyClientBuilder register(java.lang.Class<?> componentClass)
-
register
public ResteasyClientBuilder register(java.lang.Class<?> componentClass, int priority)
-
register
public ResteasyClientBuilder register(java.lang.Class<?> componentClass, java.lang.Class<?>... contracts)
-
register
public ResteasyClientBuilder register(java.lang.Class<?> componentClass, java.util.Map<java.lang.Class<?>,java.lang.Integer> contracts)
-
register
public ResteasyClientBuilder register(java.lang.Object component)
-
register
public ResteasyClientBuilder register(java.lang.Object component, int priority)
-
register
public ResteasyClientBuilder register(java.lang.Object component, java.lang.Class<?>... contracts)
-
register
public ResteasyClientBuilder register(java.lang.Object component, java.util.Map<java.lang.Class<?>,java.lang.Integer> contracts)
-
withConfig
public ResteasyClientBuilder withConfig(javax.ws.rs.core.Configuration config)
- Specified by:
withConfigin classjavax.ws.rs.client.ClientBuilder
-
-