001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.camel.builder;
018
019 import java.util.List;
020
021 import org.apache.camel.Processor;
022 import org.apache.camel.model.OnExceptionDefinition;
023 import org.apache.camel.processor.ErrorHandler;
024 import org.apache.camel.processor.exceptionpolicy.ExceptionPolicyStrategy;
025 import org.apache.camel.spi.RouteContext;
026
027 /**
028 * A builder of a <a href="http://camel.apache.org/error-handler.html">Error Handler</a>
029 *
030 * @version $Revision: 765920 $
031 */
032 public interface ErrorHandlerBuilder {
033
034 /**
035 * Creates the error handler interceptor
036 *
037 * @param routeContext the route context
038 * @param processor the outer processor
039 * @return the error handler
040 * @throws Exception is thrown if the error handler could not be created
041 */
042 Processor createErrorHandler(RouteContext routeContext, Processor processor) throws Exception;
043
044 /**
045 * Adds error handler for the given exception type
046 *
047 * @param exception the exception to handle
048 */
049 void addErrorHandlers(OnExceptionDefinition exception);
050
051 /**
052 * Adds the error handlers for the given list of exception types
053 *
054 * @param exceptions the list of exceptions to handle
055 */
056 void setErrorHandlers(List<OnExceptionDefinition> exceptions);
057
058 /**
059 * Gets the error handlers
060 */
061 List<OnExceptionDefinition> getErrorHandlers();
062
063 /**
064 * Gets the exception policy strategy
065 */
066 ExceptionPolicyStrategy getExceptionPolicyStrategy();
067
068 /**
069 * Sets the exception policy strategy to use for resolving the {@link org.apache.camel.model.OnExceptionDefinition}
070 * to use for a given thrown exception
071 *
072 * @param exceptionPolicyStrategy the exception policy strategy
073 */
074 void setExceptionPolicyStrategy(ExceptionPolicyStrategy exceptionPolicyStrategy);
075
076 /**
077 * Whether this error handler supports transacted exchanges.
078 */
079 boolean supportTransacted();
080
081 /**
082 * Configures the other error handler based on this error handler.
083 *
084 * @param handler the other error handler
085 */
086 void configure(ErrorHandler handler);
087 }