org.hibernate.engine.transaction.internal
Class TransactionCoordinatorImpl

java.lang.Object
  extended by org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl
All Implemented Interfaces:
Serializable, TransactionCoordinator

public class TransactionCoordinatorImpl
extends Object
implements TransactionCoordinator

Standard implementation of the Hibernate TransactionCoordinator

IMPL NOTE : Custom serialization handling!

See Also:
Serialized Form

Constructor Summary
TransactionCoordinatorImpl(Connection userSuppliedConnection, TransactionContext transactionContext)
           
TransactionCoordinatorImpl(TransactionContext transactionContext, JdbcCoordinatorImpl jdbcCoordinator, List<TransactionObserver> observers)
           
 
Method Summary
 void addObserver(TransactionObserver observer)
          Adds an observer to the coordinator.
 void afterNonTransactionalQuery(boolean success)
          Performs actions needed after execution of a non-transactional query.
 void afterTransaction(TransactionImplementor hibernateTransaction, int status)
           
 Connection close()
          Close the transaction context, returning any user supplied connection from the underlying JDBC coordinator.
static TransactionCoordinatorImpl deserialize(ObjectInputStream ois, TransactionContext transactionContext)
           
 JdbcCoordinator getJdbcCoordinator()
          Retrieves the JDBC coordinator currently operating within this transaction coordinator.
 SynchronizationCallbackCoordinator getSynchronizationCallbackCoordinator()
           
 SynchronizationRegistry getSynchronizationRegistry()
          Obtain the Synchronization registry associated with this coordinator.
 TransactionImplementor getTransaction()
          Get the Hibernate transaction facade object currently associated with this coordinator.
 TransactionContext getTransactionContext()
          Retrieves the context in which this coordinator operates.
 boolean isSynchronizationRegistered()
           
 boolean isTransactionInProgress()
          Are we "in" an active and joined transaction
 boolean isTransactionJoinable()
          Can we join to the underlying transaction?
 boolean isTransactionJoined()
          Is the underlying transaction already joined?
 void pulse()
          Attempts to register JTA synchronization if possible and needed.
 void removeObserver(TransactionObserver observer)
          Removed an observer from the coordinator.
 void reset()
          Reset the internal state.
 void resetJoinStatus()
          Reset the transaction's join status.
 void sendAfterTransactionBeginNotifications(TransactionImplementor hibernateTransaction)
           
 void sendAfterTransactionCompletionNotifications(TransactionImplementor hibernateTransaction, int status)
           
 void sendBeforeTransactionCompletionNotifications(TransactionImplementor hibernateTransaction)
           
 void serialize(ObjectOutputStream oos)
           
 void setRollbackOnly()
           
 boolean takeOwnership()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionCoordinatorImpl

public TransactionCoordinatorImpl(Connection userSuppliedConnection,
                                  TransactionContext transactionContext)

TransactionCoordinatorImpl

public TransactionCoordinatorImpl(TransactionContext transactionContext,
                                  JdbcCoordinatorImpl jdbcCoordinator,
                                  List<TransactionObserver> observers)
Method Detail

reset

public void reset()
Reset the internal state.


afterTransaction

public void afterTransaction(TransactionImplementor hibernateTransaction,
                             int status)
Specified by:
afterTransaction in interface TransactionCoordinator

isSynchronizationRegistered

public boolean isSynchronizationRegistered()
Specified by:
isSynchronizationRegistered in interface TransactionCoordinator

isTransactionInProgress

public boolean isTransactionInProgress()
Description copied from interface: TransactionCoordinator
Are we "in" an active and joined transaction

Specified by:
isTransactionInProgress in interface TransactionCoordinator
Returns:
true if there is currently a transaction in progress; false otherwise.

getTransactionContext

public TransactionContext getTransactionContext()
Description copied from interface: TransactionCoordinator
Retrieves the context in which this coordinator operates.

Specified by:
getTransactionContext in interface TransactionCoordinator
Returns:
The context of the coordinator

getJdbcCoordinator

public JdbcCoordinator getJdbcCoordinator()
Description copied from interface: TransactionCoordinator
Retrieves the JDBC coordinator currently operating within this transaction coordinator.

Specified by:
getJdbcCoordinator in interface TransactionCoordinator
Returns:
The JDBC coordinator.

