Skip to content

Commit b3a1fee

Browse files
committed
Moved dynamodb-enhanced to services-custom directory, to eventually include all hand-written service-specific libraries that aren't in the service's module. Improved JavaDoc.
1 parent 329257d commit b3a1fee

File tree

60 files changed

+186
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+186
-21
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<module>aws-sdk-java</module>
5454
<module>core</module>
5555
<module>services</module>
56-
<module>services-hll/dynamodb-enhanced</module>
56+
<module>services-custom/dynamodb-enhanced</module>
5757
<module>bom</module>
5858
<module>bom-internal</module>
5959
<module>codegen</module>
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,33 @@
1818
import static org.assertj.core.api.Assertions.assertThat;
1919

2020
import java.time.Instant;
21-
import java.util.Arrays;
2221
import java.util.Collections;
2322
import java.util.LinkedHashMap;
2423
import java.util.Map;
2524
import java.util.UUID;
26-
import java.util.function.Consumer;
2725
import org.junit.AfterClass;
2826
import org.junit.BeforeClass;
2927
import org.junit.Test;
3028
import software.amazon.awssdk.enhanced.dynamodb.model.RequestItem;
3129
import software.amazon.awssdk.enhanced.dynamodb.model.ResponseItem;
30+
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;
3231
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
3332
import software.amazon.awssdk.services.dynamodb.model.DynamoDbException;
3433
import software.amazon.awssdk.services.dynamodb.model.KeyType;
3534
import software.amazon.awssdk.services.dynamodb.model.ResourceInUseException;
3635
import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType;
3736
import software.amazon.awssdk.services.dynamodb.model.TableStatus;
3837
import software.amazon.awssdk.testutils.Waiter;
38+
import software.amazon.awssdk.testutils.service.AwsTestBase;
3939

