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;
018    
019    /**
020     * An exception to veto starting {@link CamelContext}.
021     * <p/>
022     * The option rethrowException can be used to control whether to rethrow this exception
023     * when starting CamelContext or not.
024     *
025     * @see org.apache.camel.spi.LifecycleStrategy
026     */
027    public class VetoCamelContextStartException extends Exception {
028        private static final long serialVersionUID = 8046489554418284257L;
029        private final CamelContext context;
030        private final boolean rethrowException;
031    
032        public VetoCamelContextStartException(String message, CamelContext context) {
033            this(message, context, true);
034        }
035    
036        public VetoCamelContextStartException(String message, CamelContext context, boolean rethrowException) {
037            super(message);
038            this.context = context;
039            this.rethrowException = rethrowException;
040        }
041    
042        public VetoCamelContextStartException(String message, Throwable cause, CamelContext context) {
043            this(message, cause, context, true);
044        }
045    
046        public VetoCamelContextStartException(String message, Throwable cause, CamelContext context, boolean rethrowException) {
047            super(message, cause);
048            this.context = context;
049            this.rethrowException = rethrowException;
050        }
051    
052        public CamelContext getContext() {
053            return context;
054        }
055    
056        /**
057         * Whether to rethrow this exception when starting CamelContext, to cause an exception
058         * to be thrown from the start method.
059         * <p/>
060         * This option is default <tt>true</tt>.
061         */
062        public boolean isRethrowException() {
063            return rethrowException;
064        }
065    
066    }