getTransaction

public TransactionImplementor getTransaction()
Description copied from interface: TransactionCoordinator
Get the Hibernate transaction facade object currently associated with this coordinator.

Specified by:
getTransaction in interface TransactionCoordinator
Returns:
The current Hibernate transaction.

afterNonTransactionalQuery

public void afterNonTransactionalQuery(boolean success)
Description copied from interface: TransactionCoordinator
Performs actions needed after execution of a non-transactional query.

Specified by:
afterNonTransactionalQuery in interface TransactionCoordinator
Parameters:
success - Was the query successfully performed

resetJoinStatus

public void resetJoinStatus()
Description copied from interface: TransactionCoordinator
Reset the transaction's join status.

Specified by:
resetJoinStatus in interface TransactionCoordinator

getSynchronizationCallbackCoordinator

public SynchronizationCallbackCoordinator getSynchronizationCallbackCoordinator()
Specified by:
getSynchronizationCallbackCoordinator in interface TransactionCoordinator

pulse

public void pulse()
Description copied from interface: TransactionCoordinator
Attempts to register JTA synchronization if possible and needed.

Specified by:
pulse in interface TransactionCoordinator

close

public Connection close()
Description copied from interface: TransactionCoordinator
Close the transaction context, returning any user supplied connection from the underlying JDBC coordinator.

Specified by:
close in interface TransactionCoordinator
Returns:
The user supplied connection (if one).

getSynchronizationRegistry

public SynchronizationRegistry getSynchronizationRegistry()
Description copied from interface: TransactionCoordinator
Obtain the Synchronization registry associated with this coordinator.

Specified by:
getSynchronizationRegistry in interface TransactionCoordinator
Returns:
The registry

addObserver

public void addObserver(TransactionObserver observer)
Description copied from interface: TransactionCoordinator
Adds an observer to the coordinator.

Unlike synchronizations added to the registry, observers are not to be cleared on transaction completion.

Specified by:
addObserver in interface TransactionCoordinator
Parameters:
observer - The observer to add.

removeObserver

public void removeObserver(TransactionObserver observer)
Description copied from interface: TransactionCoordinator
Removed an observer from the coordinator.

Specified by:
removeObserver in interface TransactionCoordinator
Parameters:
observer - The observer to remove.

isTransactionJoinable

public boolean isTransactionJoinable()
Description copied from interface: TransactionCoordinator
Can we join to the underlying transaction?

Specified by:
isTransactionJoinable in interface TransactionCoordinator
Returns:
true if the underlying transaction can be joined or is already joined; false otherwise.
See Also:
TransactionFactory.isJoinableJtaTransaction(TransactionCoordinator, TransactionImplementor)

isTransactionJoined

public boolean isTransactionJoined()
Description copied from interface: TransactionCoordinator
Is the underlying transaction already joined?

Specified by:
isTransactionJoined in interface TransactionCoordinator
Returns:
true if the underlying transaction is already joined; false otherwise.

setRollbackOnly

public void setRollbackOnly()
Specified by:
setRollbackOnly in interface TransactionCoordinator

takeOwnership

public boolean takeOwnership()
Specified by:
takeOwnership in interface TransactionCoordinator

sendAfterTransactionBeginNotifications

public void sendAfterTransactionBeginNotifications(TransactionImplementor hibernateTransaction)
Specified by:
sendAfterTransactionBeginNotifications in interface TransactionCoordinator

sendBeforeTransactionCompletionNotifications

public void sendBeforeTransactionCompletionNotifications(TransactionImplementor hibernateTransaction)
Specified by:
sendBeforeTransactionCompletionNotifications in interface TransactionCoordinator

sendAfterTransactionCompletionNotifications

public void sendAfterTransactionCompletionNotifications(TransactionImplementor hibernateTransaction,
                                                        int status)
Specified by:
sendAfterTransactionCompletionNotifications in interface TransactionCoordinator

serialize

public void serialize(ObjectOutputStream oos)
               throws IOException
Throws:
IOException

deserialize

public static TransactionCoordinatorImpl deserialize(ObjectInputStream ois,
                                                     TransactionContext transactionContext)
                                              throws ClassNotFoundException,
                                                     IOException
Throws:
ClassNotFoundException
IOException


Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.