com.metamatrix.common.connection
Class BaseTransaction

java.lang.Object
  extended by com.metamatrix.common.connection.BaseTransaction
All Implemented Interfaces:
TransactionInterface
Direct Known Subclasses:
DBIDResourceTransaction, JDBCAuthorizationTransaction, JDBCConnector, JDBCExtensionModuleTransaction

public abstract class BaseTransaction
extends java.lang.Object
implements TransactionInterface


Constructor Summary
protected BaseTransaction(ManagedConnection connection, boolean readonly)
           
 
Method Summary
 void close()
          Return whether this transaction is readonly.
 void commit()
          Make all changes made during this transaction's lifetime and release any data source locks currently held by the associated Connection.
protected  void finalize()
           
 ManagedConnection getConnection()
          Return the connection associated with this transaction.
static boolean getRollbackOnFinalize()
          Return whether transactions, if they have not been committed or rolled back when they are destroyed, are rolled back or committed.
 boolean isClosed()
          Return whether this transaction is readonly.
 boolean isEnded()
          Return whether this transaction is ended.
 boolean isReadonly()
          Return whether this transaction is readonly.
 void rollback()
          Drops all changes made during this transaction's lifetime and release any data source locks currently held by the associated Connection.
static void setRollbackOnFinalize(boolean rollback)
          Set whether transactions, if they have not been committed or rolled back when they are destroyed, are rolled back or committed.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseTransaction

protected BaseTransaction(ManagedConnection connection,
                          boolean readonly)
                   throws ManagedConnectionException
Throws:
ManagedConnectionException
Method Detail

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

commit

public void commit()
            throws ManagedConnectionException
Make all changes made during this transaction's lifetime and release any data source locks currently held by the associated Connection. A transaction can be committed or rolled back any number of times throughout its lifetime, and throughout its lifetime the transaction is guaranteed to have the same connection.

Specified by:
commit in interface TransactionInterface
Throws:
ManagedConnectionException - if an error occurred within or during communication with the associated connection.

rollback

public void rollback()
              throws ManagedConnectionException
Drops all changes made during this transaction's lifetime and release any data source locks currently held by the associated Connection. Once this method is executed, the transaction (after rolling back) becomes invalid, and the connection referenced by this transaction is returned to the pool.

Calling this method on a read-only transaction is unneccessary (and discouraged, since the implementation does nothing in that case anyway).

Specified by:
rollback in interface TransactionInterface
Throws:
ManagedConnectionException - if an error occurred within or during communication with the associated connection.

getConnection

public ManagedConnection getConnection()
                                throws ManagedConnectionException
Return the connection associated with this transaction. NOTE: the connection returned by this method is returned automatically when the transaction is committed or rolled back. Therefore, the connection reference should not be held by the caller; doing so and invoking a method upon the connection after the transaction has completed is undefined.

Returns:
the managed connection for this transaction.
Throws:
ManagedConnectionException

isReadonly

public final boolean isReadonly()
Return whether this transaction is readonly.

Specified by:
isReadonly in interface TransactionInterface
Returns:
true if this transaction is readonly, or false otherwise.

isEnded

public final boolean isEnded()
Return whether this transaction is ended.

Returns:
true if this transaction has ended with a commit or rollback.

isClosed

public final boolean isClosed()
Return whether this transaction is readonly.

Specified by:
isClosed in interface TransactionInterface
Returns:
true if this transaction is readonly, or false otherwise.

close

public void close()
Return whether this transaction is readonly.

Specified by:
close in interface TransactionInterface

getRollbackOnFinalize

public static final boolean getRollbackOnFinalize()
Return whether transactions, if they have not been committed or rolled back when they are destroyed, are rolled back or committed.

Returns:
true if transactions are rolled back when destroyed if not previously committed or rolled back.

setRollbackOnFinalize

public static final void setRollbackOnFinalize(boolean rollback)
Set whether transactions, if they have not been committed or rolled back when they are destroyed, are rolled back or committed.

Parameters:
rollback - true if transactions should be rolled back when destroyed if not previously committed or rolled back.


Copyright © 2009. All Rights Reserved.