Class CachingConnectorProvider

All Implemented Interfaces:

public class CachingConnectorProvider extends 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(, method. Client and Configuration instance passed to subsequent getConnector(...) invocations will be ignored. As such, this connector provider should not be shared among client instances that have significantly different connector-specific settings.

Marek Potociar
  • Constructor Details

    • CachingConnectorProvider

      public CachingConnectorProvider(ConnectorProvider delegate)
      Create the caching connector provider.
      delegate - delegate connector provider that will be used to initialize and create the connector instance which will be subsequently cached and reused.
  • Method Details

    • getConnector

      public Connector getConnector(Client client, Configuration runtimeConfig)
      Description copied from interface: ConnectorProvider
      Get a Jersey client connector instance for a given client instance and Jersey client runtime configuration.

      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 or hostname 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 interface ConnectorProvider
      client - Jersey client instance.
      runtimeConfig - Jersey client runtime configuration.
      configured Connector instance to be used by the client.