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.model; 018 019import javax.xml.bind.annotation.XmlAccessType; 020import javax.xml.bind.annotation.XmlAccessorType; 021import javax.xml.bind.annotation.XmlAttribute; 022import javax.xml.bind.annotation.XmlRootElement; 023 024import org.apache.camel.spi.Metadata; 025 026/** 027 * Forces a rollback by stopping routing the message 028 */ 029@Metadata(label = "eip,routing") 030@XmlRootElement(name = "rollback") 031@XmlAccessorType(XmlAccessType.FIELD) 032public class RollbackDefinition extends NoOutputDefinition<RollbackDefinition> { 033 @XmlAttribute 034 private Boolean markRollbackOnly; 035 @XmlAttribute 036 private Boolean markRollbackOnlyLast; 037 @XmlAttribute 038 private String message; 039 040 public RollbackDefinition() { 041 } 042 043 public RollbackDefinition(String message) { 044 this.message = message; 045 } 046 047 @Override 048 public String toString() { 049 if (message != null) { 050 return "Rollback[" + message + "]"; 051 } else { 052 return "Rollback"; 053 } 054 } 055 056 @Override 057 public String getShortName() { 058 return "rollback"; 059 } 060 061 @Override 062 public String getLabel() { 063 return "rollback"; 064 } 065 066 public String getMessage() { 067 return message; 068 } 069 070 /** 071 * Message to use in rollback exception 072 */ 073 public void setMessage(String message) { 074 this.message = message; 075 } 076 077 public Boolean getMarkRollbackOnly() { 078 return markRollbackOnly; 079 } 080 081 /** 082 * Mark the transaction for rollback only (cannot be overruled to commit) 083 */ 084 public void setMarkRollbackOnly(Boolean markRollbackOnly) { 085 this.markRollbackOnly = markRollbackOnly; 086 } 087 088 public Boolean getMarkRollbackOnlyLast() { 089 return markRollbackOnlyLast; 090 } 091 092 /** 093 * Mark only last sub transaction for rollback only. 094 * <p/> 095 * When using sub transactions (if the transaction manager support this) 096 */ 097 public void setMarkRollbackOnlyLast(Boolean markRollbackOnlyLast) { 098 this.markRollbackOnlyLast = markRollbackOnlyLast; 099 } 100 101}