i3.dragos.core.services.datasources
Interface DataSourceTransaction


public interface DataSourceTransaction

The Transaction interface is used by DRAGOS to obtain access to the transaction of the underlying data source.

Author:
Ernest Hammerschmidt <ernest@i3.informatik.rwth-aachen.de>, Thorsten Hermes <thermes@i3.informatik.rwth-aachen.de>

Method Summary
 void begin()
          Begins a new transaction on the data source.
 void commit()
          Commits the current transaction on the data source.
 java.lang.String getName()
          Returns the implementation-dependant name of the transaction (mostly useful for debugging).
 DataSourceTransaction getParentTransaction()
          Returns the parent transaction if this is a nested transaction, null otherwise.
 Transaction.State getState()
          Returns the current state of the transaction.
 void prepareCommit()
          Prepares a transaction for two-phase commit.
 void rollback()
          Performs a rollback on the current transaction and all nested transactions below it.
 void setRollbackOnly()
          Sets rollback to be the only possible outcome of the transaction.
 

Method Detail

begin

void begin()
           throws DataSourceTransactionException
Begins a new transaction on the data source.

Throws:
DataSourceTransactionException - if it was not possible to create a new transaction.

prepareCommit

void prepareCommit()
                   throws DataSourceTransactionException
Prepares a transaction for two-phase commit.

After this method, the transaction will be in state Transaction.State#PREPARED.

The TransactionManager will ensure that this method is called before commit(), and that the next method call will either be to commit() or rollback(). No graph data manipulation will happen between the call to this method and the following call, and it is explicitly allowed for an implementation to terminate the current session during execution of this method, meaning any changes might not be visible even in the context of this transaction until the actual commit is performed.

If an implementation does not support the two-phase commit protocol, it should just set its state to Transaction.State#PREPARED and return.

Throws:
DataSourceTransactionException - if it was not possible to prepare the transaction for two-phase commit.

commit

void commit()
            throws DataSourceTransactionException
Commits the current transaction on the data source.

Throws:
DataSourceTransactionException - if it was not possible to commit the transaction.

rollback

void rollback()
              throws DataSourceTransactionException
Performs a rollback on the current transaction and all nested transactions below it.

Throws:
DataSourceTransactionException - if it was not possible to rollback the transaction.
See Also:
Transaction.commit()

setRollbackOnly

void setRollbackOnly()
                     throws DataSourceTransactionException
Sets rollback to be the only possible outcome of the transaction.

Throws:
DataSourceTransactionException - if it was not possible to set the transaction to rollback only.

getState

Transaction.State getState()
                           throws DataSourceTransactionException
Returns the current state of the transaction.

Returns:
A Status object representing the status of the transaction.
Throws:
DataSourceTransactionException - if it was not possible to get the status information.

getName

java.lang.String getName()
                         throws DataSourceTransactionException
Returns the implementation-dependant name of the transaction (mostly useful for debugging).

Returns:
A string representing this transaction.
Throws:
DataSourceTransactionException - if it was not possible to get the string representation.

getParentTransaction

DataSourceTransaction getParentTransaction()
                                           throws DataSourceTransactionException
Returns the parent transaction if this is a nested transaction, null otherwise.

Returns:
the parent transaction if this is a nested transaction, null otherwise.
Throws:
DataSourceTransactionException - in case of internal errors.


Copyright © 2002-2008 RWTH Aachen, Department of Computer Science 3 (Software Engineering). All Rights Reserved.