org.camunda.connect.impl
Class DebugRequestInterceptor

java.lang.Object
  extended by 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 Summary
protected  boolean proceed
           
protected  Object response
           
 
Constructor Summary
DebugRequestInterceptor()
           
DebugRequestInterceptor(boolean proceed)
           
DebugRequestInterceptor(Object response)
           
 
Method Summary
<T extends ConnectorRequest<?>>
T
getRequest()
           
<T> T
getResponse()
           
<T> T
getTarget()
           
 Object handleInvocation(ConnectorInvocation invocation)
          Intercept and handle the actual invocation.
 boolean isProceed()
           
 void setProceed(boolean proceed)
           
 void setResponse(Object response)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

response

protected Object response

proceed

protected boolean proceed
Constructor Detail

DebugRequestInterceptor

public DebugRequestInterceptor()

DebugRequestInterceptor

public DebugRequestInterceptor(boolean proceed)

DebugRequestInterceptor

public DebugRequestInterceptor(Object response)
Method Detail

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()


Copyright © 2015 camunda services GmbH. All rights reserved.