Class ExecutionAttribute<T>
java.lang.Object
software.amazon.awssdk.core.interceptor.ExecutionAttribute<T>
- Type Parameters:
T
- The type of data associated with this attribute.
An attribute attached to a particular execution, stored in
ExecutionAttributes
.
This is typically used as a static final field in an ExecutionInterceptor
:
class MyExecutionInterceptor implements ExecutionInterceptor {
private static final ExecutionAttribute<String> DATA = new ExecutionAttribute<>();
public void beforeExecution(Context.BeforeExecution execution, ExecutionAttributes executionAttributes) {
executionAttributes.put(DATA, "Request: " + execution.request());
}
public void afterExecution(Context.AfterExecution execution, ExecutionAttributes executionAttributes) {
String data = executionAttributes.get(DATA); // Retrieve the value saved in beforeExecution.
}
}
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
-
Constructor Summary
ConstructorDescriptionExecutionAttribute
(String name) Creates a newExecutionAttribute
bound to the provided type param. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
U> ExecutionAttribute.DerivedAttributeBuilder <T, U> derivedBuilder
(String name, Class<T> attributeType, ExecutionAttribute<U> realAttribute) Create an execution attribute whose value is derived from another attribute.boolean
This override considers execution attributes with the same name to be the same object for the purpose of attribute merge.int
hashCode()
This override considers execution attributes with the same name to be the same object for the purpose of attribute merge.toString()
-
Constructor Details
-
ExecutionAttribute
Creates a newExecutionAttribute
bound to the provided type param.- Parameters:
name
- Descriptive name for the attribute, used primarily for debugging purposes.
-
-
Method Details
-
derivedBuilder
public static <T,U> ExecutionAttribute.DerivedAttributeBuilder<T,U> derivedBuilder(String name, Class<T> attributeType, ExecutionAttribute<U> realAttribute) Create an execution attribute whose value is derived from another attribute.Whenever this value is read, its value is read from a different "real" attribute, and whenever this value is written its value is written to the "real" attribute, instead.
This is useful when new attributes are created to replace old attributes, but for backwards-compatibility those old attributes still need to be made available.
- Parameters:
name
- The name of the attribute to createattributeType
- The type of the attribute being createdrealAttribute
- The "real" attribute from which this attribute is derived
-
toString
-
equals
This override considers execution attributes with the same name to be the same object for the purpose of attribute merge. -
hashCode
public int hashCode()This override considers execution attributes with the same name to be the same object for the purpose of attribute merge.
-