use of org.apache.camel.processor.interceptor.StreamCaching in project camel by apache.
the class ProcessorDefinition method addInterceptStrategies.
/**
* Adds the given list of interceptors to the channel.
*
* @param routeContext the route context
* @param channel the channel to add strategies
* @param strategies list of strategies to add.
*/
protected void addInterceptStrategies(RouteContext routeContext, Channel channel, List<InterceptStrategy> strategies) {
for (InterceptStrategy strategy : strategies) {
if (!routeContext.isStreamCaching() && strategy instanceof StreamCaching) {
// stream cache is disabled so we should not add it
continue;
}
if (!routeContext.isHandleFault() && strategy instanceof HandleFault) {
// handle fault is disabled so we should not add it
continue;
}
if (strategy instanceof Delayer) {
if (routeContext.getDelayer() == null || routeContext.getDelayer() <= 0) {
// delayer is disabled so we should not add it
continue;
} else {
// replace existing delayer as delayer have individual configuration
Iterator<InterceptStrategy> it = channel.getInterceptStrategies().iterator();
while (it.hasNext()) {
InterceptStrategy existing = it.next();
if (existing instanceof Delayer) {
it.remove();
}
}
// add the new correct delayer
channel.addInterceptStrategy(strategy);
continue;
}
}
// add strategy
channel.addInterceptStrategy(strategy);
}
}
Aggregations