net.sf.jso.transaction
Class JSOTransaction

java.lang.Object
  extended bynet.sf.jso.transaction.JSOTransaction
All Implemented Interfaces:
Transaction

public class JSOTransaction
extends java.lang.Object
implements Transaction


Field Summary
static int DEFAULT_TIMEOUT
           
 
Fields inherited from interface net.sf.jso.transaction.Transaction
STATUS_ACTIVE, STATUS_COMMITTED, STATUS_NOT_ACTIVE, STATUS_ROLLEDBACK
 
Constructor Summary
JSOTransaction(JSOTransactionManager aManager)
          Constructs the transaction.
 
Method Summary
 void addDeletedOID(OID oid)
          Adds OIDs of objects deleted during transaction activity.
 void addStoredOIDs(java.util.Collection c)
          Adds OIDs of objects stored during transaction activity.
 void begin()
          Begins the transaction.
static JSOTransaction cast(Transaction tx)
          Makes a cast from Transaction to JSOTransaction.
 void commit()
          Commits the transaction.
protected  void finalize()
          Frees resources before it's garbage collected.
 java.sql.Connection getConnection()
          Returns the connection within which the transaction is beeing executed.
 java.util.Set getDeletedOIDs()
          Returns set of OIDs of objects deleted during transaction activity.
 int getStatus()
          Returns transaction status.
 java.util.Set getStoredOIDs()
          Returns set of OIDs of objects stored during transaction activity.
 java.lang.Thread getThread()
          Returns the thread associated to this transaction.
 long getTimeout()
          Gets transaction timeout.
 boolean isActive()
          Indicates if the transaction is active.
 void lock(OID oid, boolean exclusive)
          Holds a lock for an object.
 void rollback()
          Rolls back the transaction.
static void safellyRollback(Transaction tx)
          Rolls back a transaction without throwing any exceptions.
 void setTimeout(long milliseconds)
          Sets transaction timeout.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
See Also:
Constant Field Values
Constructor Detail

JSOTransaction

public JSOTransaction(JSOTransactionManager aManager)
               throws StorageException
Constructs the transaction.

Method Detail

begin

public void begin()
           throws StorageException
Begins the transaction.

Specified by:
begin in interface Transaction
Throws:
StorageException

lock

public void lock(OID oid,
                 boolean exclusive)
          throws StorageException
Holds a lock for an object. All locks are released when transaction finishes.

Throws:
StorageException

isActive

public boolean isActive()
Indicates if the transaction is active.

Specified by:
isActive in interface Transaction
Returns:
true if the transaction is still active; false otherwise.

commit

public void commit()
            throws StorageException
Commits the transaction.

Specified by:
commit in interface Transaction
Throws:
StorageException

rollback

public void rollback()
              throws StorageException
Rolls back the transaction.

Specified by:
rollback in interface Transaction
Throws:
StorageException

getConnection

public java.sql.Connection getConnection()
Returns the connection within which the transaction is beeing executed.


getThread

public java.lang.Thread getThread()
Returns the thread associated to this transaction.


finalize

protected void finalize()
                 throws java.lang.Throwable
Frees resources before it's garbage collected.

Throws:
java.lang.Throwable

setTimeout

public void setTimeout(long milliseconds)
Sets transaction timeout.

Specified by:
setTimeout in interface Transaction
Parameters:
milliseconds - Number of milliseconds for timeout. Values lesser than 1 millisecond mean no timeout should be used.

getTimeout

public long getTimeout()
Gets transaction timeout.

Specified by:
getTimeout in interface Transaction
Returns:
Number of milliseconds for timeout. Values lesser than 1 millisecond mean no timeout is being used.

cast

public static JSOTransaction cast(Transaction tx)
                           throws StorageException
Makes a cast from Transaction to JSOTransaction.

Parameters:
tx - A reference to a potential JSOTransaction.
Returns:
The same tx reference as JSOTransaction.
Throws:
StorageException - If tx is not a JSOTransaction.

addStoredOIDs

public void addStoredOIDs(java.util.Collection c)
Adds OIDs of objects stored during transaction activity.


getStoredOIDs

public java.util.Set getStoredOIDs()
Returns set of OIDs of objects stored during transaction activity.


addDeletedOID

public void addDeletedOID(OID oid)
Adds OIDs of objects deleted during transaction activity.


getDeletedOIDs

public java.util.Set getDeletedOIDs()
Returns set of OIDs of objects deleted during transaction activity.


getStatus

public int getStatus()
Returns transaction status.

Specified by:
getStatus in interface Transaction
Returns:
Transaction status.

safellyRollback

public static void safellyRollback(Transaction tx)
Rolls back a transaction without throwing any exceptions.

Parameters:
tx - The transaction to be rolled back.