com.xenonsoft.bridgetown.aop.transaction.support
Class AbstractTransactionServiceManager

java.lang.Object
  extended bycom.xenonsoft.bridgetown.aop.transaction.support.AbstractTransactionServiceManager
All Implemented Interfaces:
ITransactionServiceManager
Direct Known Subclasses:
JtaTransactionServiceManager, LumberJacqueTransactionManager

public abstract class AbstractTransactionServiceManager
extends java.lang.Object
implements ITransactionServiceManager

An abstract class that contains the base implementation for a platform transaction service manager.

Version:
$Id: AbstractTransactionServiceManager.java,v 1.4 2005/03/20 17:44:12 peter_pilgrim Exp $
Author:
Peter Pilgrim, 21-Feb-2005 20:12:12

Nested Class Summary
static class AbstractTransactionServiceManager.ConfigStackThreadLocal
          A thread local based stack for storing Transaction Configuration object supplied to the transaction manager
static class AbstractTransactionServiceManager.TxStackThreadLocal
          A thread local based stack for storing Transaction Objects created by the transaction manager
 
Field Summary
protected static AbstractTransactionServiceManager.ConfigStackThreadLocal configStackList
          The thread local stack that contains all transaction configurations known to the transaction service manager
protected  java.util.List participantListeners
          A list of participant that interested in transaction manager events
protected static AbstractTransactionServiceManager.TxStackThreadLocal txStackList
          The thread local stack that contains all transaction objects known to the transaction service manager
 
Constructor Summary
AbstractTransactionServiceManager()
          Default constructor
 
Method Summary
 void addParticipiant(ITransactionParticipant participant)
          Registers a transaction participant for notification of transaction management events.
 void begin(ITransactionSession session, ITransactionConfig config)
          Causes the transaction manager to allocate a transaction object from a transaction session using the configuration attributes supplied.
 void commit()
          This method causes the transaction manager to commit the current transaction object.
protected abstract  void commitRollbackTx(TransactionObject tx, boolean commit)
          A refactored method for this implementation that attempts to commit or rollback the supplied transaction object.
protected abstract  void executeCommitOrRollback(boolean commit, boolean debuggable, java.lang.String identifier, ITransactionConfig config, TransactionObject tx)
          A refactored method to commit or rollback the transaction object.
protected abstract  TransactionObject executeCreate(ITransactionSession session, ITransactionConfig config, boolean debuggable, java.lang.String identifier)
          A refactored method to create a transaction context object.
protected abstract  void executeResume(boolean debuggable, java.lang.String identifier, ITransactionConfig config, TransactionObject tx)
          A refactored method to resume a transaction object Subclasser cannot override this method to perform additional steps.
protected abstract  void executeSuspend(ITransactionConfig config, boolean debuggable, java.lang.String identifier, TransactionObject tx)
          A refactored method to suspend an existing transaction context object.
protected  void fireAfterBegin(TransactionObject tx)
          Notify interested listeners (participants) that a transaction has just began with this transaction manager.
protected  void fireBeforeCommit(TransactionObject tx)
          Notify interested listeners (participants) that a transaction has just about to commit with this transaction manager.
protected  void fireBeforeRollback(TransactionObject tx)
          Notify interested listeners (participants) that a transaction has just about to roll back this transaction manager.
protected abstract  void forceRollbackTx(TransactionObject tx)
          A refactored method for this TM implementation that forces rollback of the transaction object.
protected static java.lang.String getThreadName()
          Print the current thread name with namespace in order to identify the method calls through the transaction manager
 ITransactionContext getTransaction()
          Retrieves the current transaction exception, if it exists within the transaction manager
abstract  boolean isActive()
          Implements / overrides isActive
abstract  boolean isTransactionNew(ITransactionContext txRef)
          Implements / overrides isTransactionNew
 void removeParticipiant(ITransactionParticipant participant)
          Unregisters a transaction participant from notification of transaction management events.
 void resume(ITransactionContext txRef)
          Resumes the transaction object
 void rollback()
          This method causes the transaction manager to rollback the current transaction object.
 ITransactionContext suspend()
          Suspends the current transaction context
