Class ClientConfig

  • All Implemented Interfaces:
    javax.ws.rs.core.Configurable<ClientConfig>, javax.ws.rs.core.Configuration, ExtendedConfig

    public class ClientConfig
    extends java.lang.Object
    implements javax.ws.rs.core.Configurable<ClientConfig>, ExtendedConfig
    Jersey externalized implementation of client-side JAX-RS configurable contract.
    • Constructor Detail

      • ClientConfig

        public ClientConfig()
        Construct a new Jersey configuration instance with the default features and property values.
      • ClientConfig

        public ClientConfig​(java.lang.Class<?>... providerClasses)
        Construct a new Jersey configuration instance and register the provided list of provider classes.
        Parameters:
        providerClasses - provider classes to be registered with this client configuration.
      • ClientConfig

        public ClientConfig​(java.lang.Object... providers)
        Construct a new Jersey configuration instance and register the provided list of provider instances.
        Parameters:
        providers - provider instances to be registered with this client configuration.
      • ClientConfig

        ClientConfig​(JerseyClient parent)
        Construct a new Jersey configuration instance with the features as well as property values copied from the supplied JAX-RS configuration instance.
        Parameters:
        parent - parent Jersey client instance.
      • ClientConfig

        ClientConfig​(JerseyClient parent,
                     javax.ws.rs.core.Configuration that)
        Construct a new Jersey configuration instance with the features as well as property values copied from the supplied JAX-RS configuration instance.
        Parameters:
        parent - parent Jersey client instance.
        that - original Configuration.
      • ClientConfig

        private ClientConfig​(ClientConfig.State state)
        Construct a new Jersey configuration instance using the supplied state.
        Parameters:
        state - to be referenced from the new configuration instance.
    • Method Detail

      • snapshot

        ClientConfig snapshot()
        Take a snapshot of the current configuration and its internal state.

        The returned configuration object is an new instance different from the original one, however the cloning of the internal configuration state is lazily deferred until either original or the snapshot configuration is modified for the first time since the snapshot was taken.

        Returns:
        snapshot of the current configuration.
      • loadFrom

        public ClientConfig loadFrom​(javax.ws.rs.core.Configuration config)
        Load the internal configuration state from an externally provided configuration state.

        Calling this method effectively replaces existing configuration state of the instance with the state represented by the externally provided configuration.

        Parameters:
        config - external configuration state to replace the configuration of this configurable instance.
        Returns:
        the updated client configuration instance.
      • register

        public ClientConfig register​(java.lang.Class<?> providerClass)
        Specified by:
        register in interface javax.ws.rs.core.Configurable<ClientConfig>
      • register

        public ClientConfig register​(java.lang.Object provider)
        Specified by:
        register in interface javax.ws.rs.core.Configurable<ClientConfig>
      • register

        public ClientConfig register​(java.lang.Class<?> providerClass,
                                     int bindingPriority)
        Specified by:
        register in interface javax.ws.rs.core.Configurable<ClientConfig>
      • register

        public ClientConfig register​(java.lang.Class<?> providerClass,
                                     java.lang.Class<?>... contracts)
        Specified by:
        register in interface javax.ws.rs.core.Configurable<ClientConfig>
      • register

        public ClientConfig register​(java.lang.Class<?> providerClass,
                                     java.util.Map<java.lang.Class<?>,​java.lang.Integer> contracts)
        Specified by:
        register in interface javax.ws.rs.core.Configurable<ClientConfig>
      • register

        public ClientConfig register​(java.lang.Object provider,
                                     int bindingPriority)
        Specified by:
        register in interface javax.ws.rs.core.Configurable<ClientConfig>
      • register

        public ClientConfig register​(java.lang.Object provider,
                                     java.lang.Class<?>... contracts)
        Specified by:
        register in interface javax.ws.rs.core.Configurable<ClientConfig>
      • register

        public ClientConfig register​(java.lang.Object provider,
                                     java.util.Map<java.lang.Class<?>,​java.lang.Integer> contracts)
        Specified by:
        register in interface javax.ws.rs.core.Configurable<ClientConfig>
      • property

        public ClientConfig property​(java.lang.String name,
                                     java.lang.Object value)
        Specified by:
        property in interface javax.ws.rs.core.Configurable<ClientConfig>
      • getConfiguration

        public ClientConfig getConfiguration()
        Specified by:
        getConfiguration in interface javax.ws.rs.core.Configurable<ClientConfig>
      • getRuntimeType

        public javax.ws.rs.RuntimeType getRuntimeType()
        Specified by:
        getRuntimeType in interface javax.ws.rs.core.Configuration
      • getProperties

        public java.util.Map<java.lang.String,​java.lang.Object> getProperties()
        Specified by:
        getProperties in interface javax.ws.rs.core.Configuration
      • getProperty

        public java.lang.Object getProperty​(java.lang.String name)
        Specified by:
        getProperty in interface javax.ws.rs.core.Configuration
      • getPropertyNames

        public java.util.Collection<java.lang.String> getPropertyNames()
        Specified by:
        getPropertyNames in interface javax.ws.rs.core.Configuration
      • isProperty

        public boolean isProperty​(java.lang.String name)
        Description copied from interface: ExtendedConfig
        Get the value of the property with a given name converted to boolean. Returns false if the value is not convertible.
        Specified by:
        isProperty in interface ExtendedConfig
        Parameters:
        name - property name.
        Returns:
        boolean property value or false if the property is not convertible.
      • isEnabled

        public boolean isEnabled​(javax.ws.rs.core.Feature feature)
        Specified by:
        isEnabled in interface javax.ws.rs.core.Configuration
      • isEnabled

        public boolean isEnabled​(java.lang.Class<? extends javax.ws.rs.core.Feature> featureClass)
        Specified by:
        isEnabled in interface javax.ws.rs.core.Configuration
      • isRegistered

        public boolean isRegistered​(java.lang.Object component)
        Specified by:
        isRegistered in interface javax.ws.rs.core.Configuration
      • getContracts

        public java.util.Map<java.lang.Class<?>,​java.lang.Integer> getContracts​(java.lang.Class<?> componentClass)
        Specified by:
        getContracts in interface javax.ws.rs.core.Configuration
      • isRegistered

        public boolean isRegistered​(java.lang.Class<?> componentClass)
        Specified by:
        isRegistered in interface javax.ws.rs.core.Configuration
      • getClasses

        public java.util.Set<java.lang.Class<?>> getClasses()
        Specified by:
        getClasses in interface javax.ws.rs.core.Configuration
      • getInstances

        public java.util.Set<java.lang.Object> getInstances()
        Specified by:
        getInstances in interface javax.ws.rs.core.Configuration
      • connectorProvider

        public ClientConfig connectorProvider​(ConnectorProvider connectorProvider)
        Register a custom Jersey client connector provider.

        The registered ConnectorProvider instance will provide a Jersey client Connector for the JerseyClient instance created with this client configuration.

        Parameters:
        connectorProvider - custom connector provider. Must not be null.
        Returns:
        this client config instance.
        Throws:
        java.lang.NullPointerException - in case the connectorProvider is null.
        Since:
        2.5
      • executorService

        public ClientConfig executorService​(java.util.concurrent.ExecutorService executorService)
        Register custom Jersey client async executor.
        Parameters:
        executorService - custom executor service instance
        Returns:
        this client config instance
      • scheduledExecutorService

        public ClientConfig scheduledExecutorService​(java.util.concurrent.ScheduledExecutorService scheduledExecutorService)
        Register custom Jersey client scheduler.
        Parameters:
        scheduledExecutorService - custom scheduled executor service instance
        Returns:
        this client config instance
      • getConnector

        public Connector getConnector()
        Get the client transport connector.

        May return null if no connector has been set.

        Returns:
        client transport connector or {code null} if not set.
      • getConnectorProvider

        public ConnectorProvider getConnectorProvider()
        Get the client transport connector provider.

        If no custom connector provider has been set, default connector provider instance is returned.

        Returns:
        configured client transport connector provider.
        Since:
        2.5
      • getExecutorService

        public java.util.concurrent.ExecutorService getExecutorService()
        Get custom client executor service.

        May return null if no custom executor service has been set.

        Returns:
        custom executor service instance or null if not set.
        Since:
        2.26
      • getScheduledExecutorService

        public java.util.concurrent.ScheduledExecutorService getScheduledExecutorService()
        Get custom client scheduled executor service.

        May return null if no custom scheduled executor service has been set.

        Returns:
        custom executor service instance or null if not set.
        Since:
        2.26
      • getRuntime

        ClientRuntime getRuntime()
        Get the configured runtime.
        Returns:
        configured runtime.
      • getClient

        public JerseyClient getClient()
        Get the parent Jersey client this configuration is bound to.

        May return null if no parent client has been bound.

        Returns:
        bound parent Jersey client or null if not bound.
      • preInitialize

        ClientConfig preInitialize()
        Pre initializes this configuration by initializing client runtime including message body workers. Once this method is called no other method implementing Configurable should be called on this pre initialized configuration otherwise configuration will change back to uninitialized.

        Note that this method must be called only when configuration is attached to the client.

        Returns:
        Client configuration.
      • checkClient

        void checkClient()
                  throws java.lang.IllegalStateException
        Check that the configuration instance has a parent client set.
        Throws:
        java.lang.IllegalStateException - in case no parent Jersey client has been bound to the configuration instance yet.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object