public abstract class RequestHandler2 extends Object implements IRequestHandler2
This interface deprecates RequestHandler
by providing access to not only the AWS
response, but also the associated http response via Response
.
Note TimingInfo
is accessible via Request.getAWSRequestMetrics()
and hence is
omitted from the interface to reduce duplication by design.
Constructor and Description |
---|
RequestHandler2() |
Modifier and Type | Method and Description |
---|---|
static RequestHandler2 |
adapt(RequestHandler old)
Returns an instance of request handler adapted to the
RequestHandler2 interface from
the given request handler implementing the deprecated RequestHandler interface. |
void |
afterAttempt(HandlerAfterAttemptContext context)
Runs any additional processing logic on a request after each individual attempt.
|
void |
afterError(Request<?> request,
Response<?> response,
Exception e)
Runs any additional processing logic on a request after it has failed.
|
void |
afterResponse(Request<?> request,
Response<?> response)
Runs any additional processing logic on the specified request (after is has been executed by
the client runtime).
|
void |
beforeAttempt(HandlerBeforeAttemptContext context)
Runs any additional processing logic on a request before each individual attempt is made.
|
AmazonWebServiceRequest |
beforeExecution(AmazonWebServiceRequest request)
Runs any additional processing logic on the specified request object as soon as the request
is provided to the service client.
|
AmazonWebServiceRequest |
beforeMarshalling(AmazonWebServiceRequest request)
Runs any additional processing logic on the specified request object before it is marshaled
into an HTTP request.
|
void |
beforeRequest(Request<?> request)
Runs any additional processing logic on the specified request (before it is executed by the
client runtime).
|
HttpResponse |
beforeUnmarshalling(Request<?> request,
HttpResponse httpResponse)
Runs any additional processing logic on the specified response before it's unmarshalled.
|
public AmazonWebServiceRequest beforeExecution(AmazonWebServiceRequest request)
IRequestHandler2
This request handler is excluded from the client execution time metrics and is run on the application's thread, even for asynchronous requests.
Warning: Modifications to this message will leak out to the user, who might reuse the request
object without realizing that it was modified as part of sending it the first time. For this
reason, we recommend that you only modify the request in the IRequestHandler2.beforeRequest(Request)
method. If you require data that is not available in that method, you should create a
AmazonWebServiceRequest.clone()
of the request (which performs a deep copy of the
handler context map), add any context data you require in the IRequestHandler2.beforeRequest(Request)
method using AmazonWebServiceRequest.addHandlerContext(HandlerContextKey, Object)
, and
return your cloned message from this method. You can then extract that data for use in the
request using HandlerContextAware.getHandlerContext(HandlerContextKey)
.
beforeExecution
in interface IRequestHandler2
request
- the request passed in by the userpublic AmazonWebServiceRequest beforeMarshalling(AmazonWebServiceRequest request)
IRequestHandler2
Warning: Modifications to this message will leak out to the user, who might reuse the request
object without realizing that it was modified as part of sending it the first time. For this
reason, we recommend that you only modify the request in the IRequestHandler2.beforeRequest(Request)
method. If you require data that is not available in that method, you should create a
AmazonWebServiceRequest.clone()
of the request (which performs a deep copy of the
handler context map), add any context data you require in the IRequestHandler2.beforeRequest(Request)
method using AmazonWebServiceRequest.addHandlerContext(HandlerContextKey, Object)
, and
return your cloned message from this method. You can then extract that data for use in the
request using HandlerContextAware.getHandlerContext(HandlerContextKey)
.
beforeMarshalling
in interface IRequestHandler2
request
- the request passed in by the userpublic void beforeRequest(Request<?> request)
IRequestHandler2
beforeRequest
in interface IRequestHandler2
request
- The low level request being processed.public void beforeAttempt(HandlerBeforeAttemptContext context)
IRequestHandler2
beforeAttempt
in interface IRequestHandler2
context
- container for callback-related data; includes the requestpublic HttpResponse beforeUnmarshalling(Request<?> request, HttpResponse httpResponse)
IRequestHandler2
AmazonServiceException
beforeUnmarshalling
in interface IRequestHandler2
request
- The low level request being processed.httpResponse
- The Raw HTTP response before being unmarshalledHttpResponse
to replace the actual response. May be a mutated version of the
original or a completely new HttpResponse
objectpublic void afterAttempt(HandlerAfterAttemptContext context)
IRequestHandler2
afterAttempt
in interface IRequestHandler2
context
- container for the request as well as all possible results of the attemptpublic void afterResponse(Request<?> request, Response<?> response)
IRequestHandler2
afterResponse
in interface IRequestHandler2
request
- The low level request being processed.response
- The response generated from the specified request.public void afterError(Request<?> request, Response<?> response, Exception e)
IRequestHandler2
afterError
in interface IRequestHandler2
request
- The request that generated an error.response
- the response or null if the failure occurred before the response is made availablee
- The error that resulted from executing the request.public static RequestHandler2 adapt(RequestHandler old)
RequestHandler2
interface from
the given request handler implementing the deprecated RequestHandler
interface.Copyright © 2024. All rights reserved.