001/* 002 * Copyright 2002-2017 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 at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * 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 and 014 * limitations under the License. 015 */ 016 017package org.springframework.transaction.event; 018 019import org.springframework.transaction.support.TransactionSynchronization; 020 021/** 022 * The phase at which a transactional event listener applies. 023 * 024 * @author Stephane Nicoll 025 * @author Juergen Hoeller 026 * @since 4.2 027 * @see TransactionalEventListener 028 */ 029public enum TransactionPhase { 030 031 /** 032 * Fire the event before transaction commit. 033 * @see TransactionSynchronization#beforeCommit(boolean) 034 */ 035 BEFORE_COMMIT, 036 037 /** 038 * Fire the event after the commit has completed successfully. 039 * <p>Note: This is a specialization of {@link #AFTER_COMPLETION} and 040 * therefore executes in the same after-completion sequence of events, 041 * (and not in {@link TransactionSynchronization#afterCommit()}). 042 * @see TransactionSynchronization#afterCompletion(int) 043 * @see TransactionSynchronization#STATUS_COMMITTED 044 */ 045 AFTER_COMMIT, 046 047 /** 048 * Fire the event if the transaction has rolled back. 049 * <p>Note: This is a specialization of {@link #AFTER_COMPLETION} and 050 * therefore executes in the same after-completion sequence of events. 051 * @see TransactionSynchronization#afterCompletion(int) 052 * @see TransactionSynchronization#STATUS_ROLLED_BACK 053 */ 054 AFTER_ROLLBACK, 055 056 /** 057 * Fire the event after the transaction has completed. 058 * <p>For more fine-grained events, use {@link #AFTER_COMMIT} or 059 * {@link #AFTER_ROLLBACK} to intercept transaction commit 060 * or rollback, respectively. 061 * @see TransactionSynchronization#afterCompletion(int) 062 */ 063 AFTER_COMPLETION 064 065}