Package org.glassfish.jersey.client
Class ClientConfig
java.lang.Object
org.glassfish.jersey.client.ClientConfig
- All Implemented Interfaces:
javax.ws.rs.core.Configurable<ClientConfig>
,javax.ws.rs.core.Configuration
,ExtendedConfig
public class ClientConfig
extends Object
implements javax.ws.rs.core.Configurable<ClientConfig>, ExtendedConfig
Jersey externalized implementation of client-side JAX-RS
configurable
contract.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static class
Default encapsulation of the internal configuration state. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstruct a new Jersey configuration instance with the default features and property values.ClientConfig
(Class<?>... providerClasses) Construct a new Jersey configuration instance and register the provided list of provider classes.ClientConfig
(Object... providers) Construct a new Jersey configuration instance and register the provided list of provider instances.private
ClientConfig
(ClientConfig.State state) Construct a new Jersey configuration instance using the supplied state.(package private)
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.(package private)
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. -
Method Summary
Modifier and TypeMethodDescription(package private) void
Check that the configuration instance has a parent client set.connectorProvider
(ConnectorProvider connectorProvider) Register a custom Jersey client connector provider.boolean
executorService
(ExecutorService executorService) Register custom Jersey client async executor.Get the parent Jersey client this configuration is bound to.Get the client transport connector.Get the client transport connector provider.getContracts
(Class<?> componentClass) Get custom client executor service.getProperty
(String name) (package private) ClientRuntime
Get the configured runtime.javax.ws.rs.RuntimeType
Get custom client scheduled executor service.int
hashCode()
boolean
boolean
isEnabled
(javax.ws.rs.core.Feature feature) boolean
isProperty
(String name) Get the value of the property with a given name converted toboolean
.boolean
isRegistered
(Class<?> componentClass) boolean
isRegistered
(Object component) loadFrom
(javax.ws.rs.core.Configuration config) Load the internal configuration state from an externally provided configuration state.(package private) ClientConfig
Pre initializes this configuration by initializingclient runtime
includingmessage body workers
.scheduledExecutorService
(ScheduledExecutorService scheduledExecutorService) Register custom Jersey client scheduler.(package private) ClientConfig
snapshot()
Take a snapshot of the current configuration and its internal state.
-
Field Details
-
state
Internal configuration state.
-
-
Constructor Details
-
ClientConfig
public ClientConfig()Construct a new Jersey configuration instance with the default features and property values. -
ClientConfig
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
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
- originalConfiguration
.
-
ClientConfig
Construct a new Jersey configuration instance using the supplied state.- Parameters:
state
- to be referenced from the new configuration instance.
-
-
Method Details
-
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
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
- Specified by:
register
in interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
register
- Specified by:
register
in interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
register
- Specified by:
register
in interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
register
- Specified by:
register
in interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
register
- Specified by:
register
in interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
register
- Specified by:
register
in interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
register
- Specified by:
register
in interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
register
- Specified by:
register
in interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
property
- Specified by:
property
in interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
getConfiguration
- Specified by:
getConfiguration
in interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
getRuntimeType
public javax.ws.rs.RuntimeType getRuntimeType()- Specified by:
getRuntimeType
in interfacejavax.ws.rs.core.Configuration
-
getProperties
- Specified by:
getProperties
in interfacejavax.ws.rs.core.Configuration
-
getProperty
- Specified by:
getProperty
in interfacejavax.ws.rs.core.Configuration
-
getPropertyNames
- Specified by:
getPropertyNames
in interfacejavax.ws.rs.core.Configuration
-
isProperty
Description copied from interface:ExtendedConfig
Get the value of the property with a given name converted toboolean
. Returnsfalse
if the value is not convertible.- Specified by:
isProperty
in interfaceExtendedConfig
- Parameters:
name
- property name.- Returns:
boolean
property value orfalse
if the property is not convertible.
-
isEnabled
public boolean isEnabled(javax.ws.rs.core.Feature feature) - Specified by:
isEnabled
in interfacejavax.ws.rs.core.Configuration
-
isEnabled
- Specified by:
isEnabled
in interfacejavax.ws.rs.core.Configuration
-
isRegistered
- Specified by:
isRegistered
in interfacejavax.ws.rs.core.Configuration
-
getContracts
- Specified by:
getContracts
in interfacejavax.ws.rs.core.Configuration
-
isRegistered
- Specified by:
isRegistered
in interfacejavax.ws.rs.core.Configuration
-
getClasses
- Specified by:
getClasses
in interfacejavax.ws.rs.core.Configuration
-
getInstances
- Specified by:
getInstances
in interfacejavax.ws.rs.core.Configuration
-
connectorProvider
Register a custom Jersey client connector provider.The registered
ConnectorProvider
instance will provide a Jersey clientConnector
for theJerseyClient
instance created with this client configuration.- Parameters:
connectorProvider
- custom connector provider. Must not benull
.- Returns:
- this client config instance.
- Throws:
NullPointerException
- in case theconnectorProvider
isnull
.- Since:
- 2.5
-
executorService
Register custom Jersey client async executor.- Parameters:
executorService
- custom executor service instance- Returns:
- this client config instance
-
scheduledExecutorService
Register custom Jersey client scheduler.- Parameters:
scheduledExecutorService
- custom scheduled executor service instance- Returns:
- this client config instance
-
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
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
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
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.
-
getClientExecutor
-
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 initializingclient runtime
includingmessage body workers
. Once this method is called no other method implementingConfigurable
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
Check that the configuration instance has a parent client set.- Throws:
IllegalStateException
- in case no parent Jersey client has been bound to the configuration instance yet.
-
equals
-
hashCode
public int hashCode()
-