Package com.amazonaws.handlers
Class RequestHandler2
java.lang.Object
com.amazonaws.handlers.RequestHandler2
- All Implemented Interfaces:
IRequestHandler2
- Direct Known Subclasses:
CredentialsRequestHandler
Interface for addition request handling in clients. A request handler is executed on a request
object before it is sent to the client runtime to be executed.
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RequestHandler2
adapt
(RequestHandler old) Returns an instance of request handler adapted to theRequestHandler2
interface from the given request handler implementing the deprecatedRequestHandler
interface.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).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).beforeUnmarshalling
(Request<?> request, HttpResponse httpResponse) Runs any additional processing logic on the specified response before it's unmarshalled.
-
Constructor Details
-
RequestHandler2
public RequestHandler2()
-
-
Method Details
-
beforeMarshalling
Description copied from interface:IRequestHandler2
Runs any additional processing logic on the specified request object before it is marshaled into an HTTP request.If you're going to modify the request, make sure to clone it first, modify the clone, and return it from this method. Otherwise your changes 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.
- Specified by:
beforeMarshalling
in interfaceIRequestHandler2
- Parameters:
request
- the request passed in by the user- Returns:
- the (possibly different) request to marshal
-
beforeRequest
Description copied from interface:IRequestHandler2
Runs any additional processing logic on the specified request (before it is executed by the client runtime).- Specified by:
beforeRequest
in interfaceIRequestHandler2
- Parameters:
request
- The low level request being processed.
-
beforeUnmarshalling
Description copied from interface:IRequestHandler2
Runs any additional processing logic on the specified response before it's unmarshalled. This callback is only invoked on successful responses that will be unmarsahlled into an appropriate modeled class and not for unsuccessful responses that will be unmarshalled into a subclass ofAmazonServiceException
- Specified by:
beforeUnmarshalling
in interfaceIRequestHandler2
- Parameters:
request
- The low level request being processed.httpResponse
- The Raw HTTP response before being unmarshalled- Returns:
HttpResponse
to replace the actual response. May be a mutated version of the original or a completely newHttpResponse
object
-
afterResponse
Description copied from interface:IRequestHandler2
Runs any additional processing logic on the specified request (after is has been executed by the client runtime).- Specified by:
afterResponse
in interfaceIRequestHandler2
- Parameters:
request
- The low level request being processed.response
- The response generated from the specified request.
-
afterError
Description copied from interface:IRequestHandler2
Runs any additional processing logic on a request after it has failed.- Specified by:
afterError
in interfaceIRequestHandler2
- Parameters:
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.
-
adapt
Returns an instance of request handler adapted to theRequestHandler2
interface from the given request handler implementing the deprecatedRequestHandler
interface.
-