Skip to content

Commit 531e4b0

Browse files
committed
DynamoDB enhanced editing pass.
1 parent b3a1fee commit 531e4b0

File tree

8 files changed

+71
-39
lines changed

8 files changed

+71
-39
lines changed

services-custom/dynamodb-enhanced/README.md

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,45 @@
11
# DynamoDB Enhanced Clients
22

3-
The enhanced DynamoDB client replaces the generated DynamoDB client with
4-
one that is easier for a Java customer to use. It does this by
5-
supporting conversions between Java objects and DynamoDB items, as well
6-
as converting between Java built-in types (eg. java.time.Instant) and
7-
DynamoDB attribute value types.
3+
The enhanced Amazon DynamoDB client replaces the generated DynamoDB
4+
client with one that is easier for a Java customer to use. It does this
5+
by converting Java types into DynamoDB types.
6+
7+
For example, the client makes it possible to persist a Book object in
8+
DynamoDB, without needing to manually convert the fields (e.g.
9+
List<Author>) into DynamoDB-specific types (e.g. List<Map<String,
10+
AttributeValue>>).
811

912
# Current Features
1013

11-
1. Synchronous and asynchronous (non-blocking) clients.
14+
1. Synchronous and asynchronous (nonblocking) clients.
1215
2. Writing a single item to DynamoDB.
1316
3. Reading a single item from DynamoDB.
1417

1518
# Installation
1619

1720
The enhanced client is currently in preview, and **is subject to change
18-
in backwards-incompatible ways**. For this reason, it's not currently
21+
in backward-incompatible ways**. For this reason, it's not currently
1922
released to Maven.
2023

21-
The client must be manually installed in your local maven repository to
22-
be used in your application.
24+
You must manually install the client in your local Maven repository to
25+
use it in your application.
2326

2427
**Step 1:** Check out the project from GitHub.
2528

2629
```bash
2730
git clone git@github.com:aws/aws-sdk-java-v2.git -b dynamodb-enhanced
2831
```
2932

30-
**Step 2:** Compile and install the project to your local maven
31-
repository. This command must be run from the directory to which you
33+
**Step 2:** Compile and install the project to your local Maven
34+
repository. You must run this command from the directory to which you
3235
checked out the project.
3336

3437
```bash
3538
mvn clean install -pl :dynamodb-enhanced -Pquick
3639
```
3740

3841
**Step 3:** Add a dependency on the `dynamodb-enhanced` project to your
39-
pom.xml:
42+
pom.xml file:
4043

4144
```xml
4245
<dependency>
@@ -46,9 +49,24 @@ pom.xml:
4649
</dependency>
4750
```
4851