protected  void unallocate(boolean commit)
          This method will either commit or rollback the current transaction, if any, and perform unallocation the current transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

txStackList

protected static transient AbstractTransactionServiceManager.TxStackThreadLocal txStackList
The thread local stack that contains all transaction objects known to the transaction service manager


configStackList

protected static transient AbstractTransactionServiceManager.ConfigStackThreadLocal configStackList
The thread local stack that contains all transaction configurations known to the transaction service manager


participantListeners

protected java.util.List participantListeners
A list of participant that interested in transaction manager events

Constructor Detail

AbstractTransactionServiceManager

public AbstractTransactionServiceManager()
Default constructor

Method Detail

getThreadName

protected static java.lang.String getThreadName()
Print the current thread name with namespace in order to identify the method calls through the transaction manager

Returns:
the text with namespace

isActive

public abstract boolean isActive()
Implements / overrides isActive

Specified by:
isActive in interface ITransactionServiceManager
Returns:
the boolean value if the current transaction is active or not
See Also:
ITransactionServiceManager.isActive()

isTransactionNew

public abstract boolean isTransactionNew(ITransactionContext txRef)
                                  throws TransactionException,
                                         java.lang.IllegalArgumentException
Implements / overrides isTransactionNew

Specified by:
isTransactionNew in interface ITransactionServiceManager
Parameters:
txRef - the reference transaction context
Returns:
the boolean value if the transaction context is new or not
Throws:
TransactionException
java.lang.IllegalArgumentException
See Also:
ITransactionServiceManager.isTransactionNew(com.xenonsoft.bridgetown.aop.transaction.ITransactionContext)

begin

public void begin(ITransactionSession session,
                  ITransactionConfig config)
           throws TransactionException
Causes the transaction manager to allocate a transaction object from a transaction session using the configuration attributes supplied. The transaction manager, then, also starts the transaction before returning.

Specified by:
begin in interface ITransactionServiceManager
Parameters:
session - the transaction session
config - the transaction configuration
Throws:
TransactionException - if there is a transaction operation failure
java.lang.IllegalArgumentException - Unknown transaction demarcation enumeration
See Also:
commit(), rollback()

unallocate

protected void unallocate(boolean commit)
                   throws TransactionException
This method will either commit or rollback the current transaction, if any, and perform unallocation the current transaction.

Parameters:
commit - parameter is true if commit is the required operation, otherwise the request is a rollback.
Throws:
TransactionException - if there is a transaction operation failure
See Also:
commit(), rollback()

suspend

public ITransactionContext suspend()
                            throws TransactionException
Suspends the current transaction context

Specified by:
suspend in interface ITransactionServiceManager
Returns:
the current transaction context
Throws:
TransactionException - if there is a transaction operation failure

resume

public void resume(ITransactionContext txRef)
            throws TransactionException
Resumes the transaction object

Specified by:
resume in interface ITransactionServiceManager
Parameters:
txRef - the transaction object as a reference
Throws:
TransactionException - if there is a transaction operation failure
java.lang.IllegalArgumentException - if the transaction object does not belong to this transaction manager
java.lang.IllegalStateException - if the transaction object was never suspended in the first place

commit

public void commit()
            throws TransactionException
This method causes the transaction manager to commit the current transaction object.

Specified by:
commit in interface ITransactionServiceManager
Throws:
TransactionException - if there is a transaction operation failure

rollback

public void rollback()
              throws TransactionException
This method causes the transaction manager to rollback the current transaction object.

Specified by:
rollback in interface ITransactionServiceManager
Throws:
TransactionException - if there is a transaction operation failure

executeCreate

protected abstract TransactionObject executeCreate(ITransactionSession session,
                                                   ITransactionConfig config,
                                                   boolean debuggable,
                                                   java.lang.String identifier)
                                            throws TransactionException
A refactored method to create a transaction context object. Subclasser cannot override this method to perform additional steps.

