Class ChainExtension
- java.lang.Object
-
- software.amazon.awssdk.enhanced.dynamodb.internal.extensions.ChainExtension
-
- All Implemented Interfaces:
DynamoDbEnhancedClientExtension
public final class ChainExtension extends Object implements DynamoDbEnhancedClientExtension
A meta-extension that allows multiple extensions to be chained in a specified order to act as a single composite extension. The order in which extensions will be used depends on the operation, for write operations they will be called in forward order, for read operations they will be called in reverse order. For example :-If you create a chain of three extensions: ChainMapperExtension.create(extension1, extension2, extension3);
When performing any kind of write operation (eg: PutItem, UpdateItem) the beforeWrite() method will be called in forward order: extension1 -> extension2 -> extension3
So the output of extension1 will be passed into extension2, and then the output of extension2 into extension3 and so on. For operations that read (eg: GetItem, UpdateItem) the afterRead() method will be called in reverse order: extension3 -> extension2 -> extension1
This is designed to create a layered pattern when dealing with multiple extensions. One thing to note is that UpdateItem acts as both a write operation and a read operation so the chain will be called both ways within a single operation.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ReadModificationafterRead(DynamoDbExtensionContext.AfterRead context)Implementation of theDynamoDbEnhancedClientExtensioninterface that will call all the chained extensions in reverse order, passing the results of each one to the next and coalescing the results into a single modification.WriteModificationbeforeWrite(DynamoDbExtensionContext.BeforeWrite context)Implementation of theDynamoDbEnhancedClientExtensioninterface that will call all the chained extensions in forward order, passing the results of each one to the next and coalescing the results into a single modification.static ChainExtensioncreate(List<DynamoDbEnhancedClientExtension> extensions)Construct a new instance ofChainExtension.static ChainExtensioncreate(DynamoDbEnhancedClientExtension... extensions)Construct a new instance ofChainExtension.
-
-
-
Method Detail
-
create
public static ChainExtension create(DynamoDbEnhancedClientExtension... extensions)
Construct a new instance ofChainExtension.- Parameters:
extensions- A list ofDynamoDbEnhancedClientExtensionto chain together.- Returns:
- A constructed
ChainExtensionobject.
-
create
public static ChainExtension create(List<DynamoDbEnhancedClientExtension> extensions)
Construct a new instance ofChainExtension.- Parameters:
extensions- A list ofDynamoDbEnhancedClientExtensionto chain together.- Returns:
- A constructed
ChainExtensionobject.
-
beforeWrite
public WriteModification beforeWrite(DynamoDbExtensionContext.BeforeWrite context)
Implementation of theDynamoDbEnhancedClientExtensioninterface that will call all the chained extensions in forward order, passing the results of each one to the next and coalescing the results into a single modification. Multiple conditional statements will be separated by the string " AND ". Expression values will be coalesced unless they conflict in which case an exception will be thrown. UpdateExpressions will be coalesced.- Specified by:
beforeWritein interfaceDynamoDbEnhancedClientExtension- Parameters:
context- ADynamoDbExtensionContext.BeforeWritecontext- Returns:
- A single
WriteModificationrepresenting the coalesced results of all the chained extensions.
-
afterRead
public ReadModification afterRead(DynamoDbExtensionContext.AfterRead context)
Implementation of theDynamoDbEnhancedClientExtensioninterface that will call all the chained extensions in reverse order, passing the results of each one to the next and coalescing the results into a single modification.- Specified by:
afterReadin interfaceDynamoDbEnhancedClientExtension- Parameters:
context- ADynamoDbExtensionContext.AfterReadcontext- Returns:
- A single
ReadModificationrepresenting the final transformation of all the chained extensions.
-
-