Class CachingConnectorProvider
- java.lang.Object
-
- org.glassfish.jersey.client.spi.CachingConnectorProvider
-
- All Implemented Interfaces:
ConnectorProvider
public class CachingConnectorProvider extends java.lang.Object implements ConnectorProvider
Caching connector provider. This utility provider can be used to serve as a lazily initialized provider of the same connector instance.Note however that the connector instance will be configured using the runtime configuration of the first client instance that has invoked the
getConnector(javax.ws.rs.client.Client, javax.ws.rs.core.Configuration)
method.Client
andConfiguration
instance passed to subsequentgetConnector(...)
invocations will be ignored. As such, this connector provider should not be shared among client instances that have significantly different connector-specific settings.- Since:
- 2.10
-
-
Field Summary
Fields Modifier and Type Field Description private Connector
connector
private ConnectorProvider
delegate
-
Constructor Summary
Constructors Constructor Description CachingConnectorProvider(ConnectorProvider delegate)
Create the caching connector provider.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Connector
getConnector(javax.ws.rs.client.Client client, javax.ws.rs.core.Configuration runtimeConfig)
Get a Jersey client connector instance for a givenclient
instance and Jersey client runtimeconfiguration
.
-
-
-
Field Detail
-
delegate
private final ConnectorProvider delegate
-
connector
private Connector connector
-
-
Constructor Detail
-
CachingConnectorProvider
public CachingConnectorProvider(ConnectorProvider delegate)
Create the caching connector provider.- Parameters:
delegate
- delegate connector provider that will be used to initialize and create the connector instance which will be subsequently cached and reused.
-
-
Method Detail
-
getConnector
public Connector getConnector(javax.ws.rs.client.Client client, javax.ws.rs.core.Configuration runtimeConfig)
Description copied from interface:ConnectorProvider
Get a Jersey client connector instance for a givenclient
instance and Jersey client runtimeconfiguration
.Note that the supplied runtime configuration can be different from the client instance configuration as a single client can be used to serve multiple differently configured runtimes. While the
SSL context
orhostname verifier
are shared, other configuration properties may change in each runtime.Based on the supplied client and runtime configuration data, it is up to each connector provider implementation to decide whether a new dedicated connector instance is required or if the existing, previously create connector instance can be reused.
- Specified by:
getConnector
in interfaceConnectorProvider
- Parameters:
client
- Jersey client instance.runtimeConfig
- Jersey client runtime configuration.- Returns:
- configured
Connector
instance to be used by the client.
-
-