40-
public class EnhancedClientIntegrationTest {
40+
public class EnhancedClientIntegrationTest extends AwsTestBase {
4141
private static final String TABLE = "books-" + UUID.randomUUID();
42-
private static final DynamoDbClient dynamo = DynamoDbClient.create();
42+
private static final DynamoDbClient dynamo = DynamoDbClient.builder()
43+
.credentialsProvider(CREDENTIALS_PROVIDER_CHAIN)
44+
.build();
45+
private static final DynamoDbAsyncClient dynamoAsync = DynamoDbAsyncClient.builder()
46+
.credentialsProvider(CREDENTIALS_PROVIDER_CHAIN)
47+
.build();
4348

4449
@BeforeClass
4550
public static void setup() {
@@ -74,7 +79,7 @@ public static void cleanup() {
7479

7580
@Test
7681
public void getCanReadTheResultOfPut() throws InterruptedException {
77-
try (DynamoDbEnhancedClient client = DynamoDbEnhancedClient.create()) {
82+
try (DynamoDbEnhancedClient client = DynamoDbEnhancedClient.builder().dynamoDbClient(dynamo).build()) {
7883
Table books = client.table("books");
7984

8085
System.out.println("Putting item...");
@@ -93,7 +98,7 @@ public void getCanReadTheResultOfPut() throws InterruptedException {
9398

9499
@Test
95100
public void getCanReadTheResultOfPutAsync() throws InterruptedException {
96-
try (DynamoDbEnhancedAsyncClient client = DynamoDbEnhancedAsyncClient.create()) {
101+
try (DynamoDbEnhancedAsyncClient client = DynamoDbEnhancedAsyncClient.builder().dynamoDbClient(dynamoAsync).build()) {
97102
AsyncTable books = client.table("books");
98103

99104
System.out.println("Putting item...");

services-hll/dynamodb-enhanced/pom.xml renamed to services-custom/dynamodb-enhanced/pom.xml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@
7171
<version>2.5.25</version>
7272
</dependency>
7373

74+
<dependency>
75+
<groupId>software.amazon.awssdk</groupId>
76+
<artifactId>service-test-utils</artifactId>
77+
<version>2.5.25</version>
78+
<scope>test</scope>
79+
</dependency>
80+
<dependency>
81+
<groupId>software.amazon.awssdk</groupId>
82+
<artifactId>test-utils</artifactId>
83+
<version>2.5.25</version>
84+
<scope>test</scope>
85+
</dependency>
7486
<dependency>
7587
<artifactId>junit</artifactId>
7688
<groupId>junit</groupId>
@@ -86,11 +98,6 @@
8698
<artifactId>mockito-core</artifactId>
8799
<scope>test</scope>
88100
</dependency>
89-
<dependency>
90-
<groupId>software.amazon.awssdk</groupId>
91-
<artifactId>test-utils</artifactId>
92-
<scope>test</scope>
93-
</dependency>
94101
<dependency>
95102
<groupId>log4j</groupId>
96103
<artifactId>log4j</artifactId>

services-hll/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/AsyncTable.java renamed to services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/AsyncTable.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@
3030
* An asynchronous way of interacting with a DynamoDB table. This is usually created via
3131
* {@link DynamoDbEnhancedAsyncClient#table(String)}.
3232
*
33+
* <p>
3334
* This provides facilities for writing {@link RequestItem}s to a table and reading {@link ResponseItem}s from a table. All
3435
* operations are non-blocking, returning a {@link CompletableFuture} for the result, instead of the result itself.
3536
*
37+
* <p>
3638
* Supported operations:
3739
* <ol>
3840
* <li>{@link #getItem(RequestItem)} to retrieve a single item from the table.</li>
3941
* <li>{@link #putItem(RequestItem)} to write a single item to a table.</li>
4042
* </ol>
4143
*
44+
* <p>
4245
* This {@link AsyncTable} will throw exceptions from all operations if the {@link DynamoDbEnhancedAsyncClient} that was used to
4346
* create it is closed.
4447
*/
@@ -58,10 +61,13 @@ default String name() {
5861
* Call DynamoDB to write the requested item, potentially replacing an existing item that has a key matching this item. If
5962
* this does not throw an exception, the item was successfully written.
6063
*
64+
* <p>
6165
* This has the same semantics as {@link DynamoDbAsyncClient#putItem(PutItemRequest)}.
6266
*
67+
* <p>
6368
* This returns a future that will only be completed when the item is done being written.
6469
*
70+
* <p>
6571
* Example Usage:
6672
* <code>
6773
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
@@ -93,12 +99,16 @@ default CompletableFuture<Void> putItem(RequestItem item) {
9399
* Call DynamoDB to write the requested item, potentially replacing an existing item that has a key matching this item. If
94100
* this does not throw an exception, the item was successfully written.
95101
*
102+
* <p>
96103
* This has the same semantics as {@link DynamoDbAsyncClient#putItem(PutItemRequest)}.
97104
*
105+
* <p>
98106
* This returns a future that will only be completed when the item is done being written.
99107
*
108+
* <p>
100109
* This is a less verbose way of calling {@link #putItem(RequestItem)}.
101110
*
111+
* <p>
102112
* Example Usage:
103113
* <code>
104114
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
@@ -129,11 +139,14 @@ default CompletableFuture<Void> putItem(Consumer<RequestItem.Builder> item) {
129139
/**
130140
* Call DynamoDB to read the item that matches the provided key. This will throw an exception if the item cannot be found.
131141
*
142+
* <p>
132143
* This has the same semantics as {@link DynamoDbAsyncClient#getItem(GetItemRequest)}, which means this performs eventually
133144
* consistent reads by default.
134145
*
146+
* <p>
135147
* This returns a future that will only be completed when the item is done being read.
136148
*
149+
* <p>
137150
* Example Usage:
138151
* <code>
139152
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
@@ -162,13 +175,17 @@ default CompletableFuture<ResponseItem> getItem(RequestItem key) {
162175
/**
163176
* Call DynamoDB to read the item that matches the provided key. This will throw an exception if the item cannot be found.
164177
*
178+
* <p>
165179
* This has the same semantics as {@link DynamoDbAsyncClient#getItem(GetItemRequest)}, which means this performs eventually
166180
* consistent reads by default.
167181
*
182+
* <p>
168183
* This returns a future that will only be completed when the item is done being read.
169184
*
185+
* <p>
170186
* This is a less verbose way of calling {@link #getItem(RequestItem)}.
171187
*
188+
* <p>
172189
* Example Usage:
173190
* <code>
174191
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,19 @@
3131
/**
3232
* An asynchronous client for interacting with DynamoDB.
3333
*
34+
* <p>
3435
* This enhanced DynamoDB client replaces the generated {@link DynamoDbAsyncClient} with one that is easier for a Java customer to
3536
* use. It does this by converting between Java built-in types (eg. java.time.Instant) and DynamoDB attribute value types.
3637
*
38+
* <p>
3739
* This can be created using the static {@link #builder()} or {@link #create()} methods. The client must be {@link #close()}d
3840
* when it is done being used.
3941
*
42+
* <p>
4043
* A {@code DynamoDbEnhancedAsyncClient} is thread-safe and relatively expensive to create. It's strongly advised to create a
4144
* single {@code DynamoDbEnhancedAsyncClient} instance that is reused throughout your whole application.
4245
*
46+
* <p>
4347
* Example Usage:
4448
* <code>
4549
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
@@ -60,10 +64,13 @@ public interface DynamoDbEnhancedAsyncClient
6064
/**
6165
* Create a {@link DynamoDbEnhancedAsyncClient} with default configuration.
6266
*
67+
* <p>
6368
* The credentials and region will be loaded automatically, using the same semantics as {@link DynamoDbAsyncClient#create()}.
6469
*
70+
* <p>
6571
* Equivalent to {@code DynamoDbEnhancedAsyncClient.builder().build()}.
6672
*
73+
* <p>
6774
* Example Usage:
6875
* <code>
6976
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
@@ -83,11 +90,14 @@ static DynamoDbEnhancedAsyncClient create() {
8390
* Create a {@link DynamoDbEnhancedAsyncClient.Builder} that can be used to create a {@link DynamoDbEnhancedAsyncClient}
8491
* with custom configuration.
8592
*
93+
* <p>
8694
* The credentials and region will be loaded from the configured {@link DynamoDbAsyncClient} (or
8795
* {@link DynamoDbAsyncClient#create()} if one is not configured).
8896
*
97+
* <p>
8998
* Sensible defaults will be used for any values not directly configured.
9099
*
100+
* <p>
91101
* Example Usage:
92102
* <code>
93103
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
@@ -109,9 +119,11 @@ static Builder builder() {
109119
* Retrieve an {@link AsyncTable} that can be used for interacting with DynamoDB. This does not make any remote calls,
110120
* and as a result does not validate that the requested table actually exists.
111121
*
122+
* <p>
112123
* If the table does not exist, exceptions will be thrown when trying to load or retrieve data from the returned
113124
* {@link AsyncTable} object. The returned {@link AsyncTable} will stop working if the enhanced client is {@link #close()}d.
114125
*
126+
* <p>
115127
* Example Usage:
116128
* <code>
117129
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
@@ -126,11 +138,14 @@ static Builder builder() {
126138
/**
127139
* A builder for {@link DynamoDbEnhancedAsyncClient}.
128140
*
141+
* <p>
129142
* This can be created using the static {@link DynamoDbEnhancedAsyncClient#builder()} method.
130143
*
144+
* <p>
131145
* Multiple clients can be created by the same builder, but unlike clients the builder <b>is not thread safe</b> and
132146
* should not be used from multiple threads at the same time.
133147
*
148+
* <p>
134149
* Example Usage:
135150
* <code>
136151
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
@@ -148,9 +163,11 @@ interface Builder extends CopyableBuilder<Builder, DynamoDbEnhancedAsyncClient>,
148163
* Configure a generated client to be used by the enhanced client to interact with DynamoDB. The enhanced client
149164
* will use the credentials and region of the provided generated client.
150165
*
166+
* <p>
151167
* The provided client <b>will not be closed</b> when {@link DynamoDbEnhancedAsyncClient#close()} is invoked, and
152168
* <b>must</b> be closed separately when it is done being used to prevent leaking resources.
153169
*
170+
* <p>
154171
* If this is not configured, {@link DynamoDbAsyncClient#create()} will be used (and cleaned up with
155172
* {@link DynamoDbEnhancedAsyncClient#close()}).
156173
*/
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,19 @@
3131
/**
3232
* A synchronous client for interacting with DynamoDB.
3333
*
34+
* <p>
3435
* This enhanced DynamoDB client replaces the generated {@link DynamoDbClient} with one that is easier for a Java customer to
3536
* use. It does this by converting between Java built-in types (eg. java.time.Instant) and DynamoDB attribute value types.
3637
*
38+
* <p>
3739
* This can be created using the static {@link #builder()} or {@link #create()} methods. The client must be {@link #close()}d
3840
* when it is done being used.
3941
*
42+
* <p>
4043
* A {@code DynamoDbEnhancedClient} is thread-safe and relatively expensive to create. It's strongly advised to create a single
4144
* {@code DynamoDbEnhancedClient} instance that is reused throughout your whole application.
4245
*
46+
* <p>
4347
* Example Usage:
4448
* <code>
4549
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
@@ -59,10 +63,13 @@ public interface DynamoDbEnhancedClient extends ToCopyableBuilder<DynamoDbEnhanc
5963
/**
6064
* Create a {@link DynamoDbEnhancedClient} with default configuration.
6165
*
66+
* <p>
6267
* The credentials and region will be loaded automatically, using the same semantics as {@link DynamoDbClient#create()}.
6368
*
69+
* <p>
6470
* Equivalent to {@code DynamoDbEnhancedClient.builder().build()}.
6571
*
72+
* <p>
6673
* Example Usage:
6774
* <code>
6875
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
@@ -82,11 +89,14 @@ static DynamoDbEnhancedClient create() {
8289
* Create a {@link DynamoDbEnhancedClient.Builder} that can be used to create a {@link DynamoDbEnhancedClient} with custom
8390
* configuration.
8491
*
92+
* <p>
8593
* The credentials and region will be loaded from the configured {@link DynamoDbClient} (or {@link DynamoDbClient#create()}
8694
* if one is not configured).
8795
*
96+
* <p>
8897
* Sensible defaults will be used for any values not directly configured.
8998
*
99+
* <p>
90100
* Example Usage:
91101
* <code>
92102
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
@@ -108,9 +118,11 @@ static DynamoDbEnhancedClient.Builder builder() {
108118
* Retrieve a {@link Table} that can be used for interacting with DynamoDB. This does not make any remote calls, and as a
109119
* result does not validate that the requested table actually exists.
110120
*
121+
* <p>
111122
* If the table does not exist, exceptions will be thrown when trying to load or retrieve data from the returned
112123
* {@link Table} object. The returned {@link Table} will stop working if the enhanced client is {@link #close()}d.
113124
*
125+
* <p>
114126
* Example Usage:
115127
* <code>
116128
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
@@ -132,11 +144,14 @@ static DynamoDbEnhancedClient.Builder builder() {
132144
/**
133145
* A builder for {@link DynamoDbEnhancedClient}.
134146
*
147+
* <p>
135148
* This can be created using the static {@link DynamoDbEnhancedClient#builder()} method.
136149
*
150+
* <p>
137151
* Multiple clients can be created by the same builder, but unlike clients the builder <b>is not thread safe</b> and
138152
* should not be used from multiple threads at the same time.
139153
*
154+
* <p>
140155
* Example Usage:
141156
* <code>
142157
* // Create a client to use for this example, and then close it. Usually, one client would be used throughout an application.
@@ -154,9 +169,11 @@ interface Builder extends CopyableBuilder<Builder, DynamoDbEnhancedClient>, Conv
154169
* Configure a generated client to be used by the enhanced client to interact with DynamoDB. The enhanced client
155170
* will use the credentials and region of the provided generated client.
156171
*
172+
* <p>
157173
* The provided client <b>will not be closed</b> when {@link DynamoDbEnhancedClient#close()} is invoked, and <b>must</b>
158174
* be closed separately when it is done being used to prevent leaking resources.
159175
*
176+
* <p>
160177
* If this is not configured, {@link DynamoDbClient#create()} will be used (and cleaned up with
161178
* {@link DynamoDbEnhancedClient#close()}).
162179
*/

0 commit comments

Comments
 (0)