Class ResteasyClientBuilder

java.lang.Object
jakarta.ws.rs.client.ClientBuilder
org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder
All Implemented Interfaces:
Configurable<ClientBuilder>
Direct Known Subclasses:
ResteasyClientBuilderImpl

public abstract class ResteasyClientBuilder extends 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
  • Field Details

    • PROPERTY_PROXY_HOST

      public static final String PROPERTY_PROXY_HOST
      Client properties to enable proxy. Proxy host property name (string).
      See Also:
    • PROPERTY_PROXY_PORT

      public static final String PROPERTY_PROXY_PORT
      Proxy port property name (integer).
      See Also:
    • PROPERTY_PROXY_SCHEME

      public static final String PROPERTY_PROXY_SCHEME
      Proxy scheme property name (string).
      See Also:
    • PROPERTY_FOLLOW_REDIRECTS

      public static final String PROPERTY_FOLLOW_REDIRECTS
      See Also:
  • Constructor Details

    • ResteasyClientBuilder

      public ResteasyClientBuilder()
  • Method Details

    • 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 live
      unit - 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 timeout
      unit - 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
    • getSniHostNames

      public abstract List<String> getSniHostNames()
    • 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 name
      port - port
      Returns:
      an updated client builder instance
    • defaultProxy

      public abstract ResteasyClientBuilder defaultProxy(String hostname, int port, String scheme)
      Specify default proxy.
      Parameters:
      hostname - host name
      port - port
      scheme - 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()
      Description copied from class: ClientBuilder
      Build a new client instance using all the configuration previously specified in this client builder.
      Specified by:
      build in class ClientBuilder
      Returns:
      a new client instance.
    • withConfig

      public abstract ResteasyClientBuilder withConfig(Configuration config)
      Description copied from class: ClientBuilder
      Set the internal configuration state to an externally provided configuration state.
      Specified by:
      withConfig in class ClientBuilder
      Parameters:
      config - external configuration state to replace the configuration of this configurable instance.
      Returns:
      the updated client builder instance.
    • sslContext

      public abstract ResteasyClientBuilder sslContext(SSLContext sslContext)
      Description copied from class: ClientBuilder
      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. 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.

      Specified by:
      sslContext in class ClientBuilder
      Parameters:
      sslContext - secure socket protocol implementation which acts as a factory for secure socket factories or SSL engines. Must not be null.
      Returns:
      an updated client builder instance.
      See Also:
    • keyStore

      public abstract ResteasyClientBuilder keyStore(KeyStore keyStore, char[] password)
      Description copied from class: ClientBuilder
      Set the client-side key store. Key store contains client's private keys, and the certificates with their corresponding public keys.

      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).

      Specified by:
      keyStore in class ClientBuilder
      Parameters:
      keyStore - client-side key store. Must not be null.
      password - client key password. Must not be null.
      Returns:
      an updated client builder instance.
      See Also:
    • keyStore

      public abstract ResteasyClientBuilder keyStore(KeyStore keyStore, String password)
      Description copied from class: ClientBuilder
      Set the client-side key store. Key store contains client's private keys, and the certificates with their corresponding public keys.

      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).

      Overrides:
      keyStore in class ClientBuilder
      Parameters:
      keyStore - client-side key store. Must not be null.
      password - client key password. Must not be null.
      Returns:
      an updated client builder instance.
      See Also:
    • trustStore

      public abstract ResteasyClientBuilder trustStore(KeyStore trustStore)
      Description copied from class: ClientBuilder
      Set the client-side trust store. Trust store is expected to contain certificates from other parties the client is you expect to communicate with, or from Certificate Authorities that are trusted to identify other parties.

      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.

      Specified by:
      trustStore in class ClientBuilder
      Parameters:
      trustStore - client-side trust store. Must not be null.
      Returns:
      an updated client builder instance.
      See Also:
    • hostnameVerifier

      public abstract ResteasyClientBuilder hostnameVerifier(HostnameVerifier verifier)
      Description copied from class: ClientBuilder
      Set the hostname verifier to be used by the client to verify the endpoint's hostname against it's identification information.
      Specified by:
      hostnameVerifier in class ClientBuilder
      Parameters:
      verifier - hostname verifier.
      Returns:
      an updated client builder instance.
    • executorService

      public abstract ResteasyClientBuilder executorService(ExecutorService executorService)
      Description copied from class: ClientBuilder
      Set the client-side ExecutorService.

      Provided executor service will be used for executing asynchronous tasks.

      When running in a Jakarta EE container, implementations are required to use the container-managed executor service by default. In Java SE, the default is implementation-specific. In either case, calling this method will override the default.

      Specified by:
      executorService in class ClientBuilder
      Parameters:
      executorService - executor service to be used for async invocations.
      Returns:
      an updated client builder instance.
      See Also:
    • scheduledExecutorService

      public abstract ResteasyClientBuilder scheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
      Description copied from class: ClientBuilder
      Set the client-side ScheduledExecutorService.

      Provided executor service will be used for executing scheduled asynchronous tasks.

      When running in a Jakarta EE container, implementations are required to use the container-managed scheduled executor service by default. In Java SE the default is implementation-specific. In either case, calling this method will override the default.

      Specified by:
      scheduledExecutorService in class ClientBuilder
      Parameters:
      scheduledExecutorService - executor service to be used for scheduled async invocations.
      Returns:
      an updated client builder instance.
      See Also:
    • connectTimeout

      public abstract ResteasyClientBuilder connectTimeout(long timeout, TimeUnit unit)
      Description copied from class: ClientBuilder
      Set the connect timeout.

      Value 0 represents infinity. Negative values are not allowed.

      Specified by:
      connectTimeout in class ClientBuilder
      Parameters:
      timeout - the maximum time to wait.
      unit - the time unit of the timeout argument.
      Returns:
      an updated client builder instance.
    • readTimeout

      public abstract ResteasyClientBuilder readTimeout(long timeout, TimeUnit unit)
      Description copied from class: ClientBuilder
      Set the read timeout.

      The value is the timeout to read a response. If the server doesn't respond within the defined timeframe, ProcessingException is thrown with TimeoutException as a cause.

      Value 0 represents infinity. Negative values are not allowed.

      Specified by:
      readTimeout in class ClientBuilder
      Parameters:
      timeout - the maximum time to wait.
      unit - the time unit of the timeout argument.
      Returns:
      an updated client builder instance.
    • 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()