Class JtaTransactionCoordinatorImpl
- java.lang.Object
-
- org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl
-
- All Implemented Interfaces:
SynchronizationCallbackTarget
,TransactionCoordinator
public class JtaTransactionCoordinatorImpl extends Object implements TransactionCoordinator, SynchronizationCallbackTarget
An implementation of TransactionCoordinator based on managing a transaction through the JTA API (either TM or UT)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
JtaTransactionCoordinatorImpl.TransactionDriverControlImpl
Implementation of the LocalInflow for this TransactionCoordinator.-
Nested classes/interfaces inherited from interface org.hibernate.resource.transaction.spi.TransactionCoordinator
TransactionCoordinator.TransactionDriver
-
-
Constructor Summary
Constructors Constructor Description JtaTransactionCoordinatorImpl(TransactionCoordinatorBuilder transactionCoordinatorBuilder, TransactionCoordinatorOwner owner, boolean autoJoinTransactions, JtaPlatform jtaPlatform, boolean preferUserTransactions, boolean performJtaThreadTracking, TransactionObserver... observers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObserver(TransactionObserver observer)
Adds an observer to the coordinator.void
afterCompletion(boolean successful, boolean delayed)
Callback of after-completion.void
beforeCompletion()
Callback of before-completion.IsolationDelegate
createIsolationDelegate()
Retrieve an isolation delegate appropriate for this transaction strategy.void
explicitJoin()
Indicates an explicit request to join a transaction.JpaCompliance
getJpaCompliance()
SynchronizationRegistry
getLocalSynchronizations()
Get access to the local registry of Synchronization instancesSynchronizationCallbackCoordinator
getSynchronizationCallbackCoordinator()
int
getTimeOut()
TransactionCoordinatorBuilder
getTransactionCoordinatorBuilder()
Access to the builder that generated this coordinatorTransactionCoordinatorOwner
getTransactionCoordinatorOwner()
TransactionCoordinator.TransactionDriver
getTransactionDriverControl()
Get the delegate used by the local transaction driver to control the underlying transactionvoid
invalidate()
boolean
isActive()
Is this transaction still active?boolean
isJoined()
Determine if there is an active transaction that this coordinator is already joined to.boolean
isJtaTransactionCurrentlyActive()
boolean
isSynchronizationRegistered()
Is the RegisteredSynchronization used by Hibernate for unified JTA Synchronization callbacks registered for this coordinator?void
pulse()
Used by owner of the "JDBC session" as a means to indicate that implicit joining should be done if needed.void
removeObserver(TransactionObserver observer)
Remove an observer from the coordinator.void
setTimeOut(int seconds)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.resource.transaction.spi.TransactionCoordinator
isTransactionActive, isTransactionActive
-
-
-
-
Constructor Detail
-
JtaTransactionCoordinatorImpl
public JtaTransactionCoordinatorImpl(TransactionCoordinatorBuilder transactionCoordinatorBuilder, TransactionCoordinatorOwner owner, boolean autoJoinTransactions, JtaPlatform jtaPlatform, boolean preferUserTransactions, boolean performJtaThreadTracking, TransactionObserver... observers)
-
-
Method Detail
-
getSynchronizationCallbackCoordinator
public SynchronizationCallbackCoordinator getSynchronizationCallbackCoordinator()
-
pulse
public void pulse()
Description copied from interface:TransactionCoordinator
Used by owner of the "JDBC session" as a means to indicate that implicit joining should be done if needed.- Specified by:
pulse
in interfaceTransactionCoordinator
-
explicitJoin
public void explicitJoin()
Description copied from interface:TransactionCoordinator
Indicates an explicit request to join a transaction. This is mainly intended to handle the JPA requirement aroundEntityManager.joinTransaction()
, and generally speaking only has an impact in JTA environments- Specified by:
explicitJoin
in interfaceTransactionCoordinator
-
isJoined
public boolean isJoined()
Description copied from interface:TransactionCoordinator
Determine if there is an active transaction that this coordinator is already joined to.- Specified by:
isJoined
in interfaceTransactionCoordinator
- Returns:
true
if there is an active transaction this coordinator is already joined to;false
otherwise.
-
isSynchronizationRegistered
public boolean isSynchronizationRegistered()
Is the RegisteredSynchronization used by Hibernate for unified JTA Synchronization callbacks registered for this coordinator?- Returns:
true
indicates that a RegisteredSynchronization is currently registered for this coordinator;false
indicates it is not (yet) registered.
-
getTransactionCoordinatorOwner
public TransactionCoordinatorOwner getTransactionCoordinatorOwner()
-
getJpaCompliance
public JpaCompliance getJpaCompliance()
- Specified by:
getJpaCompliance
in interfaceTransactionCoordinator
-
getTransactionDriverControl
public TransactionCoordinator.TransactionDriver getTransactionDriverControl()
Description copied from interface:TransactionCoordinator
Get the delegate used by the local transaction driver to control the underlying transaction- Specified by:
getTransactionDriverControl
in interfaceTransactionCoordinator
- Returns:
- The control delegate.
-
getLocalSynchronizations
public SynchronizationRegistry getLocalSynchronizations()
Description copied from interface:TransactionCoordinator
Get access to the local registry of Synchronization instances- Specified by:
getLocalSynchronizations
in interfaceTransactionCoordinator
- Returns:
- The local Synchronization registry
-
isActive
public boolean isActive()
Description copied from interface:TransactionCoordinator
Is this transaction still active?Answers on a best-effort basis. For example, in the case of JDBC based transactions we cannot know that a transaction is active when it is initiated directly through the JDBC
Connection
, only when it is initiated from here.- Specified by:
isActive
in interfaceSynchronizationCallbackTarget
- Specified by:
isActive
in interfaceTransactionCoordinator
- Returns:
true
if the transaction is still active;false
otherwise.
-
isJtaTransactionCurrentlyActive
public boolean isJtaTransactionCurrentlyActive()
-
createIsolationDelegate
public IsolationDelegate createIsolationDelegate()
Description copied from interface:TransactionCoordinator
Retrieve an isolation delegate appropriate for this transaction strategy.- Specified by:
createIsolationDelegate
in interfaceTransactionCoordinator
- Returns:
- An isolation delegate.
-
getTransactionCoordinatorBuilder
public TransactionCoordinatorBuilder getTransactionCoordinatorBuilder()
Description copied from interface:TransactionCoordinator
Access to the builder that generated this coordinator- Specified by:
getTransactionCoordinatorBuilder
in interfaceTransactionCoordinator
-
setTimeOut
public void setTimeOut(int seconds)
- Specified by:
setTimeOut
in interfaceTransactionCoordinator
-
getTimeOut
public int getTimeOut()
- Specified by:
getTimeOut
in interfaceTransactionCoordinator
-
invalidate
public void invalidate()
- Specified by:
invalidate
in interfaceTransactionCoordinator
-
beforeCompletion
public void beforeCompletion()
Description copied from interface:SynchronizationCallbackTarget
Callback of before-completion.- Specified by:
beforeCompletion
in interfaceSynchronizationCallbackTarget
- See Also:
Synchronization.beforeCompletion()
-
afterCompletion
public void afterCompletion(boolean successful, boolean delayed)
Description copied from interface:SynchronizationCallbackTarget
Callback of after-completion.- Specified by:
afterCompletion
in interfaceSynchronizationCallbackTarget
- Parameters:
successful
- Was the transaction successful?- See Also:
Synchronization.afterCompletion(int)
-
addObserver
public void addObserver(TransactionObserver observer)
Description copied from interface:TransactionCoordinator
Adds an observer to the coordinator.Observers are not to be cleared on transaction completion.
- Specified by:
addObserver
in interfaceTransactionCoordinator
- Parameters:
observer
- The observer to add.
-
removeObserver
public void removeObserver(TransactionObserver observer)
Description copied from interface:TransactionCoordinator
Remove an observer from the coordinator.- Specified by:
removeObserver
in interfaceTransactionCoordinator
- Parameters:
observer
- The observer to remove.
-
-