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 java.lang.Object implements javax.ws.rs.core.Configurable<ClientConfig>, ExtendedConfig
Jersey externalized implementation of client-side JAX-RSconfigurablecontract.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classClientConfig.RuntimeConfigConfiguratorprivate static classClientConfig.StateDefault encapsulation of the internal configuration state.
-
Field Summary
Fields Modifier and Type Field Description private ClientConfig.StatestateInternal configuration state.
-
Constructor Summary
Constructors Modifier Constructor Description ClientConfig()Construct a new Jersey configuration instance with the default features and property values.ClientConfig(java.lang.Class<?>... providerClasses)Construct a new Jersey configuration instance and register the provided list of provider classes.ClientConfig(java.lang.Object... providers)Construct a new Jersey configuration instance and register the provided list of provider instances.privateClientConfig(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidcheckClient()Check that the configuration instance has a parent client set.ClientConfigconnectorProvider(ConnectorProvider connectorProvider)Register a custom Jersey client connector provider.booleanequals(java.lang.Object obj)ClientConfigexecutorService(java.util.concurrent.ExecutorService executorService)Register custom Jersey client async executor.java.util.Set<java.lang.Class<?>>getClasses()JerseyClientgetClient()Get the parent Jersey client this configuration is bound to.ClientExecutorgetClientExecutor()ClientConfiggetConfiguration()ConnectorgetConnector()Get the client transport connector.ConnectorProvidergetConnectorProvider()Get the client transport connector provider.java.util.Map<java.lang.Class<?>,java.lang.Integer>getContracts(java.lang.Class<?> componentClass)java.util.concurrent.ExecutorServicegetExecutorService()Get custom client executor service.java.util.Set<java.lang.Object>getInstances()java.util.Map<java.lang.String,java.lang.Object>getProperties()java.lang.ObjectgetProperty(java.lang.String name)java.util.Collection<java.lang.String>getPropertyNames()(package private) ClientRuntimegetRuntime()Get the configured runtime.javax.ws.rs.RuntimeTypegetRuntimeType()java.util.concurrent.ScheduledExecutorServicegetScheduledExecutorService()Get custom client scheduled executor service.inthashCode()booleanisEnabled(java.lang.Class<? extends javax.ws.rs.core.Feature> featureClass)booleanisEnabled(javax.ws.rs.core.Feature feature)booleanisProperty(java.lang.String name)Get the value of the property with a given name converted toboolean.booleanisRegistered(java.lang.Class<?> componentClass)booleanisRegistered(java.lang.Object component)ClientConfigloadFrom(javax.ws.rs.core.Configuration config)Load the internal configuration state from an externally provided configuration state.(package private) ClientConfigpreInitialize()Pre initializes this configuration by initializingclient runtimeincludingmessage body workers.ClientConfigproperty(java.lang.String name, java.lang.Object value)ClientConfigregister(java.lang.Class<?> providerClass)ClientConfigregister(java.lang.Class<?> providerClass, int bindingPriority)ClientConfigregister(java.lang.Class<?> providerClass, java.lang.Class<?>... contracts)ClientConfigregister(java.lang.Class<?> providerClass, java.util.Map<java.lang.Class<?>,java.lang.Integer> contracts)ClientConfigregister(java.lang.Object provider)ClientConfigregister(java.lang.Object provider, int bindingPriority)ClientConfigregister(java.lang.Object provider, java.lang.Class<?>... contracts)ClientConfigregister(java.lang.Object provider, java.util.Map<java.lang.Class<?>,java.lang.Integer> contracts)ClientConfigscheduledExecutorService(java.util.concurrent.ScheduledExecutorService scheduledExecutorService)Register custom Jersey client scheduler.(package private) ClientConfigsnapshot()Take a snapshot of the current configuration and its internal state.
-
-
-
Field Detail
-
state
private ClientConfig.State state
Internal configuration state.
-
-
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- originalConfiguration.
-
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:
registerin interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
register
public ClientConfig register(java.lang.Object provider)
- Specified by:
registerin interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
register
public ClientConfig register(java.lang.Class<?> providerClass, int bindingPriority)
- Specified by:
registerin interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
register
public ClientConfig register(java.lang.Class<?> providerClass, java.lang.Class<?>... contracts)
- Specified by:
registerin interfacejavax.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:
registerin interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
register
public ClientConfig register(java.lang.Object provider, int bindingPriority)
- Specified by:
registerin interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
register
public ClientConfig register(java.lang.Object provider, java.lang.Class<?>... contracts)
- Specified by:
registerin interfacejavax.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:
registerin interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
property
public ClientConfig property(java.lang.String name, java.lang.Object value)
- Specified by:
propertyin interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
getConfiguration
public ClientConfig getConfiguration()
- Specified by:
getConfigurationin interfacejavax.ws.rs.core.Configurable<ClientConfig>
-
getRuntimeType
public javax.ws.rs.RuntimeType getRuntimeType()
- Specified by:
getRuntimeTypein interfacejavax.ws.rs.core.Configuration
-
getProperties
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
- Specified by:
getPropertiesin interfacejavax.ws.rs.core.Configuration
-
getProperty
public java.lang.Object getProperty(java.lang.String name)
- Specified by:
getPropertyin interfacejavax.ws.rs.core.Configuration
-
getPropertyNames
public java.util.Collection<java.lang.String> getPropertyNames()
- Specified by:
getPropertyNamesin interfacejavax.ws.rs.core.Configuration
-
isProperty
public boolean isProperty(java.lang.String name)
Description copied from interface:ExtendedConfigGet the value of the property with a given name converted toboolean. Returnsfalseif the value is not convertible.- Specified by:
isPropertyin interfaceExtendedConfig- Parameters:
name- property name.- Returns:
booleanproperty value orfalseif the property is not convertible.
-
isEnabled
public boolean isEnabled(javax.ws.rs.core.Feature feature)
- Specified by:
isEnabledin interfacejavax.ws.rs.core.Configuration
-
isEnabled
public boolean isEnabled(java.lang.Class<? extends javax.ws.rs.core.Feature> featureClass)
- Specified by:
isEnabledin interfacejavax.ws.rs.core.Configuration
-
isRegistered
public boolean isRegistered(java.lang.Object component)
- Specified by:
isRegisteredin interfacejavax.ws.rs.core.Configuration
-
getContracts
public java.util.Map<java.lang.Class<?>,java.lang.Integer> getContracts(java.lang.Class<?> componentClass)
- Specified by:
getContractsin interfacejavax.ws.rs.core.Configuration
-
isRegistered
public boolean isRegistered(java.lang.Class<?> componentClass)
- Specified by:
isRegisteredin interfacejavax.ws.rs.core.Configuration
-
getClasses
public java.util.Set<java.lang.Class<?>> getClasses()
- Specified by:
getClassesin interfacejavax.ws.rs.core.Configuration
-
getInstances
public java.util.Set<java.lang.Object> getInstances()
- Specified by:
getInstancesin interfacejavax.ws.rs.core.Configuration
-
connectorProvider
public ClientConfig connectorProvider(ConnectorProvider connectorProvider)
Register a custom Jersey client connector provider.The registered
ConnectorProviderinstance will provide a Jersey clientConnectorfor theJerseyClientinstance created with this client configuration.- Parameters:
connectorProvider- custom connector provider. Must not benull.- Returns:
- this client config instance.
- Throws:
java.lang.NullPointerException- in case theconnectorProviderisnull.- 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
nullif 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 providerinstance 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
nullif 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
nullif not set. - Since:
- 2.26
-
getRuntime
ClientRuntime getRuntime()
Get the configured runtime.- Returns:
- configured runtime.
-
getClientExecutor
public ClientExecutor getClientExecutor()
-
getClient
public JerseyClient getClient()
Get the parent Jersey client this configuration is bound to.May return
nullif no parent client has been bound.- Returns:
- bound parent Jersey client or
nullif not bound.
-
preInitialize
ClientConfig preInitialize()
Pre initializes this configuration by initializingclient runtimeincludingmessage body workers. Once this method is called no other method implementingConfigurableshould 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.IllegalStateExceptionCheck 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-