private static class ApplicationListenerMethodTransactionalAdapter.TransactionSynchronizationEventAdapter extends TransactionSynchronizationAdapter
Modifier and Type | Field and Description |
---|---|
private ApplicationEvent |
event |
private ApplicationListenerMethodAdapter |
listener |
private TransactionPhase |
phase |
STATUS_COMMITTED, STATUS_ROLLED_BACK, STATUS_UNKNOWN
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Modifier | Constructor and Description |
---|---|
protected |
TransactionSynchronizationEventAdapter(ApplicationListenerMethodAdapter listener,
ApplicationEvent event,
TransactionPhase phase) |
Modifier and Type | Method and Description |
---|---|
void |
afterCompletion(int status)
Invoked after transaction commit/rollback.
|
void |
beforeCommit(boolean readOnly)
Invoked before transaction commit (before "beforeCompletion").
|
int |
getOrder()
Return the order value of this object, with a
higher value meaning greater in terms of sorting.
|
protected void |
processEvent() |
afterCommit, beforeCompletion, flush, resume, suspend
private final ApplicationListenerMethodAdapter listener
private final ApplicationEvent event
private final TransactionPhase phase
protected TransactionSynchronizationEventAdapter(ApplicationListenerMethodAdapter listener, ApplicationEvent event, TransactionPhase phase)
public void beforeCommit(boolean readOnly)
TransactionSynchronization
This callback does not mean that the transaction will actually be committed. A rollback decision can still occur after this method has been called. This callback is rather meant to perform work that's only relevant if a commit still has a chance to happen, such as flushing SQL statements to the database.
Note that exceptions will get propagated to the commit caller and cause a rollback of the transaction.
beforeCommit
in interface TransactionSynchronization
beforeCommit
in class TransactionSynchronizationAdapter
readOnly
- whether the transaction is defined as read-only transactionTransactionSynchronization.beforeCompletion()
public void afterCompletion(int status)
TransactionSynchronization
NOTE: The transaction will have been committed or rolled back already,
but the transactional resources might still be active and accessible. As a
consequence, any data access code triggered at this point will still "participate"
in the original transaction, allowing to perform some cleanup (with no commit
following anymore!), unless it explicitly declares that it needs to run in a
separate transaction. Hence: Use PROPAGATION_REQUIRES_NEW
for any transactional operation that is called from here.
afterCompletion
in interface TransactionSynchronization
afterCompletion
in class TransactionSynchronizationAdapter
status
- completion status according to the STATUS_*
constantsTransactionSynchronization.STATUS_COMMITTED
,
TransactionSynchronization.STATUS_ROLLED_BACK
,
TransactionSynchronization.STATUS_UNKNOWN
,
TransactionSynchronization.beforeCompletion()
public int getOrder()
Ordered
Normally starting with 0, with Integer.MAX_VALUE
indicating the greatest value. Same order values will result
in arbitrary positions for the affected objects.
Higher values can be interpreted as lower priority. As a consequence, the object with the lowest value has highest priority (somewhat analogous to Servlet "load-on-startup" values).
getOrder
in interface Ordered
getOrder
in class TransactionSynchronizationAdapter
protected void processEvent()