Class SdkDefaultClientBuilder<B extends SdkClientBuilder<B,​C>,​C>

  • Type Parameters:
    B - The type of builder, for chaining.
    C - The type of client generated by this builder.
    All Implemented Interfaces:
    SdkClientBuilder<B,​C>, software.amazon.awssdk.utils.builder.Buildable, software.amazon.awssdk.utils.builder.SdkBuilder<B,​C>

    public abstract class SdkDefaultClientBuilder<B extends SdkClientBuilder<B,​C>,​C>
    extends Object
    implements SdkClientBuilder<B,​C>
    An SDK-internal implementation of the methods in SdkClientBuilder, SdkAsyncClientBuilder and SdkSyncClientBuilder. This implements all methods required by those interfaces, allowing service-specific builders to just implement the configuration they wish to add.

    By implementing both the sync and async interface's methods, service-specific builders can share code between their sync and async variants without needing one to extend the other. Note: This only defines the methods in the sync and async builder interfaces. It does not implement the interfaces themselves. This is because the sync and async client builder interfaces both require a type-constrained parameter for use in fluent chaining, and a generic type parameter conflict is introduced into the class hierarchy by this interface extending the builder interfaces themselves.

    Like all SdkClientBuilders, this class is not thread safe.

    • Field Detail

      • clientContextParams

        protected final software.amazon.awssdk.utils.AttributeMap.Builder clientContextParams
    • Constructor Detail

      • SdkDefaultClientBuilder

        protected SdkDefaultClientBuilder()
      • SdkDefaultClientBuilder

        protected SdkDefaultClientBuilder​(software.amazon.awssdk.http.SdkHttpClient.Builder defaultHttpClientBuilder,
                                          software.amazon.awssdk.http.async.SdkAsyncHttpClient.Builder defaultAsyncHttpClientBuilder)
    • Method Detail

      • build

        public final C build()
        Build a client using the current state of this builder. This is marked final in order to allow this class to add standard "build" logic between all service clients. Service clients are expected to implement the buildClient() method, that accepts the immutable client configuration generated by this build method.
        Specified by:
        build in interface software.amazon.awssdk.utils.builder.Buildable
        Specified by:
        build in interface software.amazon.awssdk.utils.builder.SdkBuilder<B extends SdkClientBuilder<B,​C>,​C>
      • buildClient

        protected abstract C buildClient()
        Implemented by child classes to create a client using the provided immutable configuration objects. The async and sync configurations are not yet immutable. Child classes will need to make them immutable in order to validate them and pass them to the client's constructor.
        Returns:
        A client based on the provided configuration.
      • syncClientConfiguration

        protected final SdkClientConfiguration syncClientConfiguration()
        Return a client configuration object, populated with the following chain of priorities.
        1. Client Configuration Overrides
        2. Customer Configuration
        3. Service-Specific Defaults
        4. Global Defaults
      • asyncClientConfiguration

        protected final SdkClientConfiguration asyncClientConfiguration()
        Return a client configuration object, populated with the following chain of priorities.
        1. Client Configuration Overrides
        2. Customer Configuration
        3. Implementation/Service-Specific Configuration
        4. Global Default Configuration
      • mergeChildDefaults

        protected SdkClientConfiguration mergeChildDefaults​(SdkClientConfiguration configuration)
        Optionally overridden by child implementations to apply implementation-specific default configuration. (eg. AWS's default credentials providers)
      • finalizeChildConfiguration

        protected SdkClientConfiguration finalizeChildConfiguration​(SdkClientConfiguration configuration)
        Optionally overridden by child implementations to derive implementation-specific configuration from the default-applied configuration. (eg. AWS's endpoint, derived from the region).
      • invokePlugins

        protected SdkClientConfiguration invokePlugins​(SdkClientConfiguration config)
        By default, returns the configuration as-is. Classes extending this method will take care of running the plugins and return the updated configuration if plugins are supported.
      • childHttpConfig

        protected software.amazon.awssdk.utils.AttributeMap childHttpConfig​(SdkClientConfiguration configuration)
        Optionally overridden by child implementations to provide implementation-specific default HTTP configuration.
      • childHttpConfig

        @Deprecated
        protected software.amazon.awssdk.utils.AttributeMap childHttpConfig()
        Optionally overridden by child implementations to provide implementation-specific default HTTP configuration.
      • endpointOverride

        public final B endpointOverride​(URI endpointOverride)
        Description copied from interface: SdkClientBuilder
        Configure the endpoint with which the SDK should communicate.

        It is important to know that EndpointProviders and the endpoint override on the client are not mutually exclusive. In all existing cases, the endpoint override is passed as a parameter to the provider and the provider *may* modify it. For example, the S3 provider may add the bucket name as a prefix to the endpoint override for virtual bucket addressing.

        Specified by:
        endpointOverride in interface SdkClientBuilder<B extends SdkClientBuilder<B,​C>,​C>
      • setEndpointOverride

        public final void setEndpointOverride​(URI endpointOverride)
      • httpClient

        public final B httpClient​(software.amazon.awssdk.http.SdkHttpClient httpClient)
      • httpClientBuilder

        public final B httpClientBuilder​(software.amazon.awssdk.http.SdkHttpClient.Builder httpClientBuilder)
      • httpClient

        public final B httpClient​(software.amazon.awssdk.http.async.SdkAsyncHttpClient httpClient)
      • httpClientBuilder

        public final B httpClientBuilder​(software.amazon.awssdk.http.async.SdkAsyncHttpClient.Builder httpClientBuilder)
      • metricPublishers

        public final B metricPublishers​(List<software.amazon.awssdk.metrics.MetricPublisher> metricPublishers)
      • addPlugin

        public final B addPlugin​(SdkPlugin plugin)
        Description copied from interface: SdkClientBuilder
        Adds a plugin to the client builder. The plugins will be invoked when building the client to allow them to change the configuration of the built client.
        Specified by:
        addPlugin in interface SdkClientBuilder<B extends SdkClientBuilder<B,​C>,​C>
      • thisBuilder

        protected B thisBuilder()
        Return "this" for method chaining.