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>
public abstract class SdkDefaultClientBuilder<B extends SdkClientBuilder<B,C>,C> extends Object implements SdkClientBuilder<B,C>
An SDK-internal implementation of the methods inSdkClientBuilder
,SdkAsyncClientBuilder
andSdkSyncClientBuilder
. 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
SdkClientBuilder
s, this class is not thread safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SdkDefaultClientBuilder.NonManagedSdkAsyncHttpClient
Wrapper aroundSdkAsyncHttpClient
to prevent it from being closed.static class
SdkDefaultClientBuilder.NonManagedSdkHttpClient
Wrapper aroundSdkHttpClient
to prevent it from being closed.
-
Field Summary
Fields Modifier and Type Field Description protected SdkClientConfiguration.Builder
clientConfiguration
protected AttributeMap.Builder
clientContextParams
-
Constructor Summary
Constructors Modifier Constructor Description protected
SdkDefaultClientBuilder()
protected
SdkDefaultClientBuilder(SdkHttpClient.Builder defaultHttpClientBuilder, SdkAsyncHttpClient.Builder defaultAsyncHttpClientBuilder)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description B
addPlugin(SdkPlugin plugin)
Adds a plugin to the client builder.protected SdkClientConfiguration
asyncClientConfiguration()
Return a client configuration object, populated with the following chain of priorities.B
asyncConfiguration(ClientAsyncConfiguration asyncConfiguration)
C
build()
Build a client using the current state of this builder.protected abstract C
buildClient()
Implemented by child classes to create a client using the provided immutable configuration objects.protected AttributeMap
childHttpConfig()
Deprecated.protected AttributeMap
childHttpConfig(SdkClientConfiguration configuration)
Deprecated.B
endpointOverride(URI endpointOverride)
Configure the endpoint with which the SDK should communicate.protected SdkClientConfiguration
finalizeChildConfiguration(SdkClientConfiguration configuration)
Optionally overridden by child implementations to derive implementation-specific configuration from the default-applied configuration.B
httpClient(SdkAsyncHttpClient httpClient)
B
httpClient(SdkHttpClient httpClient)
B
httpClientBuilder(SdkAsyncHttpClient.Builder httpClientBuilder)
B
httpClientBuilder(SdkHttpClient.Builder httpClientBuilder)
protected SdkClientConfiguration
invokePlugins(SdkClientConfiguration config)
By default, returns the configuration as-is.protected SdkClientConfiguration
mergeChildDefaults(SdkClientConfiguration configuration)
Optionally overridden by child implementations to apply implementation-specific default configuration.B
metricPublishers(List<MetricPublisher> metricPublishers)
ClientOverrideConfiguration
overrideConfiguration()
Retrieve the current override configuration.B
overrideConfiguration(ClientOverrideConfiguration overrideConfig)
Specify overrides to the default SDK configuration that should be used for clients created by this builder.List<SdkPlugin>
plugins()
Returns the list of plugins configured on the client builder.void
setAsyncConfiguration(ClientAsyncConfiguration asyncConfiguration)
void
setEndpointOverride(URI endpointOverride)
void
setOverrideConfiguration(ClientOverrideConfiguration overrideConfiguration)
protected SdkClientConfiguration
setOverrides(SdkClientConfiguration configuration)
Apply the client override configuration to the provided configuration.protected SdkClientConfiguration
syncClientConfiguration()
Return a client configuration object, populated with the following chain of priorities.protected B
thisBuilder()
Return "this" for method chaining.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface software.amazon.awssdk.utils.builder.SdkBuilder
applyMutation
-
Methods inherited from interface software.amazon.awssdk.core.client.builder.SdkClientBuilder
overrideConfiguration, putAuthScheme
-
-
-
-
Field Detail
-
clientConfiguration
protected final SdkClientConfiguration.Builder clientConfiguration
-
clientContextParams
protected final AttributeMap.Builder clientContextParams
-
-
Constructor Detail
-
SdkDefaultClientBuilder
protected SdkDefaultClientBuilder()
-
SdkDefaultClientBuilder
protected SdkDefaultClientBuilder(SdkHttpClient.Builder defaultHttpClientBuilder, 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 thebuildClient()
method, that accepts the immutable client configuration generated by this build method.- Specified by:
build
in interfaceBuildable
- Specified by:
build
in interfaceSdkBuilder<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.- Client Configuration Overrides
- Customer Configuration
- Service-Specific Defaults
- Global Defaults
-
asyncClientConfiguration
protected final SdkClientConfiguration asyncClientConfiguration()
Return a client configuration object, populated with the following chain of priorities.- Client Configuration Overrides
- Customer Configuration
- Implementation/Service-Specific Configuration
- Global Default Configuration
-
setOverrides
protected SdkClientConfiguration setOverrides(SdkClientConfiguration configuration)
Apply the client override configuration to the provided configuration. This generally does not need to be overridden by child classes, but some previous client versions override it.
-
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
@Deprecated protected AttributeMap childHttpConfig(SdkClientConfiguration configuration)
Deprecated.
-
childHttpConfig
@Deprecated protected AttributeMap childHttpConfig()
Deprecated.
-
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
EndpointProvider
s 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 interfaceSdkClientBuilder<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 interfaceSdkClientBuilder<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 withClientOverrideConfiguration.toBuilder()
.- Specified by:
overrideConfiguration
in interfaceSdkClientBuilder<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. The plugins will be invoked when building the client to allow them to change the configuration of the built client.- Specified by:
addPlugin
in interfaceSdkClientBuilder<B extends SdkClientBuilder<B,C>,C>
-
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 interfaceSdkClientBuilder<B extends SdkClientBuilder<B,C>,C>
-
thisBuilder
protected B thisBuilder()
Return "this" for method chaining.
-
-