类 AbstractPlatformTransactionManager

  • 所有已实现的接口:
    Serializable, PlatformTransactionManager, TransactionManager
    直接已知子类:
    CciLocalTransactionManager, DataSourceTransactionManager, HibernateTransactionManager, JmsTransactionManager, JpaTransactionManager, JtaTransactionManager

    public abstract class AbstractPlatformTransactionManager
    extends Object
    implements PlatformTransactionManager, Serializable
    Abstract base class that implements Spring's standard transaction workflow, serving as basis for concrete platform transaction managers like JtaTransactionManager.

    This base class provides the following workflow handling:

    • determines if there is an existing transaction;
    • applies the appropriate propagation behavior;
    • suspends and resumes transactions if necessary;
    • checks the rollback-only flag on commit;
    • applies the appropriate modification on rollback (actual rollback or setting rollback-only);
    • triggers registered synchronization callbacks (if transaction synchronization is active).

    Subclasses have to implement specific template methods for specific states of a transaction, e.g.: begin, suspend, resume, commit, rollback. The most important of them are abstract and must be provided by a concrete implementation; for the rest, defaults are provided, so overriding is optional.

    Transaction synchronization is a generic mechanism for registering callbacks that get invoked at transaction completion time. This is mainly used internally by the data access support classes for JDBC, Hibernate, JPA, etc when running within a JTA transaction: They register resources that are opened within the transaction for closing at transaction completion time, allowing e.g. for reuse of the same Hibernate Session within the transaction. The same mechanism can also be leveraged for custom synchronization needs in an application.

    The state of this class is serializable, to allow for serializing the transaction strategy along with proxies that carry a transaction interceptor. It is up to subclasses if they wish to make their state to be serializable too. They should implement the java.io.Serializable marker interface in that case, and potentially a private readObject() method (according to Java serialization rules) if they need to restore any transient state.

    从以下版本开始:
    28.03.2003
    作者:
    Juergen Hoeller
    另请参阅:
    setTransactionSynchronization(int), TransactionSynchronizationManager, JtaTransactionManager, 序列化表格