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 */ 017package org.apache.camel.builder; 018 019import org.apache.camel.processor.errorhandler.ExceptionPolicyStrategy; 020import org.apache.camel.util.ObjectHelper; 021 022/** 023 * Base class for builders of error handling. 024 */ 025public abstract class ErrorHandlerBuilderSupport implements ErrorHandlerBuilder { 026 private ExceptionPolicyStrategy exceptionPolicyStrategy; 027 private String exceptionPolicyStrategyRef; 028 029 @Override 030 public boolean supportTransacted() { 031 return false; 032 } 033 034 protected void cloneBuilder(ErrorHandlerBuilderSupport other) { 035 other.exceptionPolicyStrategy = exceptionPolicyStrategy; 036 other.exceptionPolicyStrategyRef = exceptionPolicyStrategyRef; 037 } 038 039 /** 040 * Sets the exception policy to use 041 */ 042 public ErrorHandlerBuilderSupport exceptionPolicyStrategy(ExceptionPolicyStrategy exceptionPolicyStrategy) { 043 setExceptionPolicyStrategy(exceptionPolicyStrategy); 044 return this; 045 } 046 047 /** 048 * Sets the exception policy to use 049 */ 050 public ErrorHandlerBuilderSupport exceptionPolicyStrategy(String exceptionPolicyStrategyRef) { 051 setExceptionPolicyStrategyRef(exceptionPolicyStrategyRef); 052 return this; 053 } 054 055 /** 056 * Gets the exception policy strategy 057 */ 058 public ExceptionPolicyStrategy getExceptionPolicyStrategy() { 059 return exceptionPolicyStrategy; 060 } 061 062 /** 063 * Sets the exception policy strategy to use for resolving the 064 * {@link org.apache.camel.model.OnExceptionDefinition} to use for a given 065 * thrown exception 066 * 067 * @param exceptionPolicyStrategy the exception policy strategy 068 */ 069 public void setExceptionPolicyStrategy(ExceptionPolicyStrategy exceptionPolicyStrategy) { 070 ObjectHelper.notNull(exceptionPolicyStrategy, "ExceptionPolicyStrategy"); 071 this.exceptionPolicyStrategy = exceptionPolicyStrategy; 072 } 073 074 public String getExceptionPolicyStrategyRef() { 075 return exceptionPolicyStrategyRef; 076 } 077 078 public void setExceptionPolicyStrategyRef(String exceptionPolicyStrategyRef) { 079 ObjectHelper.notNull(exceptionPolicyStrategyRef, "ExceptionPolicyStrategyRef"); 080 this.exceptionPolicyStrategyRef = exceptionPolicyStrategyRef; 081 } 082 083}