com.amazonaws.handlers.HandlerContextKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aws-java-sdk-core Show documentation
Show all versions of aws-java-sdk-core Show documentation
The AWS SDK for Java - Core module holds the classes that are used by the individual service clients to interact with Amazon Web Services. Users need to depend on aws-java-sdk artifact for accessing individual client classes.
/*
* Copyright 2015-2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.amazonaws.handlers;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.client.builder.AdvancedConfig;
import java.net.URI;
/**
* A type safe key used for setting and retrieving context in a {@link
* com.amazonaws.Request} object.
*
*
* final HandlerContextKey METRICS_KEY = new HandlerContextKey("METRICS_KEY");
*
* new RequestHandler2(){
*
* @Override
* public void beforeRequest(Request> request) {
* request.addHandlerContext(METRICS_KEY, AWSRequestMetrics
* .Field.HttpRequestTime.name());
* }
*
* @Override
* public void afterResponse(Request> request, Response> response) {
* String metricsKey = request.getHandlerContext(METRICS_KEY);
* }
*
* @Override
* public void afterError(Request> request, Response> response,
* Exception e) { }
* }
*
*/
public class HandlerContextKey {
/**
* The key under which the request credentials are set.
**/
public static final HandlerContextKey AWS_CREDENTIALS = new HandlerContextKey("AWSCredentials");
/**
* The region used to sign the request.
*/
public static final HandlerContextKey SIGNING_REGION = new HandlerContextKey("SigningRegion");
/**
* The optional service name to sign the request. If present, it will override the service name in the client
*/
public static final HandlerContextKey SIGNING_NAME = new HandlerContextKey("SIGNING_NAME");
/**
* The name of the operation for the request.
*/
public static final HandlerContextKey OPERATION_NAME = new HandlerContextKey("OperationName");
/**
* The unique identifier for a service to which the request is being sent.
*/
public static final HandlerContextKey SERVICE_ID = new HandlerContextKey("ServiceId");
/**
* A boolean value indicating if Content-Length header is required by the operation
*/
public static final HandlerContextKey REQUIRES_LENGTH = new HandlerContextKey("RequiresLength");
/**
* A boolean value indicating if the input of the operation has a streaming member.
* If an input shape in operation has streaming trait, then it is a streaming op
*/
public static final HandlerContextKey HAS_STREAMING_INPUT = new HandlerContextKey("HasStreamingInput");
/**
* A boolean value indicating if the output of the operation has a streaming member.
*/
public static final HandlerContextKey HAS_STREAMING_OUTPUT = new HandlerContextKey("HasStreamingOutput");
/**
* Advanced client configuration. Contents will be service specific.
*/
public static final HandlerContextKey ADVANCED_CONFIG = new HandlerContextKey("AdvancedConfig");
/**
* A boolean value indicating if an endpoint is overridden or not
*/
public static final HandlerContextKey ENDPOINT_OVERRIDDEN = new HandlerContextKey("EndpointOverridden");
/**
* The endpoint configured on the client.
*/
public static final HandlerContextKey CLIENT_ENDPOINT = new HandlerContextKey("ClientEndpoint");
private final String name;
public HandlerContextKey(String name) {
if (name == null) {
throw new IllegalArgumentException("Name cannot be null");
}
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
HandlerContextKey> key = (HandlerContextKey>) o;
return name.equals(key.getName());
}
public String getName() {
return name;
}
@Override
public int hashCode() {
return name.hashCode();
}
}