com.xenonsoft.bridgetown.aop.transaction
Interface ITransactionContext

All Known Subinterfaces:
IMutableTransactionContext
All Known Implementing Classes:
AbstractTransactionContext, BasicTransactionContext

public interface ITransactionContext

Defines the context of global or local session transaction that is associated per thread with an application.

Version:
$Id: ITransactionContext.java,v 1.3 2005/02/23 01:28:13 peter_pilgrim Exp $
Author:
Peter Pilgrim, 10-Feb-2005

Field Summary
static java.lang.String STANDARD_RESOURCE
          A publicly known constant for a name denotes a "standard" transactional resource .
 
Method Summary
 void closeAllResources()
          Closes all the resources associated the transaction explicitly.
 void commit()
          Completes the transaction and associated it with the current thread.
 void delistResource(java.lang.String name, IResourceController resource)
          Disassociate the supplied transactional resource with the transaction context
 void enlistResource(java.lang.String name, IResourceController resource)
          Associate the supplied transactional resource with the transaction context
 java.lang.Object getAttribute(java.lang.String key)
           
 java.util.Iterator getAttributeNames()
           
 java.lang.Object getResource(java.lang.String name)
          Retrieve the named transactional resource that is associated with this current transaction.
 TransactionStateEnum getTransactionState()
          Retrieves the current state of the transaction
 boolean isRollbackOnly()
          Gets the boolean flag if transaction is primed to roll back, or has rolled back already.
 boolean isTransactionNew()
          Gets the boolean flag if transaction associated with this thread is a brand new creation.
 void rollback()
          Roll back the transaction associated with the current thread.
 void setAttribute(java.lang.String key, java.lang.Object value)
           
 void setRollbackOnly()
          Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.
 void setTransactionTimeout(int seconds)
          Modify the timeout value that is associated with transactions started by subsequent invocations of the begin method.
 

Field Detail

STANDARD_RESOURCE

public static final java.lang.String STANDARD_RESOURCE
A publicly known constant for a name denotes a "standard" transactional resource .

See Also:
Constant Field Values
Method Detail

getResource

public java.lang.Object getResource(java.lang.String name)
                             throws TransactionException
Retrieve the named transactional resource that is associated with this current transaction.

A transactional resource, for example, may be a database connection and the name of this resource may could be JNDI lookup name. This approach would be very similar to way the data sources and associated connections are retrieved in a EJB / JTA connection

Parameters:
name - the name of the transactional resource
Returns:
the transactional resource
Throws:
TransactionException - if the operation cannot be completed
See Also:
enlistResource(String, IResourceController), delistResource(String, IResourceController)

commit

public void commit()
            throws TransactionException
Completes the transaction and associated it with the current thread. The method is typically routed to the transaction service manager in order to properly commit the transaction.

Throws:
TransactionException - if the commit operation cannot be completed
See Also:
rollback(), ITransactionServiceManager#commit(ITransactionSession, ITransactionConfig), ITransactionServiceManager.begin(ITransactionSession, ITransactionConfig)

rollback

public void rollback()
              throws TransactionException
Roll back the transaction associated with the current thread. The method is typically routed to the transaction service manager in order to properly roll back the transaction.

Throws:
TransactionException - if the rollback operation cannot be completed
See Also:
commit(), ITransactionServiceManager.rollback(), ITransactionServiceManager.begin(ITransactionSession, ITransactionConfig)

setRollbackOnly

public void setRollbackOnly()
                     throws TransactionException
Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.

Throws:
TransactionException - if the set rollback operation cannot be completed
See Also:
isRollbackOnly()

setTransactionTimeout

public void setTransactionTimeout(int seconds)
                           throws TransactionException
Modify the timeout value that is associated with transactions started by subsequent invocations of the begin method.

Parameters:
seconds -
Throws:
TransactionException - if the operation cannot be completed

isRollbackOnly

public boolean isRollbackOnly()
Gets the boolean flag if transaction is primed to roll back, or has rolled back already.

Returns:
boolean value if the transaction rolled back
See Also:
rollback()

isTransactionNew

public boolean isTransactionNew()
Gets the boolean flag if transaction associated with this thread is a brand new creation.

Returns:
boolean true if the current transaction is new.
See Also:
ITransactionServiceManager.isTransactionNew(ITransactionContext)

getTransactionState

public TransactionStateEnum getTransactionState()
Retrieves the current state of the transaction

Returns:
the transaction state enumeration

enlistResource

public void enlistResource(java.lang.String name,
                           IResourceController resource)
Associate the supplied transactional resource with the transaction context

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:
delistResource(String, IResourceController)

delistResource

public void delistResource(java.lang.String name,
                           IResourceController resource)
Disassociate the supplied transactional resource with the transaction context

Parameters:
name - the name of the transactional resource
resource - the resource controller to disassociate from the transaction
Throws:
TransactionException - if the delistment operation cannot be completed
See Also:
enlistResource(String, IResourceController)

closeAllResources

public void closeAllResources()
                       throws TransactionException
Closes all the resources associated the transaction explicitly.

The implementations of the transaction context may behave differently. For example JTA implementation typically does not close JNDI connections.

Throws:
TransactionException

getAttributeNames

public java.util.Iterator getAttributeNames()

getAttribute

public java.lang.Object getAttribute(java.lang.String key)

setAttribute

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


Copyright © 2005 XeNoNSoFT.com. All Rights Reserved.