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

java.lang.Object
software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder<B,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>, Buildable, SdkBuilder<B,C>
Direct Known Subclasses:
AwsDefaultClientBuilder

@SdkProtectedApi 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.

  • Method Details

    • 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 Buildable
      Specified by:
      build in interface SdkBuilder<B extends SdkClientBuilder<B,C>,C>
      Returns:
      an instance of T
    • 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)
    • asyncConfiguration

      public final B asyncConfiguration(ClientAsyncConfiguration asyncConfiguration)
    • setAsyncConfiguration

      public final void setAsyncConfiguration(ClientAsyncConfiguration asyncConfiguration)
    • overrideConfiguration

      public final B overrideConfiguration(ClientOverrideConfiguration overrideConfig)
      Description copied from interface: SdkClientBuilder
      Specify overrides to the default SDK configuration that should be used for clients created by this builder.
      Specified by:
      overrideConfiguration in interface SdkClientBuilder<B extends SdkClientBuilder<B,C>,C>
    • setOverrideConfiguration

      public final void setOverrideConfiguration(ClientOverrideConfiguration overrideConfiguration)
    • overrideConfiguration

      public final ClientOverrideConfiguration overrideConfiguration()
      Description copied from interface: SdkClientBuilder
      Retrieve the current override configuration. This allows further overrides across calls. Can be modified by first converting to a builder with ClientOverrideConfiguration.toBuilder().
      Specified by:
      overrideConfiguration in interface SdkClientBuilder<B extends SdkClientBuilder<B,C>,C>
      Returns:
      The existing override configuration for the builder.
    • httpClient

      public final B httpClient(SdkHttpClient httpClient)
    • httpClientBuilder

      public final B httpClientBuilder(SdkHttpClient.Builder httpClientBuilder)
    • httpClient

      public final B httpClient(SdkAsyncHttpClient httpClient)
    • httpClientBuilder

      public final B httpClientBuilder(SdkAsyncHttpClient.Builder httpClientBuilder)
    • metricPublishers

      public final B metricPublishers(List<MetricPublisher> metricPublishers)
    • addPlugin

      public final B addPlugin(SdkPlugin plugin)
      Description copied from interface: SdkClientBuilder
      Adds a plugin to the client builder that will modify the client configuration when the client is built.

      Plugins are invoked after all default configuration is applied, allowing them to override SDK defaults. Multiple plugins can be added and are executed in the order they were added. The configuration changes made by plugins apply to all requests made by the built client.

      Important: Plugin settings have the highest precedence and will override any configuration set directly on the client builder (e.g., via overrideConfiguration()).

      Example:

        SdkPlugin customPlugin = config -> {
            config.endpointOverride(URI.create("https://localhost:8080"))
                  .overrideConfiguration(c -> c.apiCallTimeout(Duration.ofSeconds(30)));
        };
      
        S3Client client = S3Client.builder()
            .addPlugin(customPlugin)
            .build();
      
      Specified by:
      addPlugin in interface SdkClientBuilder<B extends SdkClientBuilder<B,C>,C>
      Parameters:
      plugin - the plugin to add
      Returns:
      this builder for method chaining
      See Also:
    • plugins

      public final List<SdkPlugin> plugins()
      Description copied from interface: SdkClientBuilder
      Returns the list of plugins configured on the client builder.
      Specified by:
      plugins in interface SdkClientBuilder<B extends SdkClientBuilder<B,C>,C>