Package com.amazonaws.handlers
Class StackedRequestHandler
- java.lang.Object
-
- com.amazonaws.handlers.StackedRequestHandler
-
- All Implemented Interfaces:
IRequestHandler2
@ThreadSafe public class StackedRequestHandler extends Object implements IRequestHandler2
CompositeRequestHandler2
to execute a chain ofRequestHandler2
implementations in stack order. That is if you have request handlers R1, R2, R3 the order of execution is as followsR1.beforeMarshalling R2.beforeMarshalling R3.beforeMarshalling R1.beforeRequest R2.beforeRequest R3.beforeRequest R3.beforeUnmarshalling R2.beforeUnmarshalling R1.beforeUnmarshalling R3.after(Response|Error) R2.after(Response|Error) R1.after(Response|Error)
-
-
Constructor Summary
Constructors Constructor Description StackedRequestHandler(RequestHandler2... requestHandlers)
StackedRequestHandler(List<RequestHandler2> requestHandlers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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).AmazonWebServiceRequest
beforeMarshalling(AmazonWebServiceRequest origRequest)
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 origHttpResponse)
Runs any additional processing logic on the specified response before it's unmarshalled.
-
-
-
Constructor Detail
-
StackedRequestHandler
public StackedRequestHandler(RequestHandler2... requestHandlers)
-
StackedRequestHandler
public StackedRequestHandler(List<RequestHandler2> requestHandlers)
-
-
Method Detail
-
beforeMarshalling
public AmazonWebServiceRequest beforeMarshalling(AmazonWebServiceRequest origRequest)
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:
origRequest
- the request passed in by the user- Returns:
- the (possibly different) request to marshal
-
beforeRequest
public void beforeRequest(Request<?> request)
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
public HttpResponse beforeUnmarshalling(Request<?> request, HttpResponse origHttpResponse)
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.origHttpResponse
- 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
public void afterResponse(Request<?> request, Response<?> response)
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
public void afterError(Request<?> request, Response<?> response, Exception e)
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.
-
-