Package org.chenile.core.interceptors
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
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
bypassInterception
(ChenileExchange exchange) Over-ride this to bypass interception in special circumstancesprotected final void
doContinue
(ChenileExchange exchange) This method needs to be called if you wish to continue processing with the rest of the interception chain.protected void
doPostProcessing
(ChenileExchange exchange) Override this to do post processing.protected void
doPreProcessing
(ChenileExchange exchange) Override this to do pre-processing.void
execute
(ChenileExchange exchange) If this method is over-ridden, make sure that you call doContinue unless you want to end the chain here! This is very important.protected <T extends Annotation>
TgetExtensionByAnnotation
(Class<T> klass, ChenileExchange exchange) getExtensionByAnnotation
(String name, ChenileExchange exchange) Deprecated.protected void
resumeFromSavedPoint
(ChainContext.SavePoint savePoint, ChenileExchange exchange) SeesavePoint(ChenileExchange)
aboveprotected 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.
-
Constructor Details
-
BaseChenileInterceptor
public BaseChenileInterceptor()
-
-
Method Details
-
execute
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 todoContinue(ChenileExchange)
In most cases, you will do fine overridingdoPreProcessing(ChenileExchange)
anddoPostProcessing(ChenileExchange)
- Specified by:
execute
in interfaceCommand<ChenileExchange>
- Throws:
Exception
-
doPostProcessing
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 ifChenileExchange.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 alsoChenileExchange.setException(Throwable)
- Parameters:
exchange
- Chenile Exchange
-
doPreProcessing
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 inChenileExchange
. However you can check forChenileExchange.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, thenChenileExchange.getBody()
will return null. Then you need to look at headers only.- Parameters:
exchange
-
-
doContinue
This method needs to be called if you wish to continue processing with the rest of the interception chain.- Parameters:
exchange
-- Throws:
Exception
-
savePoint
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 toresumeFromSavedPoint(ChainContext.SavePoint, ChenileExchange)
- Parameters:
exchange
- the Chenile Exchange
-
resumeFromSavedPoint
protected void resumeFromSavedPoint(ChainContext.SavePoint savePoint, ChenileExchange exchange) throws Exception SeesavePoint(ChenileExchange)
above- 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
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 nameexchange
- - 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)
-