Package org.glassfish.jersey.client.spi
Interface PostInvocationInterceptor
The interceptor of a client request invocation that is executed after the request invocation itself, i.e. after the
ClientResponseFilters are executed.
It is ensured that all PostInvocationInterceptors are executed after the request, in the reverse order given by the
Priority, the higher the priority the later the execution. Any Throwable thrown when
the afterRequest(ClientRequestContext, ClientResponseContext) or
onException(ClientRequestContext, ExceptionContext) is being processed is accumulated and
a multi RuntimeException with other exceptions supressed is being thrown at the end
(possibly encapsulated in a ProcessingException if not a single RuntimeException),
unless resolved by onException(ClientRequestContext, ExceptionContext). During the
PostInvocationInterceptor processing, the accumulated Deque of the Throwables is available in the
PostInvocationInterceptor.ExceptionContext.
For asynchronous invocation, the PostInvocationInterceptor is invoked in the request thread, i.e. in the thread
provided by ExecutorService.
When the lowest priority PostInvocationInterceptor is executed first, one of the two methods can be invoked.
afterRequest(ClientRequestContext, ClientResponseContext) in a usual case when no previous
Throwable was caught, or onException(ClientRequestContext, ExceptionContext) when
the Throwable was caught. Should the PostInvocationInterceptor.ExceptionContext.resolve(Response) be utilized in that case,
the next PostInvocationInterceptor's
afterRequest method will be
invoked. Similarly, when a Throwable is caught during the PostInvocationInterceptor execution, the next
PostInvocationInterceptor's
onException method will be invoked.- Since:
- 2.30
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThe context providing information when theThrowable(typically, theRuntimeException) is caught. -
Method Summary
Modifier and TypeMethodDescriptionvoidafterRequest(ClientRequestContext requestContext, ClientResponseContext responseContext) The method is invoked after a request when noThrowableis thrown, or theThrowablesareresolvedby previousPostInvocationInterceptor.voidonException(ClientRequestContext requestContext, PostInvocationInterceptor.ExceptionContext exceptionContext) The method is invoked after aThrowableis caught during the client request chain processing.
-
Method Details
-
afterRequest
The method is invoked after a request when noThrowableis thrown, or theThrowablesareresolvedby previousPostInvocationInterceptor. -
onException
void onException(ClientRequestContext requestContext, PostInvocationInterceptor.ExceptionContext exceptionContext) The method is invoked after aThrowableis caught during the client request chain processing.- Parameters:
requestContext- the request context.exceptionContext- the context available to handle the caughtThrowables.
-