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 @Metadata(javaType = "java.lang.Boolean") 035 private String markRollbackOnly; 036 @XmlAttribute 037 @Metadata(javaType = "java.lang.Boolean") 038 private String markRollbackOnlyLast; 039 @XmlAttribute 040 private String message; 041 042 public RollbackDefinition() { 043 } 044 045 public RollbackDefinition(String message) { 046 this.message = message; 047 } 048 049 @Override 050 public String toString() { 051 if (message != null) { 052 return "Rollback[" + message + "]"; 053 } else { 054 return "Rollback"; 055 } 056 } 057 058 @Override 059 public String getShortName() { 060 return "rollback"; 061 } 062 063 @Override 064 public String getLabel() { 065 return "rollback"; 066 } 067 068 public String getMessage() { 069 return message; 070 } 071 072 /** 073 * Message to use in rollback exception 074 */ 075 public void setMessage(String message) { 076 this.message = message; 077 } 078 079 public String getMarkRollbackOnly() { 080 return markRollbackOnly; 081 } 082 083 /** 084 * Mark the transaction for rollback only (cannot be overruled to commit) 085 */ 086 public void setMarkRollbackOnly(String markRollbackOnly) { 087 this.markRollbackOnly = markRollbackOnly; 088 } 089 090 public String getMarkRollbackOnlyLast() { 091 return markRollbackOnlyLast; 092 } 093 094 /** 095 * Mark only last sub transaction for rollback only. 096 * <p/> 097 * When using sub transactions (if the transaction manager support this) 098 */ 099 public void setMarkRollbackOnlyLast(String markRollbackOnlyLast) { 100 this.markRollbackOnlyLast = markRollbackOnlyLast; 101 } 102 103}