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

java.lang.Object
  extended bycom.xenonsoft.bridgetown.aop.transaction.support.TransactionObject
      extended bycom.xenonsoft.bridgetown.aop.transaction.support.AbstractTransactionContext
All Implemented Interfaces:
IMutableTransactionContext, ITransactionContext
Direct Known Subclasses:
BasicTransactionContext, JtaTransactionContext

public abstract class AbstractTransactionContext
extends TransactionObject
implements IMutableTransactionContext

This is an extension of the virtual transaction object class that really takes on board the abstract transaction context concept. This class is a mutable transaction context IMutableTransactionContext in terms of the transaction service manager ITransactionServiceManager because it is the TSM that actually creates, acquires, releases, and destroys a transactional context. The mutable transaction context, then, is not supposed to be called by the application or user program.

This transactional object type is also directly related to the thread of the control. In other words this class are stored as thread local variables or associated in such as way by the TSM.

Version:
$Id: AbstractTransactionContext.java,v 1.5 2005/03/29 23:41:23 peter_pilgrim Exp $
Author:
Peter Pilgrim, 18-Feb-2005 11:17:35

Field Summary
protected  java.util.Map attributes
          Attributes for transaction context
protected  java.util.Map resourceControllers
          A list orderd set collection of resource controllers
protected  boolean rollbackOnly
          True if the transaction is set to rollback only
protected  ITransactionSession session
          The transaction session that create this transaction context.
protected  int timeout
          Transaction timeout
protected  TransactionStateEnum transactionState
          The current transaction state
 
Fields inherited from interface com.xenonsoft.bridgetown.aop.transaction.ITransactionContext
STANDARD_RESOURCE
 
Constructor Summary
AbstractTransactionContext()
          Default constructor
 
Method Summary
 void closeAllResources()
          Closes all transactional resources
 void delistResource(java.lang.String name, IResourceController resource)
          Implements / overrides delistResource Only delist if the resource was already managed by this current transaction context.
 void enlistResource(java.lang.String name, IResourceController resource)
          Implements / overrides enlistResource.
 void fireCloseResourceEvent()
          Notify all registered resource controllers that they should close any resource associated with the transaction
 void fireCommitResourceEvent()
          Notify all registered resource controllers that they should acquire any resource associated with the transaction
 void fireOpenResourceEvent()
          Notify all registered resource controllers that they should acquire any resource associated with the transaction
 boolean firePrepareToCommitEvent()
          Inquire all registered resource controllers if they can commit the transaction.
 void fireResumeResourceEvent()
          Notify all registered resource controllers that they should resume the transaction state, which was place in suspension
 void fireRollbackResourceEvent()
          Notify all registered resource controllers that they should acquire any resource associated with the transaction
 void fireSuspendResourceEvent()
          Notify all registered resource controllers that they should suspend the transaction state until resumption
 java.lang.Object getAttribute(java.lang.String key)
          Implements / overrides getAttribute
 java.util.Iterator getAttributeNames()
          Implements / overrides getAttributeNames
 java.lang.Object getResource(java.lang.String name)
          Implements / overrides getResource
 int getResourceCount()
          Implements / overrides getResourceCount
 java.util.Iterator getResourceNames()
          Implements / overrides getResourceNames
 ITransactionSession getTransactionSession()
          Gets the transaction session that created this transaction context
 TransactionStateEnum getTransactionState()
          Implements / overrides getTransactionState
 int getTransactionTimeout()
          Retrieve the transaction timeout
 boolean isRollbackOnly()
          Implements / overrides isRollbackOnly
 void setAttribute(java.lang.String key, java.lang.Object value)
          Implements / overrides setAttribute
 void setRollbackOnly()
          Implements / overrides setRollbackOnly
 void setTransactionSession(ITransactionSession session)
          Sets the transaction session that created this transaction context
 void setTransactionState(TransactionStateEnum transactionState)
          Sets the transactionState
 void setTransactionTimeout(int seconds)
          Implements / overrides setTransactionTimeout
 java.lang.String toString()
          Returns a human readable string.
 
