Top Description Inners Fields Constructors Methods
org.hibernate.resource.transaction.backend.jta.internal

public Class JtaTransactionCoordinatorImpl

extends Object
implements TransactionCoordinator, SynchronizationCallbackTarget
Class Inheritance
All Implemented Interfaces
org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackTarget, org.hibernate.resource.transaction.spi.TransactionCoordinator
Imports
java.util.ArrayList, .Collections, .List, javax.transaction.Status, .TransactionManager, .UserTransaction, org.hibernate.HibernateException, org.hibernate.boot.spi.SessionFactoryOptions, org.hibernate.engine.jdbc.spi.JdbcServices, org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform, org.hibernate.engine.transaction.spi.IsolationDelegate, .TransactionObserver, org.hibernate.jpa.spi.JpaCompliance, org.hibernate.resource.jdbc.spi.JdbcSessionContext, .JdbcSessionOwner, org.hibernate.resource.transaction.TransactionRequiredForJoinException, org.hibernate.resource.transaction.backend.jta.internal.synchronization.RegisteredSynchronization, .SynchronizationCallbackCoordinator, .SynchronizationCallbackCoordinatorNonTrackingImpl, .SynchronizationCallbackCoordinatorTrackingImpl, .SynchronizationCallbackTarget, org.hibernate.resource.transaction.internal.SynchronizationRegistryStandardImpl, org.hibernate.resource.transaction.spi.SynchronizationRegistry, .TransactionCoordinator, .TransactionCoordinatorBuilder, .TransactionCoordinatorOwner, .TransactionStatus, org.jboss.logging.Logger

An implementation of TransactionCoordinator based on managing a transaction through the JTA API (either TM or UT)
Author
Steve Ebersole

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
JtaTransactionCoordinatorImpl.TransactionDriverControlImpl

Implementation of the LocalInflow for this TransactionCoordinator.

Field Summary

Modifier and TypeField and Description
private final boolean
private SynchronizationCallbackCoordinator
private final JtaPlatform
private static final Logger
private transient List<TransactionObserver>
private final boolean
private JtaTransactionCoordinatorImpl.TransactionDriverControlImpl
private final boolean
private boolean
private final SynchronizationRegistryStandardImpl
private int
private final TransactionCoordinatorBuilder
private final TransactionCoordinatorOwner

Constructor Summary

AccessConstructor and Description
pack-priv
JtaTransactionCoordinatorImpl(TransactionCoordinatorBuilder transactionCoordinatorBuilder, TransactionCoordinatorOwner
The transactionCoordinatorOwner
owner
,
boolean
Should JTA transactions be auto-joined? Or should we wait for explicit join calls?
autoJoinTransactions
,
JtaPlatform jtaPlatform)

Construct a JtaTransactionCoordinatorImpl instance.

public
JtaTransactionCoordinatorImpl(TransactionCoordinatorBuilder transactionCoordinatorBuilder, TransactionCoordinatorOwner owner, boolean autoJoinTransactions, JtaPlatform jtaPlatform, boolean preferUserTransactions, boolean performJtaThreadTracking, TransactionObserver... observers)

Method Summary

Modifier and TypeMethod and Description
public void
addObserver(TransactionObserver
The observer to add.
observer
)

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.addObserver.

Adds an observer to the coordinator.
public void
afterCompletion(boolean
Was the transaction successful?
successful
,
boolean delayed)

Implements org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackTarget.afterCompletion.

Callback of after-completion.
public void
public IsolationDelegate
createIsolationDelegate()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.createIsolationDelegate.

Retrieve an isolation delegate appropriate for this transaction strategy.
public void
explicitJoin()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.explicitJoin.

Indicates an explicit request to join a transaction.
public JpaCompliance
public SynchronizationRegistry
getLocalSynchronizations()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.getLocalSynchronizations.

Get access to the local registry of Synchronization instances
public SynchronizationCallbackCoordinator
public int
public TransactionCoordinatorBuilder
public TransactionCoordinatorOwner
public TransactionCoordinator.TransactionDriver
getTransactionDriverControl()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.getTransactionDriverControl.

Get the delegate used by the local transaction driver to control the underlying transaction
public void
public boolean
public boolean
isJoined()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.isJoined.

Determine if there is an active transaction that this coordinator is already joined to.
public boolean
public boolean

Returns:

true indicates that a RegisteredSynchronization is currently registered for this coordinator; false indicates it is not (yet) registered.
isSynchronizationRegistered
()

Is the RegisteredSynchronization used by Hibernate for unified JTA Synchronization callbacks registered for this coordinator?

private void
joinJtaTransaction()

Join to the JTA transaction.

private JtaTransactionCoordinatorImpl.TransactionDriverControlImpl
private JtaTransactionAdapter
private JtaTransactionAdapter
private Iterable<TransactionObserver>

Returns:

TransactionObserver
observers
()

Needed because while iterating the observers list and executing the before/update callbacks, some observers might get removed from the list.

public void
pulse()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.pulse.

Used by owner of the JdbcSession as a means to indicate that implicit joining should be done if needed.
public void
removeObserver(TransactionObserver
The observer to remove.
observer
)

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.removeObserver.

