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> voidaddHandlerContext(HandlerContextKey<X> key, X value)Adds a context to the request object that is visible to allRequestHandler2.voidaddHeader(String name, String value)Sets the specified header for this request.voidaddParameter(String name, String value)Adds the specified request parameter to this request.voidaddParameters(String name, List<String> values)Adds the specified request parameter and list of values to this request.AWSRequestMetricsgetAWSRequestMetrics()Returns the request metrics.InputStreamgetContent()Returns the optional stream containing the payload data to include for this request.InputStreamgetContentUnwrapped()Returns the optional raw stream containing the payload data to include for this request, with all progress stream wrappers.URIgetEndpoint()Returns the service endpoint (ex: "https://ec2.amazonaws.com") to which this request should be sent.<X> XgetHandlerContext(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.HttpMethodNamegetHttpMethod()Returns the HTTP method (GET, POST, etc) to use when sending this request.AmazonWebServiceRequestgetOriginalRequest()Returns the original, user facing request object which this internal request object is representing.ObjectgetOriginalRequestObject()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.ReadLimitInfogetReadLimitInfo()Returns the read limit info about the original request.StringgetResourcePath()Returns the path to the resource being requested.StringgetServiceName()intgetTimeOffset()Returns the optional value for time offset for this request.voidsetAWSRequestMetrics(AWSRequestMetrics metrics)Bind the request metrics to the request.voidsetContent(InputStream content)Sets the optional stream containing the payload data to include for this request.voidsetEndpoint(URI endpoint)Sets the service endpoint (ex: "https://ec2.amazonaws.com") to which this request should be sent.voidsetHeaders(Map<String,String> headers)Sets all headers, clearing any existing ones.voidsetHttpMethod(HttpMethodName httpMethod)Sets the HTTP method (GET, POST, etc) to use when sending this request.voidsetParameters(Map<String,List<String>> parameters)Sets all parameters, clearing any existing values.voidsetResourcePath(String resourcePath)Sets the path to the resource being requested.voidsetTimeOffset(int timeOffset)Sets the optional value for time offset for this request.StringtoString()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:
getOriginalRequestin 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:SignableRequestSets the specified header for this request.- Specified by:
addHeaderin 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:SignableRequestReturns a map of all the headers included in this request.- Specified by:
getHeadersin 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:RequestSets the path to the resource being requested.- Specified by:
setResourcePathin 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:SignableRequestReturns the path to the resource being requested.- Specified by:
getResourcePathin 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:SignableRequestAdds the specified request parameter to this request.- Specified by:
addParameterin 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:RequestAdds the specified request parameter and list of values to this request.- Specified by:
addParametersin 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:SignableRequestReturns a map of all parameters in this request.- Specified by:
getParametersin 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:RequestAdds the specified request parameter to this request, and returns the updated request object.- Specified by:
withParameterin 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:SignableRequestReturns the HTTP method (GET, POST, etc) to use when sending this request.- Specified by:
getHttpMethodin 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:RequestSets the HTTP method (GET, POST, etc) to use when sending this request.- Specified by:
setHttpMethodin 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:RequestSets the service endpoint (ex: "https://ec2.amazonaws.com") to which this request should be sent.- Specified by:
setEndpointin 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:SignableRequestReturns the service endpoint (ex: "https://ec2.amazonaws.com") to which this request should be sent.- Specified by:
getEndpointin interfaceSignableRequest<T>- Returns:
- The service endpoint to which this request should be sent.
- See Also:
SignableRequest.getEndpoint()
-
getServiceName
public String getServiceName()
- Specified by:
getServiceNamein 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:SignableRequestReturns the optional stream containing the payload data to include for this request. Not all requests will contain payload data.- Specified by:
getContentin 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:SignableRequestSets the optional stream containing the payload data to include for this request. This is used, for example, for S3 chunk encoding.- Specified by:
setContentin 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:RequestSets all headers, clearing any existing ones.- Specified by:
setHeadersin interfaceRequest<T>- See Also:
Request.setHeaders(java.util.Map)
-
setParameters
public void setParameters(Map<String,List<String>> parameters)
Description copied from interface:RequestSets all parameters, clearing any existing values. Note that List values within the parameters Map must use an implementation that supports null values.- Specified by:
setParametersin interfaceRequest<T>- See Also:
Request.setParameters(java.util.Map)
-
getTimeOffset
public int getTimeOffset()
Description copied from interface:SignableRequestReturns 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:
getTimeOffsetin 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:RequestSets 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:
setTimeOffsetin 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:RequestSets 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:
withTimeOffsetin interfaceRequest<T>- Returns:
- The updated request object.
- See Also:
Request.setTimeOffset(int)
-
getAWSRequestMetrics
public AWSRequestMetrics getAWSRequestMetrics()
Description copied from interface:RequestReturns the request metrics.- Specified by:
getAWSRequestMetricsin interfaceRequest<T>
-
setAWSRequestMetrics
public void setAWSRequestMetrics(AWSRequestMetrics metrics)
Description copied from interface:RequestBind the request metrics to the request. Note metrics can be captured before the request is created.- Specified by:
setAWSRequestMetricsin interfaceRequest<T>
-
addHandlerContext
public <X> void addHandlerContext(HandlerContextKey<X> key, X value)
Description copied from interface:RequestAdds 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:
addHandlerContextin 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:RequestReturn the context for the given key if present; else return null.- Specified by:
getHandlerContextin interfaceRequest<T>- Parameters:
key- the key for the context- Returns:
- the context if present else null.
-
getContentUnwrapped
public InputStream getContentUnwrapped()
Description copied from interface:SignableRequestReturns 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:
getContentUnwrappedin 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:SignableRequestReturns the read limit info about the original request.- Specified by:
getReadLimitInfoin interfaceSignableRequest<T>
-
getOriginalRequestObject
public Object getOriginalRequestObject()
Description copied from interface:SignableRequestReturns the original, user facing request object which this internal request object is representing.- Specified by:
getOriginalRequestObjectin interfaceSignableRequest<T>- Returns:
- an instance of request as an
Object.
-
-