Class InterceptorFlowController

java.lang.Object
com.predic8.membrane.core.interceptor.InterceptorFlowController

public class InterceptorFlowController extends Object
Controls the flow of an exchange through a chain of interceptors.

In the trivial setup, an exchange passes through two chains until it hits Outcome.RETURN: The main chain owned by the Transport (containing the RuleMatching, Dispatching, UserFeature and HttpClient-Interceptors) and the inner chain owned by the UserFeatureInterceptor (containing any interceptor configured in proxies.xml).

The HTTPClientInterceptor, the last interceptor in the main chain, always returns Outcome.RETURN or Outcome.ABORT, never Outcome.CONTINUE.

Any chain is followed using Interceptor.handleRequest(Exchange) until it hits Outcome.RETURN or Outcome.ABORT. As the chain is followed, every interceptor (except those with Interceptor.Flow.REQUEST) are added to the exchange's stack.

When Outcome.RETURN is hit, the exchange's interceptor stack is unwound and Interceptor.handleResponse(Exchange) is called for every interceptor on it.

When Outcome.ABORT is hit, handling is aborted: An AbortException is thrown. The stack is unwound calling Interceptor.handleAbort(Exchange) on each interceptor on it.

  • Field Details

    • ABORTION_REASON

      public static final String ABORTION_REASON
      Key into AbstractExchange.getProperty(String) to find out the reason why some interceptor returned ABORT.

      This refers to the last interceptor that returned ABORT.

      Note that this does not have to be set if ABORT was returned by the interceptor.

      See Also:
  • Constructor Details

    • InterceptorFlowController

      public InterceptorFlowController()
  • Method Details

    • invokeHandlers

      public void invokeHandlers(Exchange exchange, List<Interceptor> interceptors) throws Exception
      Runs both the request and response handlers: This executes the main interceptor chain.
      Throws:
      Exception
    • invokeRequestHandlers

      public Outcome invokeRequestHandlers(Exchange exchange, List<Interceptor> interceptors) throws Exception
      Runs the request handlers of the given chain. Response handlers are collected as the request handlers are executed and appended to the exchange's interceptor stack for later unwinding.
      Throws:
      Exception
    • invokeResponseHandlers

      public void invokeResponseHandlers(Exchange exchange) throws Exception
      Runs all response handlers for interceptors that have been collected on the exchange's stack so far.
      Throws:
      Exception