Methods inherited from class com.xenonsoft.bridgetown.aop.transaction.support.TransactionObject
decrementUsageCount, getSavedConfiguration, getUsageCount, incrementUsageCount, isSuspended, setSavedConfiguration, setSuspended, setUsageCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.xenonsoft.bridgetown.aop.transaction.IMutableTransactionContext
getTransactionService, setTransactionService
 
Methods inherited from interface com.xenonsoft.bridgetown.aop.transaction.ITransactionContext
commit, isTransactionNew, rollback
 

Field Detail

resourceControllers

protected java.util.Map resourceControllers
A list orderd set collection of resource controllers


session

protected ITransactionSession session
The transaction session that create this transaction context. This member is used to close the transaction afterwards.


rollbackOnly

protected boolean rollbackOnly
True if the transaction is set to rollback only


timeout

protected int timeout
Transaction timeout


transactionState

protected TransactionStateEnum transactionState
The current transaction state


attributes

protected java.util.Map attributes
Attributes for transaction context

Constructor Detail

AbstractTransactionContext

public AbstractTransactionContext()
Default constructor

Method Detail

toString

public java.lang.String toString()
Returns a human readable string. Implements / overrides toString

Returns:
See Also:
Object.toString()

getResourceCount

public int getResourceCount()
Implements / overrides getResourceCount

Specified by:
getResourceCount in interface IMutableTransactionContext
Returns:
See Also:
IMutableTransactionContext.getResourceCount()

getResourceNames

public java.util.Iterator getResourceNames()
Implements / overrides getResourceNames

Specified by:
getResourceNames in interface IMutableTransactionContext
Returns:
See Also:
IMutableTransactionContext.getResourceNames()

getResource

public java.lang.Object getResource(java.lang.String name)
                             throws TransactionException
Implements / overrides getResource

Specified by:
getResource in interface ITransactionContext
Parameters:
name - the transactional resource
Returns:
the transactional resource
Throws:
TransactionException - if the operation cannot be completed
java.lang.IllegalArgumentException - thrown if the name is blank or null
See Also:
ITransactionContext.getResource(java.lang.String)

setRollbackOnly

public void setRollbackOnly()
                     throws TransactionException
Implements / overrides setRollbackOnly

Specified by:
setRollbackOnly in interface ITransactionContext
Throws:
TransactionException
See Also:
ITransactionContext.setRollbackOnly()

setTransactionTimeout

public void setTransactionTimeout(int seconds)
                           throws TransactionException
Implements / overrides setTransactionTimeout

Specified by:
setTransactionTimeout in interface ITransactionContext
Parameters:
seconds -
Throws:
TransactionException
See Also:
ITransactionContext.setTransactionTimeout(int)

getTransactionTimeout

public int getTransactionTimeout()
Retrieve the transaction timeout

Returns:
the transaction timeout

isRollbackOnly

public boolean isRollbackOnly()
Implements / overrides isRollbackOnly

Specified by:
isRollbackOnly in interface ITransactionContext
Returns:
See Also:
ITransactionContext.isRollbackOnly()

getTransactionState

public TransactionStateEnum getTransactionState()
Implements / overrides getTransactionState

Specified by:
getTransactionState in interface ITransactionContext
Returns:
See Also:
ITransactionContext.getTransactionState()

setTransactionState

public void setTransactionState(TransactionStateEnum transactionState)
Sets the transactionState

Specified by:
setTransactionState in interface IMutableTransactionContext
Parameters:
transactionState - the new value for transactionState

getTransactionSession

public ITransactionSession getTransactionSession()
Gets the transaction session that created this transaction context

Specified by:
getTransactionSession in interface IMutableTransactionContext
Returns:
the transaction session
See Also:
IMutableTransactionContext.getTransactionSession()

setTransactionSession

public void setTransactionSession(ITransactionSession session)
Sets the transaction session that created this transaction context