Removed an observer from the coordinator.
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

autoJoinTransactionsback to summary
private final boolean autoJoinTransactions
callbackCoordinatorback to summary
private SynchronizationCallbackCoordinator callbackCoordinator
jtaPlatformback to summary
private final JtaPlatform jtaPlatform
logback to summary
private static final Logger log
observersback to summary
private transient List<TransactionObserver> observers
performJtaThreadTrackingback to summary
private final boolean performJtaThreadTracking
physicalTransactionDelegateback to summary
private JtaTransactionCoordinatorImpl.TransactionDriverControlImpl physicalTransactionDelegate
preferUserTransactionsback to summary
private final boolean preferUserTransactions
synchronizationRegisteredback to summary
private boolean synchronizationRegistered
synchronizationRegistryback to summary
private final SynchronizationRegistryStandardImpl synchronizationRegistry
timeOutback to summary
private int timeOut
transactionCoordinatorBuilderback to summary
private final TransactionCoordinatorBuilder transactionCoordinatorBuilder
transactionCoordinatorOwnerback to summary
private final TransactionCoordinatorOwner transactionCoordinatorOwner

Constructor Detail

JtaTransactionCoordinatorImplback to summary
pack-priv JtaTransactionCoordinatorImpl(TransactionCoordinatorBuilder transactionCoordinatorBuilder, TransactionCoordinatorOwner owner, boolean autoJoinTransactions, JtaPlatform jtaPlatform)

Construct a JtaTransactionCoordinatorImpl instance. package-protected to ensure access goes through builder.

Parameters
owner:TransactionCoordinatorOwner

The transactionCoordinatorOwner

autoJoinTransactions:boolean

Should JTA transactions be auto-joined? Or should we wait for explicit join calls?

JtaTransactionCoordinatorImplback to summary
public JtaTransactionCoordinatorImpl(TransactionCoordinatorBuilder transactionCoordinatorBuilder, TransactionCoordinatorOwner owner, boolean autoJoinTransactions, JtaPlatform jtaPlatform, boolean preferUserTransactions, boolean performJtaThreadTracking, TransactionObserver... observers)

Method Detail

addObserverback to summary
public void addObserver(TransactionObserver observer)

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.addObserver.

Doc from org.hibernate.resource.transaction.spi.TransactionCoordinator.addObserver.

Adds an observer to the coordinator.

observers are not to be cleared on transaction completion.

Parameters
observer:TransactionObserver

The observer to add.

afterCompletionback to summary
public void afterCompletion(boolean successful, boolean delayed)

Implements org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackTarget.afterCompletion.

Doc from org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackTarget.afterCompletion.

Callback of after-completion.

Parameters
successful:boolean

Was the transaction successful?

Annotations
@Override
beforeCompletionback to summary
public void beforeCompletion()

Implements org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackTarget.beforeCompletion.

Doc from org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackTarget.beforeCompletion.

Callback of before-completion.

Annotations
@Override
createIsolationDelegateback to summary
public IsolationDelegate createIsolationDelegate()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.createIsolationDelegate.

Doc from org.hibernate.resource.transaction.spi.TransactionCoordinator.createIsolationDelegate.

Retrieve an isolation delegate appropriate for this transaction strategy.

Returns:IsolationDelegate

An isolation delegate.

Annotations
@Override
explicitJoinback to summary
public void explicitJoin()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.explicitJoin.

Doc from org.hibernate.resource.transaction.spi.TransactionCoordinator.explicitJoin.

Indicates an explicit request to join a transaction. This is mainly intended to handle the JPA requirement around javax.persistence.EntityManager#joinTransaction(), and generally speaking only has an impact in JTA environments

Annotations
@Override
getJpaComplianceback to summary
public JpaCompliance getJpaCompliance()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.getJpaCompliance.

Annotations
@Override
getLocalSynchronizationsback to summary
public SynchronizationRegistry getLocalSynchronizations()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.getLocalSynchronizations.

Doc from org.hibernate.resource.transaction.spi.TransactionCoordinator.getLocalSynchronizations.

Get access to the local registry of Synchronization instances

Returns:SynchronizationRegistry

The local Synchronization registry

Annotations
@Override
getSynchronizationCallbackCoordinatorback to summary
public SynchronizationCallbackCoordinator getSynchronizationCallbackCoordinator()
getTimeOutback to summary
public int getTimeOut()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.getTimeOut.

Annotations
@Override
getTransactionCoordinatorBuilderback to summary
public TransactionCoordinatorBuilder getTransactionCoordinatorBuilder()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.getTransactionCoordinatorBuilder.

Doc from org.hibernate.resource.transaction.spi.TransactionCoordinator.getTransactionCoordinatorBuilder.

Access to the builder that generated this coordinator

Annotations
@Override
getTransactionCoordinatorOwnerback to summary
public TransactionCoordinatorOwner getTransactionCoordinatorOwner()
getTransactionDriverControlback to summary
public TransactionCoordinator.TransactionDriver getTransactionDriverControl()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.getTransactionDriverControl.

