Package com.amazonaws
Class DefaultRequest<T>
- java.lang.Object
-
- com.amazonaws.DefaultRequest<T>
-
- All Implemented Interfaces:
Request<T>
,SignableRequest<T>
public class DefaultRequest<T> extends Object implements Request<T>
Default implementation of the Request interface.This class is only intended for internal use inside the AWS client libraries. Callers shouldn't ever interact directly with objects of this class.
-
-
Constructor Summary
Constructors Constructor Description DefaultRequest(AmazonWebServiceRequest originalRequest, String serviceName)
Constructs a new DefaultRequest with the specified service name and the original, user facing request object.DefaultRequest(String serviceName)
Constructs a new DefaultRequest with the specified service name and no specified original, user facing request object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <X> void
addHandlerContext(HandlerContextKey<X> key, X value)
Adds a context to the request object that is visible to allRequestHandler2
.void
addHeader(String name, String value)
Sets the specified header for this request.void
addParameter(String name, String value)
Adds the specified request parameter to this request.void
addParameters(String name, List<String> values)
Adds the specified request parameter and list of values to this request.AWSRequestMetrics
getAWSRequestMetrics()
Returns the request metrics.InputStream
getContent()
Returns the optional stream containing the payload data to include for this request.InputStream
getContentUnwrapped()
Returns the optional raw stream containing the payload data to include for this request, with all progress stream wrappers.URI
getEndpoint()
Returns the service endpoint (ex: "https://ec2.amazonaws.com") to which this request should be sent.<X> X
getHandlerContext(HandlerContextKey<X> key)
Return the context for the given key if present; else return null.Map<String,String>
getHeaders()
Returns a map of all the headers included in this request.HttpMethodName
getHttpMethod()
Returns the HTTP method (GET, POST, etc) to use when sending this request.AmazonWebServiceRequest
getOriginalRequest()
Returns the original, user facing request object which this internal request object is representing.Object
getOriginalRequestObject()
Returns the original, user facing request object which this internal request object is representing.Map<String,List<String>>
getParameters()
Returns a map of all parameters in this request.ReadLimitInfo
getReadLimitInfo()
Returns the read limit info about the original request.String
getResourcePath()
Returns the path to the resource being requested.String
getServiceName()
int
getTimeOffset()
Returns the optional value for time offset for this request.void
setAWSRequestMetrics(AWSRequestMetrics metrics)
Bind the request metrics to the request.void
setContent(InputStream content)
Sets the optional stream containing the payload data to include for this request.void
setEndpoint(URI endpoint)
Sets the service endpoint (ex: "https://ec2.amazonaws.com") to which this request should be sent.void
setHeaders(Map<String,String> headers)
Sets all headers, clearing any existing ones.void
setHttpMethod(HttpMethodName httpMethod)
Sets the HTTP method (GET, POST, etc) to use when sending this request.void
setParameters(Map<String,List<String>> parameters)
Sets all parameters, clearing any existing values.void
setResourcePath(String resourcePath)
Sets the path to the resource being requested.void
setTimeOffset(int timeOffset)
Sets the optional value for time offset for this request.String
toString()
Request<T>
withParameter(String name, String value)
Adds the specified request parameter to this request, and returns the updated request object.Request<T>
withTimeOffset(int timeOffset)
Sets the optional value for time offset for this request.
-
-
-
Constructor Detail
-
DefaultRequest
public DefaultRequest(AmazonWebServiceRequest originalRequest, String serviceName)
Constructs a new DefaultRequest with the specified service name and the original, user facing request object.- Parameters:
serviceName
- The name of the service to which this request is being sent.originalRequest
- The original, user facing, AWS request being represented by this internal request object.
-
DefaultRequest
public DefaultRequest(String serviceName)
Constructs a new DefaultRequest with the specified service name and no specified original, user facing request object.- Parameters:
serviceName
- The name of the service to which this request is being sent.
-
-
Method Detail
-
getOriginalRequest
public AmazonWebServiceRequest getOriginalRequest()
Returns the original, user facing request object which this internal request object is representing.- Specified by:
getOriginalRequest
in interfaceRequest<T>
- Returns:
- The original, user facing request object which this request object is representing.
-
addHeader
public void addHeader(String name, String value)
Description copied from interface:SignableRequest
Sets the specified header for this request.- Specified by:
addHeader
in interfaceSignableRequest<T>
- Parameters:
name
- The name of the header to set.value
- The header's value.- See Also:
SignableRequest.addHeader(java.lang.String, java.lang.String)
-
getHeaders
public Map<String,String> getHeaders()
Description copied from interface:SignableRequest
Returns a map of all the headers included in this request.- Specified by:
getHeaders
in interfaceSignableRequest<T>
- Returns:
- A map of all the headers included in this request.
- See Also:
SignableRequest.getHeaders()
-
setResourcePath
public void setResourcePath(String resourcePath)
Description copied from interface:Request
Sets the path to the resource being requested.- Specified by:
setResourcePath
in interfaceRequest<T>
- Parameters:
resourcePath
- The path to the resource being requested.- See Also:
Request.setResourcePath(java.lang.String)
-
getResourcePath
public String getResourcePath()
Description copied from interface:SignableRequest
Returns the path to the resource being requested.- Specified by:
getResourcePath
in interfaceSignableRequest<T>
- Returns:
- The path to the resource being requested.
- See Also:
SignableRequest.getResourcePath()
-
addParameter
public void addParameter(String name, String value)
Description copied from interface:SignableRequest
Adds the specified request parameter to this request.- Specified by:
addParameter
in interfaceSignableRequest<T>
- Parameters:
name
- The name of the request parameter.value
- The value of the request parameter.- See Also:
SignableRequest.addParameter(java.lang.String, java.lang.String)
-
addParameters
public void addParameters(String name, List<String> values)
Description copied from interface:Request
Adds the specified request parameter and list of values to this request.- Specified by:
addParameters
in interfaceRequest<T>
- Parameters:
name
- The name of the request parameter.values
- The value of the request parameter.- See Also:
Request.addParameters(java.lang.String, java.util.List)
-
getParameters
public Map<String,List<String>> getParameters()
Description copied from interface:SignableRequest
Returns a map of all parameters in this request.- Specified by:
getParameters
in interfaceSignableRequest<T>
- Returns:
- A map of all parameters in this request.
- See Also:
SignableRequest.getParameters()
-
withParameter
public Request<T> withParameter(String name, String value)
Description copied from interface:Request
Adds the specified request parameter to this request, and returns the updated request object.- Specified by:
withParameter
in interfaceRequest<T>
- Parameters:
name
- The name of the request parameter.value
- The value of the request parameter.- Returns:
- The updated request object.
- See Also:
Request.withParameter(java.lang.String, java.lang.String)
-
getHttpMethod
public HttpMethodName getHttpMethod()
Description copied from interface:SignableRequest
Returns the HTTP method (GET, POST, etc) to use when sending this request.- Specified by:
getHttpMethod
in interfaceSignableRequest<T>
- Returns:
- The HTTP method to use when sending this request.
- See Also:
SignableRequest.getHttpMethod()
-
setHttpMethod
public void setHttpMethod(HttpMethodName httpMethod)
Description copied from interface:Request
Sets the HTTP method (GET, POST, etc) to use when sending this request.- Specified by:
setHttpMethod
in interfaceRequest<T>
- Parameters:
httpMethod
- The HTTP method to use when sending this request.- See Also:
Request.setHttpMethod(com.amazonaws.http.HttpMethodName)
-
setEndpoint
public void setEndpoint(URI endpoint)
Description copied from interface:Request
Sets the service endpoint (ex: "https://ec2.amazonaws.com") to which this request should be sent.- Specified by:
setEndpoint
in interfaceRequest<T>
- Parameters:
endpoint
- The service endpoint to which this request should be sent.- See Also:
Request.setEndpoint(java.net.URI)
-
getEndpoint
public URI getEndpoint()
Description copied from interface:SignableRequest
Returns the service endpoint (ex: "https://ec2.amazonaws.com") to which this request should be sent.- Specified by:
getEndpoint
in interfaceSignableRequest<T>
- Returns:
- The service endpoint to which this request should be sent.
- See Also:
SignableRequest.getEndpoint()
-
getServiceName
public String getServiceName()
- Specified by:
getServiceName
in interfaceRequest<T>
- Returns:
- The name of the Amazon service this request is for. This is used
as the service name set in request metrics and service
exceptions. This is NOT the same as the service name returned by
AmazonWebServiceClient.getServiceName()
which is used for signing purpose. - See Also:
Request.getServiceName()
-
getContent
public InputStream getContent()
Description copied from interface:SignableRequest
Returns the optional stream containing the payload data to include for this request. Not all requests will contain payload data.- Specified by:
getContent
in interfaceSignableRequest<T>
- Returns:
- The optional stream containing the payload data to include for this request.
- See Also:
SignableRequest.getContent()
-
setContent
public void setContent(InputStream content)
Description copied from interface:SignableRequest
Sets the optional stream containing the payload data to include for this request. This is used, for example, for S3 chunk encoding.- Specified by:
setContent
in interfaceSignableRequest<T>
- Parameters:
content
- The optional stream containing the payload data to include for this request.- See Also:
SignableRequest.setContent(java.io.InputStream)
-
setHeaders
public void setHeaders(Map<String,String> headers)
Description copied from interface:Request
Sets all headers, clearing any existing ones.- Specified by:
setHeaders
in interfaceRequest<T>
- See Also:
Request.setHeaders(java.util.Map)
-
setParameters
public void setParameters(Map<String,List<String>> parameters)
Description copied from interface:Request
Sets all parameters, clearing any existing values. Note that List values within the parameters Map must use an implementation that supports null values.- Specified by:
setParameters
in interfaceRequest<T>
- See Also:
Request.setParameters(java.util.Map)
-
getTimeOffset
public int getTimeOffset()
Description copied from interface:SignableRequest
Returns the optional value for time offset for this request. This will be used by the signer to adjust for potential clock skew. Value is in seconds, positive values imply the current clock is "fast", negative values imply clock is slow.- Specified by:
getTimeOffset
in interfaceSignableRequest<T>
- Returns:
- The optional value for time offset (in seconds) for this request.
- See Also:
SignableRequest.getTimeOffset()
-
setTimeOffset
public void setTimeOffset(int timeOffset)
Description copied from interface:Request
Sets the optional value for time offset for this request. This will be used by the signer to adjust for potential clock skew. Value is in seconds, positive values imply the current clock is "fast", negative values imply clock is slow.- Specified by:
setTimeOffset
in interfaceRequest<T>
- Parameters:
timeOffset
- The optional value for time offset (in seconds) for this request.- See Also:
Request.setTimeOffset(int)
-
withTimeOffset
public Request<T> withTimeOffset(int timeOffset)
Description copied from interface:Request
Sets the optional value for time offset for this request. This will be used by the signer to adjust for potential clock skew. Value is in seconds, positive values imply the current clock is "fast", negative values imply clock is slow.- Specified by:
withTimeOffset
in interfaceRequest<T>
- Returns:
- The updated request object.
- See Also:
Request.setTimeOffset(int)
-
getAWSRequestMetrics
public AWSRequestMetrics getAWSRequestMetrics()
Description copied from interface:Request
Returns the request metrics.- Specified by:
getAWSRequestMetrics
in interfaceRequest<T>
-
setAWSRequestMetrics
public void setAWSRequestMetrics(AWSRequestMetrics metrics)
Description copied from interface:Request
Bind the request metrics to the request. Note metrics can be captured before the request is created.- Specified by:
setAWSRequestMetrics
in interfaceRequest<T>
-
addHandlerContext
public <X> void addHandlerContext(HandlerContextKey<X> key, X value)
Description copied from interface:Request
Adds a context to the request object that is visible to allRequestHandler2
. Note that, context added here will available only for the scope of the request execution and will not be marshalled over the wire.- Specified by:
addHandlerContext
in interfaceRequest<T>
- Parameters:
key
- the key for the property being set in the request.value
- the value for the property being set in the request.
-
getHandlerContext
public <X> X getHandlerContext(HandlerContextKey<X> key)
Description copied from interface:Request
Return the context for the given key if present; else return null.- Specified by:
getHandlerContext
in interfaceRequest<T>
- Parameters:
key
- the key for the context- Returns:
- the context if present else null.
-
getContentUnwrapped
public InputStream getContentUnwrapped()
Description copied from interface:SignableRequest
Returns the optional raw stream containing the payload data to include for this request, with all progress stream wrappers. Not all requests contain payload data.- Specified by:
getContentUnwrapped
in interfaceSignableRequest<T>
- Returns:
- The optional raw stream containing the payload data to include for this request, with all progress stream wrappers removed.
-
getReadLimitInfo
public ReadLimitInfo getReadLimitInfo()
Description copied from interface:SignableRequest
Returns the read limit info about the original request.- Specified by:
getReadLimitInfo
in interfaceSignableRequest<T>
-
getOriginalRequestObject
public Object getOriginalRequestObject()
Description copied from interface:SignableRequest
Returns the original, user facing request object which this internal request object is representing.- Specified by:
getOriginalRequestObject
in interfaceSignableRequest<T>
- Returns:
- an instance of request as an
Object
.
-
-