001/*002 * Copyright 2002-2019 the original author or authors.003 *004 * Licensed under the Apache License, Version 2.0 (the "License");005 * you may not use this file except in compliance with the License.006 * You may obtain a copy of the License at007 *008 * https://www.apache.org/licenses/LICENSE-2.0009 *010 * Unless required by applicable law or agreed to in writing, software011 * distributed under the License is distributed on an "AS IS" BASIS,012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.013 * See the License for the specific language governing permissions and014 * limitations under the License.015 */016017package org.springframework.transaction.support;018019import org.springframework.lang.Nullable;020import org.springframework.transaction.NestedTransactionNotSupportedException;021import org.springframework.transaction.SavepointManager;022import org.springframework.transaction.TransactionException;023import org.springframework.transaction.TransactionStatus;024import org.springframework.transaction.TransactionUsageException;025026/**027 * Abstract base implementation of the028 * {@link org.springframework.transaction.TransactionStatus} interface.029 *030 * <p>Pre-implements the handling of local rollback-only and completed flags, and031 * delegation to an underlying {@link org.springframework.transaction.SavepointManager}.032 * Also offers the option of a holding a savepoint within the transaction.033 *034 * <p>Does not assume any specific internal transaction handling, such as an035 * underlying transaction object, and no transaction synchronization mechanism.036 *037 * @author Juergen Hoeller038 * @since 1.2.3039 * @see #setRollbackOnly()040 * @see #isRollbackOnly()041 * @see #setCompleted()042 * @see #isCompleted()043 * @see #getSavepointManager()044 * @see SimpleTransactionStatus045 * @see DefaultTransactionStatus046 */047public abstract class AbstractTransactionStatus implements TransactionStatus {048049 private boolean rollbackOnly = false;050051 private boolean completed = false;052053 @Nullable054 private Object savepoint;055056057 //---------------------------------------------------------------------058 // Implementation of TransactionExecution059 //---------------------------------------------------------------------060061 @Override062 public void setRollbackOnly() {063 this.rollbackOnly = true;064 }065066 /**067 * Determine the rollback-only flag via checking both the local rollback-only flag068 * of this TransactionStatus and the global rollback-only flag of the underlying069 * transaction, if any.070 * @see #isLocalRollbackOnly()071 * @see #isGlobalRollbackOnly()072 */073 @Override074 public boolean isRollbackOnly() {075 return (isLocalRollbackOnly() || isGlobalRollbackOnly());076 }