52+
# Getting Started
53+
54+
The enhanced DynamoDB client is still in preview, and is changing
55+
constantly. Until the client is released, you can refer to the following
56+
for usage examples:
57+
58+
* [The issue for this feature](https://github.com/aws/aws-sdk-java-v2/issues/35):
59+
Here you can see development updates and code samples.
60+
* [The `DynamoDbEnhancedClient` source and JavaDocs](https://github.com/aws/aws-sdk-java-v2/blob/dynamodb-enhanced/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/DynamoDbEnhancedClient.java):
61+
Here you can see up-to-date code samples using the
62+
`DynamoDbEnhancedClient`.
63+
* [The `DynamoDbEnhancedAsyncClient` source and JavaDocs](https://github.com/aws/aws-sdk-java-v2/blob/dynamodb-enhanced/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/DynamoDbEnhancedAsyncClient.java):
64+
Here you can see up-to-date code samples using the
65+
`DynamoDbEnhancedAsyncClient`.
66+
4967
# Examples
5068

51-
### Writing a book to DynamoDB
69+
### Writing a Book to DynamoDB
5270

5371
**Enhanced API Code**
5472

@@ -85,7 +103,7 @@ requestItem.put("authors", AttributeValue.builder().ss("Douglas Adams").build())
85103
client.putItem(r -> r.tableName(TABLE).item(requestItem));
86104
```
87105

88-
### Reading a book from DynamoDB
106+
### Reading a Book from DynamoDB
89107

90108
**Enhanced API Code**
91109

services-custom/dynamodb-enhanced/pom.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@
2626
<artifactId>dynamodb-enhanced</artifactId>
2727
<version>preview-SNAPSHOT</version>
2828
<name>AWS Java SDK :: DynamoDB :: Enhanced Client</name>
29-
<description>The enhanced DynamoDB client replaces the generated DynamoDB client with
30-
one that is easier for a Java customer to use. It does this by
31-
supporting conversions between Java objects and DynamoDB items, as well
32-
as converting between Java built-in types (eg. java.time.Instant) and
33-
DynamoDB attribute value types.</description>
29+
<description>
30+
The enhanced Amazon DynamoDB client replaces the generated DynamoDB
31+
client with one that is easier for a Java customer to use. It does this
32+
by converting Java types into DynamoDB types.
33+
34+
For example, the client makes it possible to persist a Book object in
35+
DynamoDB, without needing to manually convert the fields (e.g.
36+
List&gt;Author&lt;) into DynamoDB-specific types (e.g. List&gt;Map&gt;String,
37+
AttributeValue&lt;&lt;).
38+
</description>
3439
<url>https://aws.amazon.com/sdkforjava</url>
3540

3641
<properties>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*
3333
* <p>
3434
* This provides facilities for writing {@link RequestItem}s to a table and reading {@link ResponseItem}s from a table. All
35-
* operations are non-blocking, returning a {@link CompletableFuture} for the result, instead of the result itself.
35+
* operations are nonblocking, returning a {@link CompletableFuture} for the result, instead of the result itself.
3636
*
3737
* <p>
3838
* Supported operations:
@@ -81,7 +81,7 @@ default String name() {
8181
* .putAttribute("title", "The Hitchhiker's Guide to the Galaxy")
8282
* .build());
8383
*
84-
* // Log when the book is done being written
84+
* // Log when the book is done being written.
8585
* CompletableFuture<Void> resultLoggedFuture = serviceCallCompleteFuture.thenAccept(() -> {
8686
* System.out.println("Book was successfully written!");
8787
* });
@@ -120,7 +120,7 @@ default CompletableFuture<Void> putItem(RequestItem item) {
120120
* booksTable.putItem(item -> item.putAttribute("isbn", "0-330-25864-8")
121121
* .putAttribute("title", "The Hitchhiker's Guide to the Galaxy"));
122122
*
123-
* // Log when the book is done being written
123+
* // Log when the book is done being written.
124124
* CompletableFuture<Void> resultLoggedFuture = serviceCallCompleteFuture.thenAccept(ignored -> {
125125
* System.out.println("Book was successfully written!");
126126
* });

services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/DynamoDbEnhancedAsyncClient.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,18 @@
3333
*
3434
* <p>
3535
* This enhanced DynamoDB client replaces the generated {@link DynamoDbAsyncClient} with one that is easier for a Java customer to
36-
* use. It does this by converting between Java built-in types (eg. java.time.Instant) and DynamoDB attribute value types.
36+
* use. It does this by converting Java types into DynamoDB types.
37+
*
38+
* <p>
39+
* For example, the client makes it possible to persist a Book object in DynamoDB, without needing to manually convert the fields
40+
* (e.g. {@code List<Author>}) into DynamoDB-specific types (e.g. {@code List<Map<String, AttributeValue>>}).
3741
*
3842
* <p>
3943
* This can be created using the static {@link #builder()} or {@link #create()} methods. The client must be {@link #close()}d
4044
* when it is done being used.
4145
*
4246
* <p>
43-
* A {@code DynamoDbEnhancedAsyncClient} is thread-safe and relatively expensive to create. It's strongly advised to create a
47+
* A {@code DynamoDbEnhancedAsyncClient} is thread-safe and relatively expensive to create. We strongly advise you to create a
4448
* single {@code DynamoDbEnhancedAsyncClient} instance that is reused throughout your whole application.
4549
*
4650
* <p>
@@ -65,7 +69,8 @@ public interface DynamoDbEnhancedAsyncClient
6569
* Create a {@link DynamoDbEnhancedAsyncClient} with default configuration.
6670
*
6771
* <p>
68-
* The credentials and region will be loaded automatically, using the same semantics as {@link DynamoDbAsyncClient#create()}.
72+
* The credentials and AWS Region will be loaded automatically, using the same semantics as
73+
* {@link DynamoDbAsyncClient#create()}.
6974
*
7075
* <p>
7176
* Equivalent to {@code DynamoDbEnhancedAsyncClient.builder().build()}.
@@ -91,7 +96,7 @@ static DynamoDbEnhancedAsyncClient create() {
9196
* with custom configuration.
9297
*
9398
* <p>
94-
* The credentials and region will be loaded from the configured {@link DynamoDbAsyncClient} (or
99+
* The credentials and AWS Region will be loaded from the configured {@link DynamoDbAsyncClient} (or
95100
* {@link DynamoDbAsyncClient#create()} if one is not configured).
96101
*
97102
* <p>
@@ -142,7 +147,7 @@ static Builder builder() {
142147
* This can be created using the static {@link DynamoDbEnhancedAsyncClient#builder()} method.
143148
*
144149
* <p>
145-
* Multiple clients can be created by the same builder, but unlike clients the builder <b>is not thread safe</b> and
150+
* Multiple clients can be created by the same builder, but unlike clients the builder <b>is not thread-safe</b> and
146151
* should not be used from multiple threads at the same time.
147152
*
148153
* <p>
@@ -161,7 +166,7 @@ static Builder builder() {
161166
interface Builder extends CopyableBuilder<Builder, DynamoDbEnhancedAsyncClient>, ConverterAware.Builder {
162167
/**
163168
* Configure a generated client to be used by the enhanced client to interact with DynamoDB. The enhanced client
164-
* will use the credentials and region of the provided generated client.
169+
* will use the credentials and AWS Region of the provided generated client.
165170
*
166171
* <p>
167172
* The provided client <b>will not be closed</b> when {@link DynamoDbEnhancedAsyncClient#close()} is invoked, and

services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/DynamoDbEnhancedClient.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,18 @@
3333
*
3434
* <p>
3535
* This enhanced DynamoDB client replaces the generated {@link DynamoDbClient} with one that is easier for a Java customer to
36-
* use. It does this by converting between Java built-in types (eg. java.time.Instant) and DynamoDB attribute value types.
36+
* use. It does this by converting Java types into DynamoDB types.
37+
*
38+
* <p>
39+
* For example, the client makes it possible to persist a Book object in DynamoDB, without needing to manually convert the fields
40+
* (e.g. {@code List<Author>}) into DynamoDB-specific types (e.g. {@code List<Map<String, AttributeValue>>}).
3741
*
3842
* <p>
3943
* This can be created using the static {@link #builder()} or {@link #create()} methods. The client must be {@link #close()}d
4044
* when it is done being used.
4145
*
4246
* <p>
43-
* A {@code DynamoDbEnhancedClient} is thread-safe and relatively expensive to create. It's strongly advised to create a single
47+
* A {@code DynamoDbEnhancedClient} is thread-safe and relatively expensive to create. We strongly advise you to create a single
4448
* {@code DynamoDbEnhancedClient} instance that is reused throughout your whole application.
4549
*
4650
* <p>
@@ -64,7 +68,7 @@ public interface DynamoDbEnhancedClient extends ToCopyableBuilder<DynamoDbEnhanc
6468
* Create a {@link DynamoDbEnhancedClient} with default configuration.
6569
*
6670
* <p>
67-
* The credentials and region will be loaded automatically, using the same semantics as {@link DynamoDbClient#create()}.
71+
* The credentials and AWS Region will be loaded automatically, using the same semantics as {@link DynamoDbClient#create()}.
6872
*
6973
* <p>
7074
* Equivalent to {@code DynamoDbEnhancedClient.builder().build()}.
@@ -90,8 +94,8 @@ static DynamoDbEnhancedClient create() {
9094
* configuration.
9195
*
9296
* <p>
93-
* The credentials and region will be loaded from the configured {@link DynamoDbClient} (or {@link DynamoDbClient#create()}
94-
* if one is not configured).
97+
* The credentials and AWS Region will be loaded from the configured {@link DynamoDbClient} (or
98+
* {@link DynamoDbClient#create()} if one is not configured).
9599
*
96100
* <p>
97101
* Sensible defaults will be used for any values not directly configured.
@@ -148,7 +152,7 @@ static DynamoDbEnhancedClient.Builder builder() {
148152
* This can be created using the static {@link DynamoDbEnhancedClient#builder()} method.
149153
*
150154
* <p>
151-
* Multiple clients can be created by the same builder, but unlike clients the builder <b>is not thread safe</b> and
155+
* Multiple clients can be created by the same builder, but unlike clients the builder <b>is not thread-safe</b> and
152156
* should not be used from multiple threads at the same time.
153157
*
154158
* <p>
@@ -167,7 +171,7 @@ static DynamoDbEnhancedClient.Builder builder() {
167171
interface Builder extends CopyableBuilder<Builder, DynamoDbEnhancedClient>, ConverterAware.Builder {
168172
/**
169173
* Configure a generated client to be used by the enhanced client to interact with DynamoDB. The enhanced client
170-
* will use the credentials and region of the provided generated client.
174+
* will use the credentials and AWS Region of the provided generated client.
171175
*
172176
* <p>
173177
* The provided client <b>will not be closed</b> when {@link DynamoDbEnhancedClient#close()} is invoked, and <b>must</b>

services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/converter/DefaultConverterChain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public final class DefaultConverterChain implements ItemAttributeValueConverter
9191

9292
// InstanceOf Converters
9393
// Potential optimization: allow InstanceOf converters to specify a set of
94-
// types that should be cached in an eager fashion (eg. DefaultRequestItem)
94+
// types that should be cached in an eager fashion (e.g. DefaultRequestItem)
9595
.addConverter(new RequestItemConverter())
9696
.addConverter(new ResponseItemConverter())
9797
.addConverter(new ListConverter())

services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/model/ConvertableItemAttributeValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public interface ConvertableItemAttributeValue {
6767
* {@link #asList(Class)}. Maps should use {@link #asMap(Class, Class)}.
6868
*
6969
* <p>
70-
* When creating a {@link TypeToken}, you must create an anonymous sub-class, eg.
70+
* When creating a {@link TypeToken}, you must create an anonymous sub-class, e.g.
7171
* {@code new TypeToken<Collection<String>>()&#123;&#125;} (note the extra {}).
7272
*/
7373
<T> T as(TypeToken<T> type);

services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/model/TypeToken.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private static Type validateIsSupportedType(Type type) {
105105
/**
106106
* Retrieve the {@link Class} object that this type token represents.
107107
*
108-
* Eg. For {@code TypeToken<String>}, this would return {@code String.class}.
108+
* e.g. For {@code TypeToken<String>}, this would return {@code String.class}.
109109
*/
110110
public Class<T> rawClass() {
111111
return rawClass;
@@ -115,7 +115,7 @@ public Class<T> rawClass() {
115115
* Retrieve the {@link Class} objects of any type parameters for the class that this type token represents.
116116
*
117117
* <p>
118-
* Eg. For {@code TypeToken<List<String>>}, this would return {@code String.class}, and {@link #rawClass()} would
118+
* e.g. For {@code TypeToken<List<String>>}, this would return {@code String.class}, and {@link #rawClass()} would
119119
* return {@code List.class}.
120120
*
121121
* <p>

0 commit comments

Comments
 (0)