public class ResteasyClientBuilder extends ClientBuilder
Modifier and Type | Class and Description |
---|---|
static class |
ResteasyClientBuilder.HostnameVerificationPolicy |
Modifier and Type | Field and Description |
---|---|
protected ExecutorService |
asyncExecutor |
protected boolean |
cleanupExecutor |
protected KeyStore |
clientKeyStore |
protected String |
clientPrivateKeyPassword |
protected int |
connectionCheckoutTimeoutMs |
protected int |
connectionPoolSize |
protected long |
connectionTTL |
protected TimeUnit |
connectionTTLUnit |
protected org.apache.http.HttpHost |
defaultProxy |
protected boolean |
disableTrustManager |
protected long |
establishConnectionTimeout |
protected TimeUnit |
establishConnectionTimeoutUnits |
protected ClientHttpEngine |
httpEngine |
protected int |
maxPooledPerRoute |
protected ResteasyClientBuilder.HostnameVerificationPolicy |
policy |
protected Map<String,Object> |
properties |
protected ResteasyProviderFactory |
providerFactory |
protected int |
responseBufferSize |
protected List<String> |
sniHostNames |
protected long |
socketTimeout |
protected TimeUnit |
socketTimeoutUnits |
protected SSLContext |
sslContext |
protected KeyStore |
truststore |
protected HostnameVerifier |
verifier |
JAXRS_DEFAULT_CLIENT_BUILDER_PROPERTY
Constructor and Description |
---|
ResteasyClientBuilder() |
Modifier and Type | Method and Description |
---|---|
ResteasyClientBuilder |
asyncExecutor(ExecutorService asyncExecutor)
Executor to use to run AsyncInvoker invocations
|
ResteasyClientBuilder |
asyncExecutor(ExecutorService asyncExecutor,
boolean cleanupExecutor)
Executor to use to run AsyncInvoker invocations
|
ResteasyClient |
build()
Build a new client instance using all the configuration previously specified
in this client builder.
|
ResteasyClient |
buildOld()
Deprecated.
|
ResteasyClientBuilder |
connectionCheckoutTimeout(long timeout,
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 pool
|
ResteasyClientBuilder |
connectionTTL(long ttl,
TimeUnit unit)
If there is a connection pool, set the time to live in the pool.
|
ResteasyClientBuilder |
defaultProxy(String hostname)
Specify a default proxy.
|
ResteasyClientBuilder |
defaultProxy(String hostname,
int port)
Specify a default proxy host and port.
|
ResteasyClientBuilder |
defaultProxy(String hostname,
int port,
String scheme)
Specify default proxy.
|
ResteasyClientBuilder |
disableTrustManager()
Disable trust management and hostname verification.
|
ResteasyClientBuilder |
establishConnectionTimeout(long timeout,
TimeUnit unit)
When trying to make an initial socket connection, what is the timeout?
|
Configuration |
getConfiguration()
Get a live view of an internal configuration state of this configurable instance.
|
protected ResteasyProviderFactory |
getProviderFactory() |
ResteasyClientBuilder |
hostnameVerification(ResteasyClientBuilder.HostnameVerificationPolicy policy)
SSL policy used to verify hostnames
|
ResteasyClientBuilder |
hostnameVerifier(HostnameVerifier verifier)
Set the hostname verifier to be used by the client to verify the endpoint's hostname against it's
identification information.
|
ResteasyClientBuilder |
httpEngine(ClientHttpEngine httpEngine)
Negates all ssl and connection specific configuration
|
protected ClientHttpEngine |
initDefaultEngine() |
ResteasyClientBuilder |
keyStore(KeyStore keyStore,
char[] password)
Set the client-side key store.
|
ResteasyClientBuilder |
keyStore(KeyStore keyStore,
String password)
Set the client-side key store.
|
ResteasyClientBuilder |
maxPooledPerRoute(int maxPooledPerRoute)
If connection pooling enabled, how many connections to pool per url?
|
protected void |
prepareSocketForSni(SSLSocket socket) |
ResteasyClientBuilder |
property(String name,
Object value)
Set the new configuration property, if already set, the existing value of
the property will be updated.
|
ResteasyClientBuilder |
providerFactory(ResteasyProviderFactory providerFactory)
Changing the providerFactory will wipe clean any registered components or properties.
|
ResteasyClientBuilder |
register(Class<?> componentClass)
Register a class of a custom JAX-RS component (such as an extension provider or
a
feature meta-provider) to be instantiated
and used in the scope of this configurable context. |
ResteasyClientBuilder |
register(Class<?> componentClass,
Class<?>... contracts)
Register a class of a custom JAX-RS component (such as an extension provider or
a
feature meta-provider) to be instantiated
and used in the scope of this configurable context. |
ResteasyClientBuilder |
register(Class<?> componentClass,
int priority)
Register a class of a custom JAX-RS component (such as an extension provider or
a
feature meta-provider) to be instantiated
and used in the scope of this configurable context. |
ResteasyClientBuilder |
register(Class<?> componentClass,
Map<Class<?>,Integer> contracts)
Register a class of a custom JAX-RS component (such as an extension provider or
a
feature meta-provider) to be instantiated
and used in the scope of this configurable context. |
ResteasyClientBuilder |
register(Object component)
Register an instance of a custom JAX-RS component (such as an extension provider or
a
feature meta-provider) to be instantiated
and used in the scope of this configurable context. |
ResteasyClientBuilder |
register(Object component,
Class<?>... contracts)
Register an instance of a custom JAX-RS component (such as an extension provider or
a
feature meta-provider) to be instantiated
and used in the scope of this configurable context. |
ResteasyClientBuilder |
register(Object component,
int priority)
Register an instance of a custom JAX-RS component (such as an extension provider or
a
feature meta-provider) to be instantiated
and used in the scope of this configurable context. |
ResteasyClientBuilder |
register(Object component,
Map<Class<?>,Integer> contracts)
Register an instance of a custom JAX-RS component (such as an extension provider or
a
feature meta-provider) to be instantiated
and used in the scope of this configurable context. |
ResteasyClientBuilder |
responseBufferSize(int size)
Response stream is wrapped in a BufferedInputStream.
|
ResteasyClientBuilder |
sniHostNames(String... sniHostNames)
Adds a TLS/SSL SNI Host Name for authentication.
|
ResteasyClientBuilder |
socketTimeout(long timeout,
TimeUnit unit)
The timeout for waiting for data.
|
ResteasyClientBuilder |
sslContext(SSLContext sslContext)
Set the SSL context that will be used when creating secured transport connections
to server endpoints from
web targets created by the client
instance that is using this SSL context. |
ResteasyClientBuilder |
trustStore(KeyStore truststore)
Set the client-side trust store.
|
ResteasyClientBuilder |
withConfig(Configuration config)
Set the internal configuration state to an externally provided configuration state.
|
newBuilder, newClient, newClient
protected KeyStore truststore
protected KeyStore clientKeyStore
protected String clientPrivateKeyPassword
protected boolean disableTrustManager
protected ResteasyClientBuilder.HostnameVerificationPolicy policy
protected ResteasyProviderFactory providerFactory
protected ExecutorService asyncExecutor
protected boolean cleanupExecutor
protected SSLContext sslContext
protected ClientHttpEngine httpEngine
protected int connectionPoolSize
protected int maxPooledPerRoute
protected long connectionTTL
protected TimeUnit connectionTTLUnit
protected long socketTimeout
protected TimeUnit socketTimeoutUnits
protected long establishConnectionTimeout
protected TimeUnit establishConnectionTimeoutUnits
protected int connectionCheckoutTimeoutMs
protected HostnameVerifier verifier
protected org.apache.http.HttpHost defaultProxy
protected int responseBufferSize
public ResteasyClientBuilder providerFactory(ResteasyProviderFactory providerFactory)
providerFactory
- public ResteasyClientBuilder asyncExecutor(ExecutorService asyncExecutor)
asyncExecutor
- public ResteasyClientBuilder asyncExecutor(ExecutorService asyncExecutor, boolean cleanupExecutor)
asyncExecutor
- cleanupExecutor
- true if the Client should close the executor when it is closedpublic ResteasyClientBuilder connectionTTL(long ttl, TimeUnit unit)
ttl
- unit
- public ResteasyClientBuilder socketTimeout(long timeout, TimeUnit unit)
timeout
- unit
- public ResteasyClientBuilder establishConnectionTimeout(long timeout, TimeUnit unit)
timeout
- unit
- public ResteasyClientBuilder maxPooledPerRoute(int maxPooledPerRoute)
maxPooledPerRoute
- public ResteasyClientBuilder connectionCheckoutTimeout(long timeout, TimeUnit unit)
timeout
- the timeoutunit
- the units the timeout is inpublic ResteasyClientBuilder connectionPoolSize(int connectionPoolSize)
connectionPoolSize
- public ResteasyClientBuilder responseBufferSize(int size)
size
- public ResteasyClientBuilder disableTrustManager()
public ResteasyClientBuilder hostnameVerification(ResteasyClientBuilder.HostnameVerificationPolicy policy)
policy
- public ResteasyClientBuilder httpEngine(ClientHttpEngine httpEngine)
httpEngine
- public ResteasyClientBuilder sslContext(SSLContext sslContext)
ClientBuilder
web targets
created by the client
instance that is using this SSL context. The SSL context is expected to have all the
security infrastructure initialized, including the key and trust managers.
Setting a SSL context instance resets any key store
or trust store
values previously
specified.
sslContext
in class ClientBuilder
sslContext
- secure socket protocol implementation which acts as a factory
for secure socket factories or SSL engines
. Must not be null
.ClientBuilder.keyStore(java.security.KeyStore, char[])
,
ClientBuilder.keyStore(java.security.KeyStore, String)
,
ClientBuilder.trustStore(java.security.KeyStore)
public ResteasyClientBuilder trustStore(KeyStore truststore)
ClientBuilder
Setting a trust store instance resets any SSL context instance
value previously specified.
In case a custom trust store or custom SSL context is not specified, the trust management will be configured to use the default Java runtime settings.
trustStore
in class ClientBuilder
truststore
- client-side trust store. Must not be null
.ClientBuilder.sslContext(javax.net.ssl.SSLContext)
,
ClientBuilder.keyStore(java.security.KeyStore, char[])
,
ClientBuilder.keyStore(java.security.KeyStore, String)
public ResteasyClientBuilder keyStore(KeyStore keyStore, String password)
ClientBuilder
Setting a key store instance resets any SSL context instance
value previously specified.
Note that for improved security of working with password data and avoid storing passwords in Java string
objects, the ClientBuilder.keyStore(java.security.KeyStore, char[])
version of the method can be utilized.
Also note that a custom key store is only required if you want to enable a custom setup of a 2-way SSL
connections (client certificate authentication).
keyStore
in class ClientBuilder
keyStore
- client-side key store. Must not be null
.password
- client key password. Must not be null
.ClientBuilder.sslContext(javax.net.ssl.SSLContext)
,
ClientBuilder.keyStore(java.security.KeyStore, char[])
,
ClientBuilder.trustStore(java.security.KeyStore)
public ResteasyClientBuilder keyStore(KeyStore keyStore, char[] password)
ClientBuilder
Setting a key store instance resets any SSL context instance
value previously specified.
Note that a custom key store is only required if you want to enable a custom setup of a 2-way SSL connections (client certificate authentication).
keyStore
in class ClientBuilder
keyStore
- client-side key store. Must not be null
.password
- client key password. Must not be null
.ClientBuilder.sslContext(javax.net.ssl.SSLContext)
,
ClientBuilder.keyStore(java.security.KeyStore, String)
,
ClientBuilder.trustStore(java.security.KeyStore)
public ResteasyClientBuilder property(String name, Object value)
Configurable
null
value into a property
effectively removes the property from the property bag.name
- property name.value
- (new) property value. null
value removes the property
with the given name.public ResteasyClientBuilder sniHostNames(String... sniHostNames)
sniHostNames
- public ResteasyClientBuilder defaultProxy(String hostname)
hostname
- public ResteasyClientBuilder defaultProxy(String hostname, int port)
hostname
- port
- public ResteasyClientBuilder defaultProxy(String hostname, int port, String scheme)
hostname
- port
- scheme
- protected ResteasyProviderFactory getProviderFactory()
@Deprecated public ResteasyClient buildOld()
public ResteasyClient build()
ClientBuilder
build
in class ClientBuilder
protected ClientHttpEngine initDefaultEngine()
protected void prepareSocketForSni(SSLSocket socket)
public ResteasyClientBuilder hostnameVerifier(HostnameVerifier verifier)
ClientBuilder
hostnameVerifier
in class ClientBuilder
verifier
- hostname verifier.public Configuration getConfiguration()
Configurable
Configurable
instance will be reflected
in the returned Configuration
instance.
The returned Configuration
instance and the collection data it provides are not
thread-safe wrt. modification made using methods on the parent configurable object.
public ResteasyClientBuilder register(Class<?> componentClass)
Configurable
feature
meta-provider) to be instantiated
and used in the scope of this configurable context.
Implementations SHOULD warn about and ignore registrations that do not
conform to the requirements of supported JAX-RS component types in the
given configurable context. Any subsequent registration attempts for a component
type, for which a class or instance-based registration already exists in the system
MUST be rejected by the JAX-RS implementation and a warning SHOULD be raised to
inform the user about the rejected registration.
The registered JAX-RS component class is registered as a contract provider of
all the recognized JAX-RS or implementation-specific extension contracts including
meta-provider contracts, such as Feature
or DynamicFeature
.
As opposed to component instances registered via Configurable.register(Object)
method,
the lifecycle of components registered using this class-based register(...)
method is fully managed by the JAX-RS implementation or any underlying IoC
container supported by the implementation.
componentClass
- JAX-RS component class to be configured in the scope of this
configurable context.public ResteasyClientBuilder register(Class<?> componentClass, int priority)
Configurable
feature
meta-provider) to be instantiated
and used in the scope of this configurable context.
This registration method provides the same functionality as Configurable.register(Class)
except that any priority specified on the registered JAX-RS component class via
@Priority
annotation is overridden
with the supplied priority
value.
Note that in case the priority is not applicable to a particular
provider contract implemented by the class of the registered component, the supplied
priority
value will be ignored for that contract.
componentClass
- JAX-RS component class to be configured in the scope of this
configurable context.priority
- the overriding priority for the registered component
and all the provider contracts the component implements.public ResteasyClientBuilder register(Class<?> componentClass, Class<?>... contracts)
Configurable
feature
meta-provider) to be instantiated
and used in the scope of this configurable context.
This registration method provides the same functionality as Configurable.register(Class)
except the JAX-RS component class is only registered as a provider of the listed
extension provider or meta-provider contracts
.
All explicitly enumerated contract types must represent a class or an interface
implemented or extended by the registered component. Contracts that are not
assignable from
the registered component class
MUST be ignored and implementations SHOULD raise a warning to inform users about the
ignored contract(s).
componentClass
- JAX-RS component class to be configured in the scope of this
configurable context.contracts
- the specific extension provider or meta-provider contracts
implemented by the component for which the component should
be registered.
Implementations MUST ignore attempts to register a component
class for an empty or null
collection of contracts via
this method and SHOULD raise a warning about such event.public ResteasyClientBuilder register(Class<?> componentClass, Map<Class<?>,Integer> contracts)
Configurable
feature
meta-provider) to be instantiated
and used in the scope of this configurable context.
This registration method provides same functionality as Configurable.register(Class, Class[])
except that any priority specified on the registered JAX-RS component class using
@Priority
annotation is overridden
for each extension provider contract type separately with an integer priority value
specified as a value in the supplied map of [contract type, priority] pairs.
Note that in case a priority is not applicable to a provider contract registered for the JAX-RS component, the supplied priority value is ignored for such contract.
componentClass
- JAX-RS component class to be configured in the scope of this
configurable context.contracts
- map of the specific extension provider and meta-provider contracts
and their associated priorities for which the JAX-RS component
is registered.
All contracts in the map must represent a class or an interface
implemented or extended by the JAX-RS component. Contracts that are
not assignable from
the registered
component class MUST be ignored and implementations SHOULD raise a warning
to inform users about the ignored contract(s).public ResteasyClientBuilder register(Object component)
Configurable
feature
meta-provider) to be instantiated
and used in the scope of this configurable context.
Implementations SHOULD warn about and ignore registrations that do not
conform to the requirements of supported JAX-RS component types in the
given configurable context. Any subsequent registration attempts for a component
type, for which a class or instance-based registration already exists in the system
MUST be rejected by the JAX-RS implementation and a warning SHOULD be raised to
inform the user about the rejected registration.
The registered JAX-RS component is registered as a contract provider of
all the recognized JAX-RS or implementation-specific extension contracts including
meta-provider contracts, such as Feature
or DynamicFeature
.
As opposed to components registered via Configurable.register(Class)
method,
the lifecycle of providers registered using this instance-based register(...)
is not managed by JAX-RS runtime. The same registered component instance is used during
the whole lifespan of the configurable context.
Fields and properties of all registered JAX-RS component instances are injected with their
declared dependencies (see Context
) by the JAX-RS runtime prior to use.
component
- JAX-RS component instance to be configured in the scope of this
configurable context.public ResteasyClientBuilder register(Object component, int priority)
Configurable
feature
meta-provider) to be instantiated
and used in the scope of this configurable context.
This registration method provides the same functionality as Configurable.register(Object)
except that any priority specified on the registered JAX-RS component class via
@Priority
annotation is overridden
with the supplied priority
value.
Note that in case the priority is not applicable to a particular
provider contract implemented by the class of the registered component, the supplied
priority
value will be ignored for that contract.
component
- JAX-RS component instance to be configured in the scope of this
configurable context.priority
- the overriding priority for the registered component
and all the provider contracts the component implements.public ResteasyClientBuilder register(Object component, Class<?>... contracts)
Configurable
feature
meta-provider) to be instantiated
and used in the scope of this configurable context.
This registration method provides the same functionality as Configurable.register(Object)
except the JAX-RS component class is only registered as a provider of the listed
extension provider or meta-provider contracts
.
All explicitly enumerated contract types must represent a class or an interface
implemented or extended by the registered component. Contracts that are not
assignable from
the registered component class
MUST be ignored and implementations SHOULD raise a warning to inform users about the
ignored contract(s).
component
- JAX-RS component instance to be configured in the scope of this
configurable context.contracts
- the specific extension provider or meta-provider contracts
implemented by the component for which the component should
be registered.
Implementations MUST ignore attempts to register a component
class for an empty or null
collection of contracts via
this method and SHOULD raise a warning about such event.public ResteasyClientBuilder register(Object component, Map<Class<?>,Integer> contracts)
Configurable
feature
meta-provider) to be instantiated
and used in the scope of this configurable context.
This registration method provides same functionality as Configurable.register(Object, Class[])
except that any priority specified on the registered JAX-RS component class using
@Priority
annotation is overridden
for each extension provider contract type separately with an integer priority value
specified as a value in the supplied map of [contract type, priority] pairs.
Note that in case a priority is not applicable to a provider contract registered for the JAX-RS component, the supplied priority value is ignored for such contract.
component
- JAX-RS component instance to be configured in the scope of this
configurable context.contracts
- map of the specific extension provider and meta-provider contracts
and their associated priorities for which the JAX-RS component
is registered.
All contracts in the map must represent a class or an interface
implemented or extended by the JAX-RS component. Contracts that are
not assignable from
the registered
component class MUST be ignored and implementations SHOULD raise a warning
to inform users about the ignored contract(s).public ResteasyClientBuilder withConfig(Configuration config)
ClientBuilder
withConfig
in class ClientBuilder
config
- external configuration state to replace the configuration of this configurable
instance.Copyright © 2017 JBoss by Red Hat. All rights reserved.