Interface PreInvocationInterceptor


@Beta @Contract @ConstrainedTo(CLIENT) public interface PreInvocationInterceptor
The interceptor of a client request invocation that is executed before the invocation itself, i.e. before the ClientRequestFilter is invoked.

It is ensured that all PreInvocationInterceptors are executed before the request, in the order given by the Priority, the higher the priority the sooner the execution. Any RuntimeException thrown when the beforeRequest(ClientRequestContext) is being processed is accumulated and a multi RuntimeException with other exceptions supressed is being thrown.

For asynchronous invocation, the PreInvocationInterceptor is invoked in the main thread, i.e. not in the thread provided by ExecutorService. For reactive invocations, this depends on the provided RxInvoker. For the default Jersey asynchronous JerseyCompletionStageRxInvoker, PreInvocationInterceptor is invoked in the main thread, too.

Should the ClientRequestContext.abortWith(Response) be utilized, the request abort is performed after every registered PreInvocationInterceptor is processed. If multiple PreInvocationInterceptors PreInvocationInterceptor tries to utilize ClientRequestContext.abortWith(Response) method, the second and every next throws IllegalStateException.

Since:
2.30
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    The method invoked before the request starts.
  • Method Details

    • beforeRequest

      void beforeRequest(ClientRequestContext requestContext)
      The method invoked before the request starts.
      Parameters:
      requestContext - the request context shared with ClientRequestFilter.