Specified by:
setTransactionSession in interface IMutableTransactionContext
Parameters:
session - the transaction session
See Also:
IMutableTransactionContext.setTransactionSession(com.xenonsoft.bridgetown.aop.transaction.ITransactionSession)

enlistResource

public void enlistResource(java.lang.String name,
                           IResourceController resource)
Implements / overrides enlistResource. Only enlist if the resource was not already managed by this current transaction context. Otherwise silently ignore (for now).

Specified by:
enlistResource in interface ITransactionContext
Parameters:
name - the name of the transactional resource
resource - the resource controller to associate with the transaction
Throws:
TransactionException - if the enlistment operation cannot be completed
See Also:
com.xenonsoft.bridgetown.aop.transaction.ITransactionContext#enlistResource(com.xenonsoft.bridgetown.aop.transaction.IResourceController)

delistResource

public void delistResource(java.lang.String name,
                           IResourceController resource)
Implements / overrides delistResource Only delist if the resource was already managed by this current transaction context. Otherwise silently ignore (for now).

Specified by:
delistResource in interface ITransactionContext
Parameters:
name - the name of the transactional resource
resource - the resource controller to associate with the transaction
Throws:
TransactionException - if the enlistment operation cannot be completed
See Also:
com.xenonsoft.bridgetown.aop.transaction.ITransactionContext#delistResource(com.xenonsoft.bridgetown.aop.transaction.IResourceController)

closeAllResources

public void closeAllResources()
                       throws TransactionException
Closes all transactional resources

Specified by:
closeAllResources in interface ITransactionContext
Throws:
TransactionException - if the operation cannot be completed
See Also:
ITransactionContext.closeAllResources(), fireCloseResourceEvent()

fireOpenResourceEvent

public void fireOpenResourceEvent()
Notify all registered resource controllers that they should acquire any resource associated with the transaction

Specified by:
fireOpenResourceEvent in interface IMutableTransactionContext

fireCloseResourceEvent

public void fireCloseResourceEvent()
Notify all registered resource controllers that they should close any resource associated with the transaction

Specified by:
fireCloseResourceEvent in interface IMutableTransactionContext

firePrepareToCommitEvent

public boolean firePrepareToCommitEvent()
Inquire all registered resource controllers if they can commit the transaction.

Specified by:
firePrepareToCommitEvent in interface IMutableTransactionContext

fireSuspendResourceEvent

public void fireSuspendResourceEvent()
Notify all registered resource controllers that they should suspend the transaction state until resumption

Specified by:
fireSuspendResourceEvent in interface IMutableTransactionContext

fireCommitResourceEvent

public void fireCommitResourceEvent()
Notify all registered resource controllers that they should acquire any resource associated with the transaction

Specified by:
fireCommitResourceEvent in interface IMutableTransactionContext

fireRollbackResourceEvent

public void fireRollbackResourceEvent()
Notify all registered resource controllers that they should acquire any resource associated with the transaction

Specified by:
fireRollbackResourceEvent in interface IMutableTransactionContext

fireResumeResourceEvent

public void fireResumeResourceEvent()
Notify all registered resource controllers that they should resume the transaction state, which was place in suspension

Specified by:
fireResumeResourceEvent in interface IMutableTransactionContext

getAttribute

public java.lang.Object getAttribute(java.lang.String key)
Implements / overrides getAttribute

Specified by:
getAttribute in interface ITransactionContext
Parameters:
key -
Returns:
See Also:
ITransactionContext.getAttribute(java.lang.String)

getAttributeNames

public java.util.Iterator getAttributeNames()
Implements / overrides getAttributeNames

Specified by:
getAttributeNames in interface ITransactionContext
Returns:
See Also:
ITransactionContext.getAttributeNames()

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object value)
Implements / overrides setAttribute

Specified by:
setAttribute in interface ITransactionContext
Parameters:
key -
value -
See Also:
ITransactionContext.setAttribute(java.lang.String, java.lang.Object)


Copyright © 2005 XeNoNSoFT.com. All Rights Reserved.