Class BaseChenileInterceptor

java.lang.Object
org.chenile.core.interceptors.BaseChenileInterceptor
All Implemented Interfaces:
Command<ChenileExchange>
Direct Known Subclasses:
CacheInterceptor, ChenileExceptionHandler, CloudEdgeSwitch, ConstructServiceReference, GenericResponseBuilder, LogOutput, PopulateContextContainer, QuerySAASInterceptor, QueryUserFilterInterceptor, RegionToTrajectoryConverter, ResponseBodyTypeSelector, SecurityInterceptor, TransformationClassSelector, Transformer, ValidateCopyHeaders

public class BaseChenileInterceptor extends Object implements Command<ChenileExchange>
A generic interceptor for other Chenile Interceptors to override. If it is a pre or post interceptor, override the corresponding methods If it is a surround interceptor that needs to stop the chain under certaim circumstances then override the execute(ChenileExchange) method. For stopping the chain return without calling the doContinue method If you wish to bypass interception then override bypassInterception(ChenileExchange) method.
Author:
Raja Shankar Kolluru
  • Constructor Details

    • BaseChenileInterceptor

      public BaseChenileInterceptor()
  • Method Details

    • execute

      public void execute(ChenileExchange exchange) throws Exception
      If this method is over-ridden, make sure that you call doContinue unless you want to end the chain here! This is very important. Also, if there is an exception downstream it needs to be handled here after a call to doContinue(ChenileExchange) In most cases, you will do fine overriding doPreProcessing(ChenileExchange) and doPostProcessing(ChenileExchange)
      Specified by:
      execute in interface Command<ChenileExchange>
      Throws:
      Exception
    • doPostProcessing

      protected void doPostProcessing(ChenileExchange exchange)
      Override this to do post processing. This will be called even if there is an exception downstream. So make sure that if you don't want to do any processing in case of exception, check if ChenileExchange.getException() returns null value. If you happen to throw an exception in this method, it will get added to the set of errors that would ultimately be returned. See also ChenileExchange.setException(Throwable)
      Parameters:
      exchange - Chenile Exchange
    • doPreProcessing

      protected void doPreProcessing(ChenileExchange exchange)
      Override this to do pre-processing. This will be called before the service is invoked. Don't expect to see exception or response being set in ChenileExchange. However you can check for ChenileExchange.getBody() to manipulate the body if this interceptor is a Chenile post processor or a service specific or operation specific interceptor.
      If this interceptor is a Chenile pre-processor, then ChenileExchange.getBody() will return null. Then you need to look at headers only.
      Parameters:
      exchange -
    • doContinue

      protected final void doContinue(ChenileExchange exchange) throws Exception
      This method needs to be called if you wish to continue processing with the rest of the interception chain.
      Parameters:
      exchange -
      Throws:
      Exception
    • savePoint

      protected ChainContext.SavePoint savePoint(ChenileExchange exchange)
      This is used when an interceptor needs to save the current position in the interceptor chain with the intent of continuing again from the saved point. This is only required if there is a need to execute the downstream systems multiple times. Treat the SavePoint return value in an opaque fashion i.e. don't try to manipulate that data structure. This must only be used in the subsequent call to resumeFromSavedPoint(ChainContext.SavePoint, ChenileExchange)
      Parameters:
      exchange - the Chenile Exchange
    • resumeFromSavedPoint

      protected void resumeFromSavedPoint(ChainContext.SavePoint savePoint, ChenileExchange exchange) throws Exception
      Parameters:
      savePoint - the structure returned by savePoint call.
      exchange - the chenile exchange
      Throws:
      Exception - this can throw an exception if the downstream systems throw an error
    • bypassInterception

      protected boolean bypassInterception(ChenileExchange exchange)
      Over-ride this to bypass interception in special circumstances
      Parameters:
      exchange -
      Returns:
    • getExtensionByAnnotation

      @Deprecated protected Map<String,Object> getExtensionByAnnotation(String name, ChenileExchange exchange)
      Deprecated.
      See if there is an annotation of type T defined in either the OperationDefinition or ServiceDefinition. Return if it exists
      Parameters:
      name - - the annotation class name
      exchange - - the context thst is being passed around
      Returns:
      the annotation if it exists or null if it does not. Opertion level annotations override service level annotations
    • getExtensionByAnnotation

      protected <T extends Annotation> T getExtensionByAnnotation(Class<T> klass, ChenileExchange exchange)