• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  *  http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 package software.amazon.awssdk.awscore.client.handler;
17 
18 import java.util.concurrent.CompletableFuture;
19 import software.amazon.awssdk.annotations.Immutable;
20 import software.amazon.awssdk.annotations.SdkProtectedApi;
21 import software.amazon.awssdk.annotations.ThreadSafe;
22 import software.amazon.awssdk.awscore.internal.AwsExecutionContextBuilder;
23 import software.amazon.awssdk.awscore.internal.client.config.AwsClientOptionValidation;
24 import software.amazon.awssdk.core.SdkRequest;
25 import software.amazon.awssdk.core.SdkResponse;
26 import software.amazon.awssdk.core.async.AsyncResponseTransformer;
27 import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
28 import software.amazon.awssdk.core.client.handler.AsyncClientHandler;
29 import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
30 import software.amazon.awssdk.core.client.handler.SdkAsyncClientHandler;
31 import software.amazon.awssdk.core.http.ExecutionContext;
32 
33 /**
34  * Async client handler for AWS SDK clients.
35  */
36 @ThreadSafe
37 @Immutable
38 @SdkProtectedApi
39 public final class AwsAsyncClientHandler extends SdkAsyncClientHandler implements AsyncClientHandler {
40 
AwsAsyncClientHandler(SdkClientConfiguration clientConfiguration)41     public AwsAsyncClientHandler(SdkClientConfiguration clientConfiguration) {
42         super(clientConfiguration);
43         AwsClientOptionValidation.validateAsyncClientOptions(clientConfiguration);
44     }
45 
46     @Override
execute( ClientExecutionParams<InputT, OutputT> executionParams)47     public <InputT extends SdkRequest, OutputT extends SdkResponse> CompletableFuture<OutputT> execute(
48         ClientExecutionParams<InputT, OutputT> executionParams) {
49         return super.execute(executionParams);
50     }
51 
52     @Override
execute( ClientExecutionParams<InputT, OutputT> executionParams, AsyncResponseTransformer<OutputT, ReturnT> asyncResponseTransformer)53     public <InputT extends SdkRequest, OutputT extends SdkResponse, ReturnT> CompletableFuture<ReturnT> execute(
54         ClientExecutionParams<InputT, OutputT> executionParams,
55         AsyncResponseTransformer<OutputT, ReturnT> asyncResponseTransformer) {
56         return super.execute(executionParams, asyncResponseTransformer);
57     }
58 
59     @Override
60     protected <InputT extends SdkRequest, OutputT extends SdkResponse> ExecutionContext
invokeInterceptorsAndCreateExecutionContext(ClientExecutionParams<InputT, OutputT> executionParams)61         invokeInterceptorsAndCreateExecutionContext(ClientExecutionParams<InputT, OutputT> executionParams) {
62         SdkClientConfiguration clientConfiguration = resolveRequestConfiguration(executionParams);
63         return AwsExecutionContextBuilder.invokeInterceptorsAndCreateExecutionContext(executionParams, clientConfiguration);
64     }
65 }
66