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.ErrorHandlerFactory;
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 
031     */
032    public interface ErrorHandlerBuilder extends ErrorHandlerFactory {
033    
034        /**
035         * Adds error handler for the given exception type
036         *
037         * @param routeContext  the route context
038         * @param exception     the exception to handle
039         */
040        void addErrorHandlers(RouteContext routeContext, OnExceptionDefinition exception);
041    
042        /**
043         * Adds the error handlers for the given list of exception types
044         *
045         * @param routeContext  the route context
046         * @param exceptions    the list of exceptions to handle
047         */
048        void setErrorHandlers(RouteContext routeContext, List<OnExceptionDefinition> exceptions);
049    
050        /**
051         * Gets the error handlers
052         *
053         * @param routeContext  the route context
054         */
055        List<OnExceptionDefinition> getErrorHandlers(RouteContext routeContext);
056    
057        /**
058         * Gets the exception policy strategy
059         */
060        ExceptionPolicyStrategy getExceptionPolicyStrategy();
061    
062        /**
063         * Sets the exception policy strategy to use for resolving the {@link org.apache.camel.model.OnExceptionDefinition}
064         * to use for a given thrown exception
065         *
066         * @param exceptionPolicyStrategy  the exception policy strategy
067         */
068        void setExceptionPolicyStrategy(ExceptionPolicyStrategy exceptionPolicyStrategy);
069    
070        /**
071         * Whether this error handler supports transacted exchanges.
072         */
073        boolean supportTransacted();
074    
075        /**
076         * Configures the other error handler based on this error handler.
077         *
078         * @param routeContext the route context
079         * @param handler the other error handler
080         */
081        void configure(RouteContext routeContext, ErrorHandler handler);
082    
083        /**
084         * Clones this builder so each {@link RouteBuilder} has its private builder
085         * to use, to avoid changes from one {@link RouteBuilder} to influence the
086         * others.
087         * <p/>
088         * This is needed by the current Camel 2.x architecture.
089         *
090         * @return a clone of this {@link ErrorHandlerBuilder}
091         */
092        ErrorHandlerBuilder cloneBuilder();
093    }