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.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 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ResteasyClientBuilder.HostnameVerificationPolicy
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.ExecutorService
asyncExecutor
protected boolean
cleanupExecutor
protected java.security.KeyStore
clientKeyStore
protected java.lang.String
clientPrivateKeyPassword
protected int
connectionCheckoutTimeoutMs
protected int
connectionPoolSize
protected long
connectionTTL
protected java.util.concurrent.TimeUnit
connectionTTLUnit
protected org.apache.http.HttpHost
defaultProxy
protected boolean
disableTrustManager
protected long
establishConnectionTimeout
protected java.util.concurrent.TimeUnit
establishConnectionTimeoutUnits
protected ClientHttpEngine
httpEngine
protected int
maxPooledPerRoute
protected ResteasyClientBuilder.HostnameVerificationPolicy
policy
protected java.util.Map<java.lang.String,java.lang.Object>
properties
protected ResteasyProviderFactory
providerFactory
protected int
responseBufferSize
protected java.util.List<java.lang.String>
sniHostNames
protected long
socketTimeout
protected java.util.concurrent.TimeUnit
socketTimeoutUnits
protected javax.net.ssl.SSLContext
sslContext
protected java.security.KeyStore
truststore
protected javax.net.ssl.HostnameVerifier
verifier
-
Constructor Summary
Constructors Constructor Description ResteasyClientBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ResteasyClientBuilder
asyncExecutor(java.util.concurrent.ExecutorService asyncExecutor)
Executor to use to run AsyncInvoker invocationsResteasyClientBuilder
asyncExecutor(java.util.concurrent.ExecutorService asyncExecutor, boolean cleanupExecutor)
Executor to use to run AsyncInvoker invocationsResteasyClient
build()
ResteasyClient
buildOld()
Deprecated.ResteasyClientBuilder
connectionCheckoutTimeout(long timeout, java.util.concurrent.TimeUnit unit)
If connection pooling is enabled, how long will we wait to get a connection?ResteasyClientBuilder
connectionPoolSize(int connectionPoolSize)
Number of connections allowed to poolResteasyClientBuilder
connectionTTL(long ttl, java.util.concurrent.TimeUnit unit)
If there is a connection pool, set the time to live in the pool.ResteasyClientBuilder
defaultProxy(java.lang.String hostname)
Specify a default proxy.ResteasyClientBuilder
defaultProxy(java.lang.String hostname, int port)
Specify a default proxy host and port.ResteasyClientBuilder
defaultProxy(java.lang.String hostname, int port, java.lang.String scheme)
Specify default proxy.ResteasyClientBuilder
disableTrustManager()
Disable trust management and hostname verification.ResteasyClientBuilder
establishConnectionTimeout(long timeout, java.util.concurrent.TimeUnit unit)
When trying to make an initial socket connection, what is the timeout?javax.ws.rs.core.Configuration
getConfiguration()
protected ResteasyProviderFactory
getProviderFactory()
ResteasyClientBuilder
hostnameVerification(ResteasyClientBuilder.HostnameVerificationPolicy policy)
SSL policy used to verify hostnamesResteasyClientBuilder
hostnameVerifier(javax.net.ssl.HostnameVerifier verifier)
ResteasyClientBuilder
httpEngine(ClientHttpEngine httpEngine)
Negates all ssl and connection specific configurationResteasyClientBuilder
keyStore(java.security.KeyStore keyStore, char[] password)
ResteasyClientBuilder
keyStore(java.security.KeyStore keyStore, java.lang.String password)
ResteasyClientBuilder
maxPooledPerRoute(int maxPooledPerRoute)
If connection pooling enabled, how many connections to pool per url?protected void
prepareSocketForSni(javax.net.ssl.SSLSocket socket)
ResteasyClientBuilder
property(java.lang.String name, java.lang.Object value)
ResteasyClientBuilder
providerFactory(ResteasyProviderFactory providerFactory)
Changing the providerFactory will wipe clean any registered components or properties.ResteasyClientBuilder
register(java.lang.Class<?> componentClass)
ResteasyClientBuilder
register(java.lang.Class<?> componentClass, int priority)
ResteasyClientBuilder
register(java.lang.Class<?> componentClass, java.lang.Class<?>... contracts)
ResteasyClientBuilder
register(java.lang.Class<?> componentClass, java.util.Map<java.lang.Class<?>,java.lang.Integer> contracts)
ResteasyClientBuilder
register(java.lang.Object component)
ResteasyClientBuilder
register(java.lang.Object component, int priority)
ResteasyClientBuilder
register(java.lang.Object component, java.lang.Class<?>... contracts)
ResteasyClientBuilder
register(java.lang.Object component, java.util.Map<java.lang.Class<?>,java.lang.Integer> contracts)
ResteasyClientBuilder
responseBufferSize(int size)
Response stream is wrapped in a BufferedInputStream.ResteasyClientBuilder
sniHostNames(java.lang.String... sniHostNames)
Adds a TLS/SSL SNI Host Name for authentication.ResteasyClientBuilder
socketTimeout(long timeout, java.util.concurrent.TimeUnit unit)
The timeout for waiting for data.ResteasyClientBuilder
sslContext(javax.net.ssl.SSLContext sslContext)
ResteasyClientBuilder
trustStore(java.security.KeyStore truststore)
ResteasyClientBuilder
withConfig(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:
sslContext
in classjavax.ws.rs.client.ClientBuilder
-
trustStore
public ResteasyClientBuilder trustStore(java.security.KeyStore truststore)
- Specified by:
trustStore
in classjavax.ws.rs.client.ClientBuilder
-
keyStore
public ResteasyClientBuilder keyStore(java.security.KeyStore keyStore, java.lang.String password)
- Overrides:
keyStore
in classjavax.ws.rs.client.ClientBuilder
-
keyStore
public ResteasyClientBuilder keyStore(java.security.KeyStore keyStore, char[] password)
- Specified by:
keyStore
in 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:
build
in 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:
hostnameVerifier
in 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:
withConfig
in classjavax.ws.rs.client.ClientBuilder
-
-