Class 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 $
    • Field Detail

      • truststore

        protected java.security.KeyStore truststore
      • clientKeyStore

        protected java.security.KeyStore clientKeyStore
      • clientPrivateKeyPassword

        protected java.lang.String clientPrivateKeyPassword
      • disableTrustManager

        protected boolean disableTrustManager
      • 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
      • 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
    • Constructor Detail

      • ResteasyClientBuilder

        public ResteasyClientBuilder()
    • 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 timeout
        unit - 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.
      • sslContext

        public ResteasyClientBuilder sslContext​(javax.net.ssl.SSLContext sslContext)
        Specified by:
        sslContext in class javax.ws.rs.client.ClientBuilder
      • trustStore

        public ResteasyClientBuilder trustStore​(java.security.KeyStore truststore)
        Specified by:
        trustStore in class javax.ws.rs.client.ClientBuilder
      • keyStore

        public ResteasyClientBuilder keyStore​(java.security.KeyStore keyStore,
                                              java.lang.String password)
        Overrides:
        keyStore in class javax.ws.rs.client.ClientBuilder
      • keyStore

        public ResteasyClientBuilder keyStore​(java.security.KeyStore keyStore,
                                              char[] password)
        Specified by:
        keyStore in class javax.ws.rs.client.ClientBuilder
      • 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:
      • build

        public ResteasyClient build()
        Specified by:
        build in class javax.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 class javax.ws.rs.client.ClientBuilder
      • getConfiguration

        public javax.ws.rs.core.Configuration getConfiguration()
      • 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,
                                              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 class javax.ws.rs.client.ClientBuilder