Doc from org.hibernate.resource.transaction.spi.TransactionCoordinator.getTransactionDriverControl.

Get the delegate used by the local transaction driver to control the underlying transaction

Returns:TransactionCoordinator.TransactionDriver

The control delegate.

Annotations
@Override
invalidateback to summary
public void invalidate()

Overrides default org.hibernate.resource.transaction.spi.TransactionCoordinator.invalidate.

Annotations
@Override
isActiveback to summary
public boolean isActive()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.isActive, org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackTarget.isActive.

Doc from org.hibernate.resource.transaction.spi.TransactionCoordinator.isActive.

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 java.sql.Connection, only when it is initiated from here.

Returns:boolean

true if the transaction is still active; false otherwise.

Annotations
@Override
isJoinedback to summary
public boolean isJoined()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.isJoined.

Doc from org.hibernate.resource.transaction.spi.TransactionCoordinator.isJoined.

Determine if there is an active transaction that this coordinator is already joined to.

Returns:boolean

true if there is an active transaction this coordinator is already joined to; false otherwise.

Annotations
@Override
isJtaTransactionCurrentlyActiveback to summary
public boolean isJtaTransactionCurrentlyActive()
isSynchronizationRegisteredback to summary
public boolean isSynchronizationRegistered()

Is the RegisteredSynchronization used by Hibernate for unified JTA Synchronization callbacks registered for this coordinator?

Returns:boolean

true indicates that a RegisteredSynchronization is currently registered for this coordinator; false indicates it is not (yet) registered.

joinJtaTransactionback to summary
private void joinJtaTransaction()

Join to the JTA transaction. Note that the underlying meaning of joining in JTA environments is to register the RegisteredSynchronization with the JTA system

makePhysicalTransactionDelegateback to summary
private JtaTransactionCoordinatorImpl.TransactionDriverControlImpl makePhysicalTransactionDelegate()
makeTransactionManagerAdapterback to summary
private JtaTransactionAdapter makeTransactionManagerAdapter()
makeUserTransactionAdapterback to summary
private JtaTransactionAdapter makeUserTransactionAdapter()
observersback to summary
private Iterable<TransactionObserver> observers()

Needed because while iterating the observers list and executing the before/update callbacks, some observers might get removed from the list. Yet try to not allocate anything for when the list is empty, as this is a common case.

Returns:Iterable<TransactionObserver>

TransactionObserver

pulseback to summary
public void pulse()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.pulse.

Doc from org.hibernate.resource.transaction.spi.TransactionCoordinator.pulse.

Used by owner of the JdbcSession as a means to indicate that implicit joining should be done if needed.

Annotations
@Override
removeObserverback to summary
public void removeObserver(TransactionObserver observer)

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.removeObserver.

Doc from org.hibernate.resource.transaction.spi.TransactionCoordinator.removeObserver.

Removed an observer from the coordinator.

Parameters
observer:TransactionObserver

The observer to remove.

Annotations
@Override
setTimeOutback to summary
public void setTimeOut(int seconds)

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.setTimeOut.

Annotations
@Override
org.hibernate.resource.transaction.backend.jta.internal back to summary

public Class JtaTransactionCoordinatorImpl.TransactionDriverControlImpl

extends Object
implements TransactionDriver
Class Inheritance
  • java.lang.Object
  • org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl.TransactionDriverControlImpl
All Implemented Interfaces
org.hibernate.resource.transaction.spi.TransactionCoordinator.TransactionDriver

Implementation of the LocalInflow for this TransactionCoordinator. Allows the local transaction (org.hibernate.Transaction to callback into this TransactionCoordinator for the purpose of driving the underlying JTA transaction.

Field Summary

Modifier and TypeField and Description
private boolean
private final JtaTransactionAdapter

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
protected void
public TransactionStatus
protected void
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

invalidback to summary
private boolean invalid
jtaTransactionAdapterback to summary
private final JtaTransactionAdapter jtaTransactionAdapter

Constructor Detail

TransactionDriverControlImplback to summary
public TransactionDriverControlImpl(JtaTransactionAdapter jtaTransactionAdapter)

Method Detail

beginback to summary
public void begin()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.TransactionDriver.begin.

Doc from org.hibernate.resource.transaction.spi.TransactionCoordinator.TransactionDriver.begin.

Begin the physical transaction

Annotations
@Override
commitback to summary
public void commit()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.TransactionDriver.commit.

Doc from org.hibernate.resource.transaction.spi.TransactionCoordinator.TransactionDriver.commit.

Commit the physical transaction

Annotations
@Override
errorIfInvalidback to summary
protected void errorIfInvalid()
getStatusback to summary
public TransactionStatus getStatus()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.TransactionDriver.getStatus.

Annotations
@Override
invalidateback to summary
protected void invalidate()
markRollbackOnlyback to summary
public void markRollbackOnly()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.TransactionDriver.markRollbackOnly.

Annotations
@Override
rollbackback to summary
public void rollback()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinator.TransactionDriver.rollback.

Doc from org.hibernate.resource.transaction.spi.TransactionCoordinator.TransactionDriver.rollback.

Rollback the physical transaction

Annotations
@Override