Purpose: Abstract implementation of an ExternalTransactionController.
Description: This class implements the ExternalTransactionController interface. Concrete implementations of this class are responsible for performing the coordination with the external transaction manager through whatever means available to that manager. Different transaction services may do this in slightly different ways, but most common ones (JTA and JTS/OTS) will use a synchronization interface.
AbstractSynchronizationListener, org.eclipse.persistence.sessions.ExternalTransactionController
| Modifier and Type | Field and Description |
|---|---|
| protected ThreadLocal | activeUnitOfWorkThreadLocal
PERF: Cache the active uow in a thread local. |
| protected ConcurrentMap | currentlyProcessedListeners
Non-null only in case sequencing callbacks are used: numSessionsRequiringSequencingCallback > 0 |
| protected ExceptionHandler | exceptionHandler
Allow exception in before/after completion to be wrapped. |
| protected SynchronizationListenerFactory | listenerFactory
Generates listener instances for synchronization |
| protected int | numSessionsRequiringSequencingCallback
more - the session is a session broker with several members requiring sequencing callbacks. |
| protected ConcurrentMap | sequencingListeners
Non-null only in case sequencing callbacks are used: numSessionsRequiringSequencingCallback > 0 |
| protected AbstractSession | session
The session this controller is responsible for controlling |
| protected ConcurrentMap | unitsOfWork
Table of external transaction object keys and unit of work values |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | addUnitOfWork(Object transactionKey, UnitOfWorkImpl activeUnitOfWork)
INTERNAL: Add a UnitOfWork object to the Hashtable keyed on the external transaction object. |
| public void | beginTransaction(AbstractSession
The session for which the transaction is being begun. session)Implements org. |
| protected abstract void | |
| public void | bindToCurrentTransaction(UnitOfWorkImpl
The unit of work that is to be bound to the active transaction unitOfWork, AbstractSession The session ancestor of the unit of work session)INTERNAL: Associate the given unit of work and EclipseLink session with the active external transaction. |
| protected abstract boolean | Returns: true if the current state allows for a transaction to be startedThe current transaction status status)INTERNAL: Return true if the status indicates that a transaction can be started. |
| protected abstract boolean | Returns: true if the current state allows for a transaction to be committedThe current transaction status status)INTERNAL: Return true if the status indicates that a transaction can be committed. |
| protected abstract boolean | Returns: true if the current state allows for the SQL to be sent to the databaseThe current transaction status status)INTERNAL: Return true if the status indicates that the SQL should be issued to the db. |
| protected abstract boolean | Returns: true if the current state dictates that the unit of work should be mergedThe current transaction status status)INTERNAL: Return true if the status indicates that the unit of work should be merged into the shared cache. |
| protected abstract boolean | Returns: true if the current state allows for a transaction to be rolled backThe current transaction status status)INTERNAL: Return true if the status indicates that a transaction can be rolled back. |
| public void | clearSequencingListeners()
Implements org. |
| public void | commitTransaction(AbstractSession
The session for which the transaction is being committed. session)Implements org. |
| protected abstract void | |
| public SequencingCallback | getActiveSequencingCallback(DatabaseSession dbSession, SequencingCallbackFactory sequencingCallbackFactory)
Implements org. |
| public UnitOfWorkImpl | getActiveUnitOfWork()
Implements org. |
| public ExceptionHandler | getExceptionHandler()
Implements org. |
| public SynchronizationListenerFactory | |
| public AbstractSession | getSession()
Implements org. |
| public Object | |
| protected abstract Object | Returns: The active transaction object, or null if no transaction is activeINTERNAL: Return the active external transaction for the calling thread, or null if none is currently active for this thread. |
| public Object | getTransactionKey(Object transaction)
INTERNAL: Return a key for the specified external transaction object. |
| protected abstract Object | Returns: A key for the passed in transaction, or null if no transaction specifiedThe transaction to which the returned key applies (may be null) transaction)INTERNAL: Return a key for the specified external transaction object. |
| public Object | |
| protected abstract Object | Returns: The current transaction statusINTERNAL: Return the transaction status. |
| public Map | getUnitsOfWork()
INTERNAL: Return the hashtable keyed on the external transaction objects with values that are the associated units of work. |
| public boolean | hasActiveUnitOfWork()
INTERNAL: Return true if there is a unit of work associated with the active external transaction. |
| public void | initializeSequencingListeners()
Implements org. |
| public abstract boolean | isRolledBack_impl(Object status)
INTERNAL: Return true if the transaction is in the rolled back state. |
| public boolean | |
| public Object | Returns: The object bound in JNDI to the specified nameThe name to look up jndiName)PUBLIC: Look up a given name in JNDI. |
| public void | |
| public void | |
| public UnitOfWorkImpl | lookupActiveUnitOfWork()
INTERNAL: Return the unit of work associated with the active external transaction. |
| public UnitOfWorkImpl | lookupActiveUnitOfWork(Object transaction)
INTERNAL: Return the unit of work associated with the active external transaction. |
| public void | markTransactionForRollback()
Implements org. |
| protected abstract void | |
| public boolean | noTransactionOrRolledBackOrCommited()
INTERNAL: Used the EJB 3.0 to determine if a transaction is in a state where an EntityManager can be closed |
| public int | numSessionsRequiringSequencingCallback()
INTERNAL: Indicates how many sessions require sequencing callbacks. |
| protected abstract void | registerSynchronization_impl(AbstractSynchronizationListener
The synchronization listener created for this transaction listener, Object The active transaction for which notification is being requested txn)INTERNAL: Register the specified synchronization listener with the given active transaction. |
| public void | registerSynchronizationListener(UnitOfWorkImpl uow, AbstractSession session)
Implements org. |
| public void | |
| public void | removeUnitOfWork(Object transactionKey)
INTERNAL: Remove the unit of work associated with the transaction passed in. |
| public void | rollbackTransaction(AbstractSession
The session for which the transaction is being rolled back. session)Implements org. |
| protected abstract void | |
| public void | setExceptionHandler(ExceptionHandler exceptionHandler)
Implements org. |
| public void | setListenerFactory(SynchronizationListenerFactory factory)
INTERNAL: Set the factory used to generate synchronization listeners. |
| public void | setSession(AbstractSession session)
Implements org. |
| protected void | setUnitsOfWork(ConcurrentMap<Object, UnitOfWorkImpl> unitsOfWork)
INTERNAL: Set the table of transactions to units of work. |
| protected abstract String |
| activeUnitOfWorkThreadLocal | back to summary |
|---|---|
| protected ThreadLocal<UnitOfWorkImpl> activeUnitOfWorkThreadLocal PERF: Cache the active uow in a thread local. | |
| currentlyProcessedListeners | back to summary |
|---|---|
| protected ConcurrentMap<Object, AbstractSynchronizationListener> currentlyProcessedListeners Non-null only in case sequencing callbacks are used: numSessionsRequiringSequencingCallback > 0 | |
| exceptionHandler | back to summary |
|---|---|
| protected ExceptionHandler exceptionHandler Allow exception in before/after completion to be wrapped. | |
| listenerFactory | back to summary |
|---|---|
| protected SynchronizationListenerFactory listenerFactory Generates listener instances for synchronization | |
| numSessionsRequiringSequencingCallback | back to summary |
|---|---|
| protected int numSessionsRequiringSequencingCallback more - the session is a session broker with several members requiring sequencing callbacks. | |
| sequencingListeners | back to summary |
|---|---|
| protected ConcurrentMap<Object, AbstractSynchronizationListener> sequencingListeners Non-null only in case sequencing callbacks are used: numSessionsRequiringSequencingCallback > 0 | |
| session | back to summary |
|---|---|
| protected AbstractSession session The session this controller is responsible for controlling | |
| unitsOfWork | back to summary |
|---|---|
| protected ConcurrentMap<Object, UnitOfWorkImpl> unitsOfWork Table of external transaction object keys and unit of work values | |
| AbstractTransactionController | back to summary |
|---|---|
| protected AbstractTransactionController() INTERNAL: Return a new controller. | |
| addUnitOfWork | back to summary |
|---|---|
| public void addUnitOfWork(Object transactionKey, UnitOfWorkImpl activeUnitOfWork) INTERNAL: Add a UnitOfWork object to the Hashtable keyed on the external transaction object. | |
| beginTransaction | back to summary |
|---|---|
| public void beginTransaction(AbstractSession session) Implements org. INTERNAL: Begin an external transaction.
| |
| beginTransaction_impl | back to summary |
|---|---|
| protected abstract void beginTransaction_impl() throws Exception INTERNAL: Begin an external transaction. Do this in a way appropriate to the transaction subsystem. | |
| bindToCurrentTransaction | back to summary |
|---|---|
| public void bindToCurrentTransaction(UnitOfWorkImpl unitOfWork, AbstractSession session) INTERNAL: Associate the given unit of work and EclipseLink session with the active external transaction. This may be done by whatever means supported by the transaction manager (i.e. through a synchronization protocol).
| |
| canBeginTransaction_impl | back to summary |
|---|---|
| protected abstract boolean canBeginTransaction_impl(Object status) INTERNAL: Return true if the status indicates that a transaction can be started. This would normally mean that no transaction is currently active. The status is interpreted by the transaction subsystem.
| |
| canCommitTransaction_impl | back to summary |
|---|---|
| protected abstract boolean canCommitTransaction_impl(Object status) INTERNAL: Return true if the status indicates that a transaction can be committed. This would normally mean that a transaction is currently active. The status is interpreted by the transaction subsystem.
| |
| canIssueSQLToDatabase_impl | back to summary |
|---|---|
| protected abstract boolean canIssueSQLToDatabase_impl(Object status) INTERNAL: Return true if the status indicates that the SQL should be issued to the db. This would normally mean that a transaction was active and not being rolled back or marked for rollback. The status is interpreted by the transaction subsystem.
| |
| canMergeUnitOfWork_impl | back to summary |
|---|---|
| protected abstract boolean canMergeUnitOfWork_impl(Object status) INTERNAL: Return true if the status indicates that the unit of work should be merged into the shared cache. This would normally mean that the transaction was committed successfully. The status is interpreted by the transaction subsystem.
| |
| canRollbackTransaction_impl | back to summary |
|---|---|
| protected abstract boolean canRollbackTransaction_impl(Object status) INTERNAL: Return true if the status indicates that a transaction can be rolled back. This would normally mean that a transaction is currently active. The status is interpreted by the transaction subsystem.
| |
| clearSequencingListeners | back to summary |
|---|---|
| public void clearSequencingListeners() Implements org. INTERNAL: Clears sequencing listeners. Called by initializeSequencingListeners and by sequencing on disconnect.
| |
| commitTransaction | back to summary |
|---|---|
| public void commitTransaction(AbstractSession session) Implements org. INTERNAL: Commit the external transaction.
| |
| commitTransaction_impl | back to summary |
|---|---|
| protected abstract void commitTransaction_impl() throws Exception INTERNAL: Commit the external transaction. Do this in a way appropriate to the transaction subsystem. | |
| getActiveSequencingCallback | back to summary |
|---|---|
| public SequencingCallback getActiveSequencingCallback(DatabaseSession dbSession, SequencingCallbackFactory sequencingCallbackFactory) Implements org. INTERNAL: Returns sequencingCallback for the current active external transaction. DatabaseSession is passed for the sake of SessionBroker case. This method requires active external transaction.
| |
| getActiveUnitOfWork | back to summary |
|---|---|
| public UnitOfWorkImpl getActiveUnitOfWork() Implements org. INTERNAL: Return the active unit of work for the current external transaction. If no transaction is active then return null. If a transaction is active but no unit of work has been bound to it then create and return one.
| |
| getExceptionHandler | back to summary |
|---|---|
| public ExceptionHandler getExceptionHandler() Implements org. Return the exception handler used to handle or wrap exceptions thrown in before/after completion.
| |
| getListenerFactory | back to summary |
|---|---|
| public SynchronizationListenerFactory getListenerFactory() INTERNAL: Get the factory used to generate synchronization listeners. | |
| getSession | back to summary |
|---|---|
| public AbstractSession getSession() Implements org. INTERNAL: Return the manager's session.
| |
| getTransaction | back to summary |
|---|---|
| public Object getTransaction() INTERNAL: Return the active external transaction object, or null if none is active. This may be in whatever form the transaction system uses. | |
| getTransaction_impl | back to summary |
|---|---|
| protected abstract Object getTransaction_impl() throws Exception INTERNAL: Return the active external transaction for the calling thread, or null if none is currently active for this thread.
| |
| getTransactionKey | back to summary |
|---|---|
| public Object getTransactionKey(Object transaction) INTERNAL: Return a key for the specified external transaction object. The key is just something that can be inserted into a hashtable (must support hashCode() and equals() methods). | |
| getTransactionKey_impl | back to summary |
|---|---|
| protected abstract Object getTransactionKey_impl(Object transaction) throws Exception INTERNAL: Return a key for the specified external transaction object. The key is just something that can be inserted into a hashtable (must support hashCode() and equals() methods). | |
| getTransactionStatus | back to summary |
|---|---|
| public Object getTransactionStatus() INTERNAL: Return the transaction status. This may be any type of status or value, depending upon the transaction system. | |
| getTransactionStatus_impl | back to summary |
|---|---|
| protected abstract Object getTransactionStatus_impl() throws Exception INTERNAL: Return the transaction status. This may be any type of status or value, depending upon the transaction system.
| |
| getUnitsOfWork | back to summary |
|---|---|
| public Map INTERNAL: Return the hashtable keyed on the external transaction objects with values that are the associated units of work. | |
| hasActiveUnitOfWork | back to summary |
|---|---|
| public boolean hasActiveUnitOfWork() INTERNAL: Return true if there is a unit of work associated with the active external transaction. Return false if no transaction is current, or if no uow has been associated with the active transaction yet. | |
| initializeSequencingListeners | back to summary |
|---|---|
| public void initializeSequencingListeners() Implements org. INTERNAL: Initializes sequencing listeners. There are two methods calling this method: 1. setSession method - this could lead to initialization of sequencing listeners only if sequencing already connected (that would happen if setSession is called after session.login, which is normally not the case). 2. in the very end of connecting sequencing or adding descriptors to sequencing, after it's determined whether sequencing callbacks (and therefore listeners) will be required. In SessionBroker case each member's sequencing may call this method. Note that the number of sessions requiring callbacks may never decrease, therefore if isSequencingCallbackRequired method has returned true once, it will always return true after that (unless clearSequencingListeners method is called).
| |
| isRolledBack_impl | back to summary |
|---|---|
| public abstract boolean isRolledBack_impl(Object status) INTERNAL: Return true if the transaction is in the rolled back state. | |
| isSequencingCallbackRequired | back to summary |
|---|---|
| public boolean isSequencingCallbackRequired() INTERNAL: Indicates whether sequencing callback may be required. | |
| jndiLookup | back to summary |
|---|---|
| public Object jndiLookup(String jndiName) PUBLIC: Look up a given name in JNDI. This can be used by a subclass or even an application to look up transaction artifacts that are required for the implementation. The lookup assumes that it is taking place on the server side, and that the InitialContext can be used without requiring any special properties.
| |
| logTxStateTrace | back to summary |
|---|---|
| public void logTxStateTrace(AbstractSession session, String msgInd, Object status) | |
| logTxTrace | back to summary |
|---|---|
| public void logTxTrace(AbstractSession session, String msgInd, Object[] args) | |
| lookupActiveUnitOfWork | back to summary |
|---|---|
| public UnitOfWorkImpl lookupActiveUnitOfWork() INTERNAL: Return the unit of work associated with the active external transaction. Return null if no transaction is active, or if no uow has been associated with the active transaction yet. | |
| lookupActiveUnitOfWork | back to summary |
|---|---|
| public UnitOfWorkImpl lookupActiveUnitOfWork(Object transaction) INTERNAL: Return the unit of work associated with the active external transaction. Return null if no transaction is active, or if no uow has been associated with the active transaction yet. | |
| markTransactionForRollback | back to summary |
|---|---|
| public void markTransactionForRollback() Implements org. INTERNAL: Mark the external transaction for rollback.
| |
| markTransactionForRollback_impl | back to summary |
|---|---|
| protected abstract void markTransactionForRollback_impl() throws Exception INTERNAL: Mark the external transaction for rollback. Do this in a way appropriate to the transaction subsystem. | |
| noTransactionOrRolledBackOrCommited | back to summary |
|---|---|
| public boolean noTransactionOrRolledBackOrCommited() INTERNAL: Used the EJB 3.0 to determine if a transaction is in a state where an EntityManager can be closed | |
| numSessionsRequiringSequencingCallback | back to summary |
|---|---|
| public int numSessionsRequiringSequencingCallback() INTERNAL: Indicates how many sessions require sequencing callbacks. | |
| registerSynchronization_impl | back to summary |
|---|---|
| protected abstract void registerSynchronization_impl(AbstractSynchronizationListener listener, Object txn) throws Exception INTERNAL: Register the specified synchronization listener with the given active transaction.
| |
| registerSynchronizationListener | back to summary |
|---|---|
| public void registerSynchronizationListener(UnitOfWorkImpl uow, AbstractSession session) throws DatabaseException Implements org. INTERNAL: Associate the given unit of work and EclipseLink session with the current external transaction. This method is offered only for backwards compatibility.
| |
| removeSequencingListener | back to summary |
|---|---|
| public void removeSequencingListener(Object transactionKey) INTERNAL: Clears sequencingCallbacks. Called by initializeSequencingCallbacks and by sequencing on disconnect. | |
| removeUnitOfWork | back to summary |
|---|---|
| public void removeUnitOfWork(Object transactionKey) INTERNAL: Remove the unit of work associated with the transaction passed in. | |
| rollbackTransaction | back to summary |
|---|---|
| public void rollbackTransaction(AbstractSession session) Implements org. INTERNAL: Roll back the external transaction.
| |
| rollbackTransaction_impl | back to summary |
|---|---|
| protected abstract void rollbackTransaction_impl() throws Exception INTERNAL: Roll back the external transaction. Do this in a way appropriate to the transaction subsystem. | |
| setExceptionHandler | back to summary |
|---|---|
| public void setExceptionHandler(ExceptionHandler exceptionHandler) Implements org. Set an exception handler to handle or wrap exceptions thrown in before/after completion.
| |
| setListenerFactory | back to summary |
|---|---|
| public void setListenerFactory(SynchronizationListenerFactory factory) INTERNAL: Set the factory used to generate synchronization listeners. This should be set if a listener other than the default one is being used. | |
| setSession | back to summary |
|---|---|
| public void setSession(AbstractSession session) Implements org. INTERNAL: Set the manager's session.
| |
| setUnitsOfWork | back to summary |
|---|---|
| protected void setUnitsOfWork(ConcurrentMap<Object, UnitOfWorkImpl> unitsOfWork) INTERNAL: Set the table of transactions to units of work. | |
| statusToString_impl | back to summary |
|---|---|
| protected abstract String statusToString_impl(Object status) INTERNAL: Convert the status to a string for tracing. | |