Parameters:
session - the transaction session factory
config - the transaction configuration
debuggable - if the logging debuggable flag is set
identifier - the transaction service identifier for logging
Returns:
the brand new transaction object
Throws:
TransactionException - if there is a transaction operation failure

executeSuspend

protected abstract void executeSuspend(ITransactionConfig config,
                                       boolean debuggable,
                                       java.lang.String identifier,
                                       TransactionObject tx)
                                throws TransactionException
A refactored method to suspend an existing transaction context object. Subclasser cannot override this method to perform additional steps.

Parameters:
config - the transaction configuration
debuggable - if the logging debuggable flag is set
identifier - the transaction service identifier for logging
tx - the transaction object that represents a transaction context to suspend
Throws:
TransactionException - if there is a transaction operation failure

executeCommitOrRollback

protected abstract void executeCommitOrRollback(boolean commit,
                                                boolean debuggable,
                                                java.lang.String identifier,
                                                ITransactionConfig config,
                                                TransactionObject tx)
                                         throws TransactionException
A refactored method to commit or rollback the transaction object. Subclasser cannot override this method to perform additional steps.

Parameters:
commit - if true then attempt to commit transaction otherwise rollback
debuggable - the debuggable flag if this method writes to logger
identifier - the transaction service manager identifier
config - the transaction configuration
tx - the transaction context
Throws:
TransactionException - if there is a transaction operation failure

executeResume

protected abstract void executeResume(boolean debuggable,
                                      java.lang.String identifier,
                                      ITransactionConfig config,
                                      TransactionObject tx)
                               throws TransactionException
A refactored method to resume a transaction object Subclasser cannot override this method to perform additional steps.

Parameters:
debuggable - the debuggable flag if this method writes to logger
identifier - the transaction service manager identifier
config - the transaction configuration
tx - the transaction context
Throws:
TransactionException - if there is a transaction operation failure

commitRollbackTx

protected abstract void commitRollbackTx(TransactionObject tx,
                                         boolean commit)
                                  throws TransactionException
A refactored method for this implementation that attempts to commit or rollback the supplied transaction object.

Parameters:
tx - the transaction object
commit - if true then attempt to commit transaction otherwise rollback
Throws:
TransactionException - if there is a transaction operation failure

forceRollbackTx

protected abstract void forceRollbackTx(TransactionObject tx)
                                 throws TransactionException
A refactored method for this TM implementation that forces rollback of the transaction object.

Parameters:
tx - the transaction object
Throws:
TransactionException - if there is a transaction operation failure

addParticipiant

public void addParticipiant(ITransactionParticipant participant)
Registers a transaction participant for notification of transaction management events.

Specified by:
addParticipiant in interface ITransactionServiceManager
Parameters:
participant - the transaction participant

removeParticipiant

public void removeParticipiant(ITransactionParticipant participant)
Unregisters a transaction participant from notification of transaction management events.

Specified by:
removeParticipiant in interface ITransactionServiceManager
Parameters:
participant - the transaction participant

getTransaction

public ITransactionContext getTransaction()
                                   throws TransactionException
Retrieves the current transaction exception, if it exists within the transaction manager

Specified by:
getTransaction in interface ITransactionServiceManager
Returns:
the current transaction object
Throws:
TransactionException - if there is a transaction operation failure
See Also:
LumberJacqueTransactionManager.isActive()

fireAfterBegin

protected void fireAfterBegin(TransactionObject tx)
Notify interested listeners (participants) that a transaction has just began with this transaction manager.

Parameters:
tx - the transaction object

fireBeforeCommit

protected void fireBeforeCommit(TransactionObject tx)
Notify interested listeners (participants) that a transaction has just about to commit with this transaction manager.

Parameters:
tx - the transaction object

fireBeforeRollback

protected void fireBeforeRollback(TransactionObject tx)
Notify interested listeners (participants) that a transaction has just about to roll back this transaction manager.

Parameters:
tx - the transaction object


Copyright © 2005 XeNoNSoFT.com. All Rights Reserved.