类 SpringJtaSynchronizationAdapter
- java.lang.Object
- org.springframework.transaction.jta.SpringJtaSynchronizationAdapter
- 所有已实现的接口:
Synchronization
public class SpringJtaSynchronizationAdapter extends Object implements Synchronization
Adapter that implements the JTASynchronization
interface delegating to an underlying SpringTransactionSynchronization
.Useful for synchronizing Spring resource management code with plain JTA / EJB CMT transactions, despite the original code being built for Spring transaction synchronization.
- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller
- 另请参阅:
Transaction.registerSynchronization(javax.transaction.Synchronization)
,TransactionSynchronization
构造器概要
构造器 构造器 说明 SpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization)
Create a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.SpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization, TransactionManager jtaTransactionManager)
Create a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.SpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization, UserTransaction jtaUserTransaction)
Create a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterCompletion(int status)
JTAafterCompletion
callback: invoked after commit/rollback.void
beforeCompletion()
JTAbeforeCompletion
callback: just invoked before commit.
构造器详细资料
SpringJtaSynchronizationAdapter
public SpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization)
Create a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.- 参数:
springSynchronization
- the Spring TransactionSynchronization to delegate to
SpringJtaSynchronizationAdapter
public SpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization, UserTransaction jtaUserTransaction)
Create a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.Note that this adapter will never perform a rollback-only call on WebLogic, since WebLogic Server is known to automatically mark the transaction as rollback-only in case of a
beforeCompletion
exception. Hence, on WLS, this constructor is equivalent to the single-arg constructor.- 参数:
springSynchronization
- the Spring TransactionSynchronization to delegate tojtaUserTransaction
- the JTA UserTransaction to use for rollback-only setting in case of an exception thrown inbeforeCompletion
(can be omitted if the JTA provider itself marks the transaction rollback-only in such a scenario, which is required by the JTA specification as of JTA 1.1).
SpringJtaSynchronizationAdapter
public SpringJtaSynchronizationAdapter(TransactionSynchronization springSynchronization, TransactionManager jtaTransactionManager)
Create a new SpringJtaSynchronizationAdapter for the given Spring TransactionSynchronization and JTA TransactionManager.Note that this adapter will never perform a rollback-only call on WebLogic, since WebLogic Server is known to automatically mark the transaction as rollback-only in case of a
beforeCompletion
exception. Hence, on WLS, this constructor is equivalent to the single-arg constructor.- 参数:
springSynchronization
- the Spring TransactionSynchronization to delegate tojtaTransactionManager
- the JTA TransactionManager to use for rollback-only setting in case of an exception thrown inbeforeCompletion
(can be omitted if the JTA provider itself marks the transaction rollback-only in such a scenario, which is required by the JTA specification as of JTA 1.1)
方法详细资料
beforeCompletion
public void beforeCompletion()
JTAbeforeCompletion
callback: just invoked before commit.In case of an exception, the JTA transaction will be marked as rollback-only.
afterCompletion
public void afterCompletion(int status)
JTAafterCompletion
callback: invoked after commit/rollback.Needs to invoke the Spring synchronization's
beforeCompletion
at this late stage in case of a rollback, since there is no corresponding callback with JTA.