Class DebugRequestInterceptor

java.lang.Object
org.camunda.connect.impl.DebugRequestInterceptor
All Implemented Interfaces:
ConnectorRequestInterceptor

public class DebugRequestInterceptor extends Object implements ConnectorRequestInterceptor

A dummy debug connector, which saves the ConnectorRequest (getRequest()) and the raw request (getTarget()) for debugging purpose.

The boolean constructor flag determines whether the request invocation should be continued or aborted after this interceptor. Also it is possible to add a response object which will returned without further passing the interceptor chain;

Author:
Sebastian Menski
  • Field Details

    • response

      protected Object response
    • proceed

      protected boolean proceed
  • Constructor Details

    • DebugRequestInterceptor

      public DebugRequestInterceptor()
    • DebugRequestInterceptor

      public DebugRequestInterceptor(boolean proceed)
    • DebugRequestInterceptor

      public DebugRequestInterceptor(Object response)
  • Method Details

    • handleInvocation

      public Object handleInvocation(ConnectorInvocation invocation) throws Exception
      Description copied from interface: ConnectorRequestInterceptor

      Intercept and handle the actual invocation. An implementation of this method *must* call invocation.proceed(); and return the result:

        public Object handleInvocation(ConnectorInvocation invocation) throws Exception {
          // do something before the request
          try {
            Object result = invocation.proceed();
            // do something after a successful request
            return result;
          } catch(Exception e) {
            // do something after a failed request
            throw e;
          }
        }
       

      This may be useful for "management" use cases such as logging, failure tracking etc... and modifying the Thread context of the request thread (Security Context, Transactions, ...).

      It is also possible for an implementation to access and modify the low level "raw" request object before it is executed by the connector:

        public Object handleInvocation(ConnectorInvocation invocation) throws Exception {
          Object rawRequest = invocation.getTarget();
          // cast rawRequest to the low-level connector implementation object and work with it.
      
          // finally
          return invocation.proceed();
        }
       
      Specified by:
      handleInvocation in interface ConnectorRequestInterceptor
      Parameters:
      invocation - the invocation
      Returns:
      the result of the invocation
      Throws:
      Exception
    • setProceed

      public void setProceed(boolean proceed)
    • isProceed

      public boolean isProceed()
    • setResponse

      public void setResponse(Object response)
    • getResponse

      public <T> T getResponse()
    • getRequest

      public <T extends ConnectorRequest<?>> T getRequest()
    • getTarget

      public <T> T getTarget()