Search in sources :

Example 1 with ExceptionPolicyKey

use of org.apache.camel.processor.exceptionpolicy.ExceptionPolicyKey in project camel by apache.

the class ErrorHandlerSupport method addExceptionPolicy.

public void addExceptionPolicy(RouteContext routeContext, OnExceptionDefinition exceptionType) {
    if (routeContext != null) {
        // add error handler as child service so they get lifecycle handled
        Processor errorHandler = exceptionType.getErrorHandler(routeContext.getRoute().getId());
        if (errorHandler != null) {
            addChildService(errorHandler);
        }
    }
    List<Class<? extends Throwable>> list = exceptionType.getExceptionClasses();
    for (Class<? extends Throwable> clazz : list) {
        String routeId = null;
        // only get the route id, if the exception type is route scoped
        if (exceptionType.isRouteScoped()) {
            RouteDefinition route = ProcessorDefinitionHelper.getRoute(exceptionType);
            if (route != null) {
                routeId = route.getId();
            }
        }
        ExceptionPolicyKey key = new ExceptionPolicyKey(routeId, clazz, exceptionType.getOnWhen());
        exceptionPolicies.put(key, exceptionType);
    }
}
Also used : Processor(org.apache.camel.Processor) RouteDefinition(org.apache.camel.model.RouteDefinition) ExceptionPolicyKey(org.apache.camel.processor.exceptionpolicy.ExceptionPolicyKey)

Aggregations

Processor (org.apache.camel.Processor)1 RouteDefinition (org.apache.camel.model.RouteDefinition)1 ExceptionPolicyKey (org.apache.camel.processor.exceptionpolicy.ExceptionPolicyKey)1