}
// Implementation methods
// -------------------------------------------------------------------------
protected RouteContext addRoutes(Collection<Route> routes, FromDefinition fromType) throws Exception {
RouteContext routeContext = new DefaultRouteContext(this, fromType, routes);
// configure tracing
if (trace != null) {
routeContext.setTracing(isTrace());
if (isTrace()) {
if (log.isDebugEnabled()) {
log.debug("Tracing is enabled on route: " + this);
}
// only add a new tracer if not already a global configured on camel context
if (Tracer.getTracer(camelContext) == null) {
Tracer tracer = Tracer.createTracer(camelContext);
addInterceptStrategy(tracer);
}
}
}
// configure stream caching
if (streamCache != null) {
routeContext.setStreamCaching(isStreamCache());
if (isStreamCache()) {
if (log.isDebugEnabled()) {
log.debug("StramCaching is enabled on route: " + this);
}
// only add a new stream cache if not already a global configured on camel context
if (StreamCaching.getStreamCaching(camelContext) == null) {
addInterceptStrategy(new StreamCaching());
}
}
}
// configure handle fault
if (handleFault != null) {
routeContext.setHandleFault(isHandleFault());
if (isHandleFault()) {
if (log.isDebugEnabled()) {
log.debug("HandleFault is enabled on route: " + this);
}
// only add a new handle fault if not already a global configured on camel context
if (HandleFault.getHandleFault(camelContext) == null) {
addInterceptStrategy(new HandleFault());
}
}
}
// configure delayer
if (delayer != null) {
routeContext.setDelayer(getDelayer());
if (getDelayer() != null) {
long millis = getDelayer();
if (millis > 0) {
if (log.isDebugEnabled()) {
log.debug("Delayer is enabled with: " + millis + " ms. on route: " + this);
}
addInterceptStrategy(new Delayer(millis));
} else {
if (log.isDebugEnabled()) {
log.debug("Delayer is disabled on route: " + this);
}
}
}
}
// should inherit the intercept strategies we have defined
routeContext.setInterceptStrategies(this.getInterceptStrategies());
// force endpoint resolution
routeContext.getEndpoint();
if (camelContext != null) {
camelContext.getLifecycleStrategy().onRouteContextCreate(routeContext);
}
List<ProcessorDefinition> list = new ArrayList<ProcessorDefinition>(outputs);
for (ProcessorDefinition output : list) {
output.addRoutes(routeContext, routes);
}
routeContext.commit();
return routeContext;
}