All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class semper.txlayer.transaction.Transaction

java.lang.Object
   |
   +----semper.txlayer.transaction.Transaction

public abstract class Transaction
extends Object
implements Runnable, Serializable
The transaction mechanisms. This class is supposed to hold all mechanisms that fulfill the basic transaction properties ACID. This class does not do any communication itself, instead there are the derived TransferTransaction and ExchangeTransaction.


Variable Index

 o _observers
A list of observers that might get notified of certain state changes.
 o _signal
status and signal of the transaction.
 o _thr
This is the thread the transaction runs in.
 o _tid
The transaction id.
 o _timeout
This may hold the timeout value that was passed to us with beginAndBlock(m).
 o ABORTED
 o COMMITTED
 o NO_SIGNAL
 o PREPARED
 o RUNNING
 o TO_BE_ABORTED
Constants for defining signals to be given to the transaction.
 o TO_BE_COMMITTED
 o UNPREPARED
Constants for defining the state the transaction is in.

Constructor Index

 o Transaction()
Empty constructor.
 o Transaction(TransactionID)
Constructor with transaction id as parameter.

Method Index

 o abort()
With this method the outer world can set a signal to abort the transaction.
 o addObserver(TransactionObserver)
Adds an observer object to the transaction.
 o begin()
Starts the transaction and returns to main thread of execution.
 o beginAndBlock()
Starts the transaction and blocks as long as it lasts.
 o beginAndBlock(long)
Starts the transaction and blocks as long as it lasts, but almost m milliseconds.
 o checkForSignal()
Checks if a signal has been set, and consequently changes the control flow of the program, that means triggers methods on a signal.
 o commit()
Makes the transaction real: The last step in successfully finishing a transaction.
 o deleteObserver(TransactionObserver)
Deletes an observer object from the transaction.
 o doAbort()
Does whatever is necessary to abort the transaction.
 o doCommit()
Does whatever is necessary to commit the transaction.
 o end()
Executed at the end of join() Notifies all registered observers.
 o getException()
This method can be called to examine the reason of a Transaction.ABORTED status.
 o getStatus()
 o getTID()
 o join()
Borrowed from thread.
 o join(long)
Same as join(), but with a timeout in milliseconds.
 o newSubTID(int)
Generates a new subtransaction id that fits to the current tid and the parameter i.
 o notifyObserver()
Notify all registered observers.
 o rollback()
performs the recovery to the last saved savepoint.
 o run()
The Thread's run method, for satisfaction of the Runnable interface.
 o setException(TXLayerException)
Sets the internal _exception variable, which will be thrown when somebody calls join() or beginAndBlock().
 o setSignal(int)
Used to set a signal to the transaction.
 o setStatus(int)
Used to set the status of the transaction.
 o setTID(TransactionID)

Variables

 o UNPREPARED
 public static final int UNPREPARED
Constants for defining the state the transaction is in.

 o PREPARED
 public static final int PREPARED
 o RUNNING
 public static final int RUNNING
 o ABORTED
 public static final int ABORTED
 o COMMITTED
 public static final int COMMITTED
 o TO_BE_ABORTED
 protected static final int TO_BE_ABORTED
Constants for defining signals to be given to the transaction.

 o TO_BE_COMMITTED
 protected static final int TO_BE_COMMITTED
 o NO_SIGNAL
 protected static final int NO_SIGNAL
 o _timeout
 protected long _timeout
This may hold the timeout value that was passed to us with beginAndBlock(m). If no value is set, this variable is zero.

 o _tid
 protected TransactionID _tid
The transaction id.

 o _signal
 protected int _signal
status and signal of the transaction.

 o _thr
 protected transient Thread _thr
This is the thread the transaction runs in.

 o _observers
 protected Vector _observers
A list of observers that might get notified of certain state changes.

Constructors

 o Transaction
 public Transaction()
Empty constructor. Can be used, a new transaction id is generated automatically.

 o Transaction
 public Transaction(TransactionID tid)
Constructor with transaction id as parameter. The given id will be used.

Methods

 o checkForSignal
 protected boolean checkForSignal()
Checks if a signal has been set, and consequently changes the control flow of the program, that means triggers methods on a signal. The running transaction thread uses this to poll a desired action.

 o setStatus
 protected boolean setStatus(int s)
Used to set the status of the transaction. Derived transactions (e.g., StatementTransaction) might want to use this.

Parameters:
s - The status that is to be set. You MUST use the constants defined above (UNPREPARED...COMMITTED).
Returns:
true in any case. (?) Note that no one should use integer, but only the symbolic Names. Because these Constants will be real constants (objects) in future.
 o setSignal
 protected boolean setSignal(int s)
Used to set a signal to the transaction. Derived transactions (e.g., StatementTransaction) might want to use this.

Parameters:
s - The signal that is to be set. You MUST use the constants defined above (TO_BE_ABORTED...NO_SIGNAL).
Returns:
true in any case. (?) Note that no one should use integer, but only the symbolic Names. Because these Constants will be real constants (objects) in future.
 o setException
 protected void setException(TXLayerException e)
Sets the internal _exception variable, which will be thrown when somebody calls join() or beginAndBlock().

Parameters:
e - The internal _exception is set to e.
 o doAbort
 protected boolean doAbort()
Does whatever is necessary to abort the transaction.

Returns:
true When abort was successfull, false otherwise.
 o doCommit
 protected boolean doCommit()
Does whatever is necessary to commit the transaction.

Returns:
true When abort was successfull, false otherwise.
 o notifyObserver
 protected boolean notifyObserver()
Notify all registered observers. Doesn't do anything up to now!

Returns:
false When notification failed.
 o newSubTID
 public TransactionID newSubTID(int i)
Generates a new subtransaction id that fits to the current tid and the parameter i. Tom: What's the difference to newSubtransactionID(i)?

Parameters:
i - Parameter which is combined with current tid to new subtid.
 o run
 public abstract void run()
The Thread's run method, for satisfaction of the Runnable interface. DON'T CALL this method from outside.

 o begin
 public void begin()
Starts the transaction and returns to main thread of execution. The transaction runs in the background.

 o beginAndBlock
 public void beginAndBlock() throws TXLayerException
Starts the transaction and blocks as long as it lasts.

Throws: TXLayerException
On problems in executing the transaction.
 o beginAndBlock
 public void beginAndBlock(long m) throws TXLayerException
Starts the transaction and blocks as long as it lasts, but almost m milliseconds.

Parameters:
m - Time in milliseconds that we should wait for the completion of the transaction.
Throws: TXLayerException
On problems in executing the transaction.
 o abort
 public boolean abort()
With this method the outer world can set a signal to abort the transaction. All observers are notified of onAbort.

Returns:
true if the signal could be set, false otherwise.
 o rollback
 public boolean rollback()
performs the recovery to the last saved savepoint. All observers are notified with onRollback.

Returns:
false.
 o commit
 public boolean commit()
Makes the transaction real: The last step in successfully finishing a transaction. All observers are notified with onCommit

Returns:
true if the signal could be set, false otherwise.
 o end
 public boolean end()
Executed at the end of join() Notifies all registered observers.

Returns:
false.
 o join
 public void join() throws TXLayerException
Borrowed from thread. Blocks the caller until the transaction has finished. Calls end() and thus notifies all observers.

Throws: TXLayerException
On problems in executing the transaction.
 o join
 public void join(long millis) throws TXLayerException
Same as join(), but with a timeout in milliseconds. Calls end() and thus notifies all observers.

Parameters:
m - Time in milliseconds that we should wait for the completion of the transaction.
Throws: TXLayerException
On problems in executing the transaction.
 o getStatus
 public int getStatus()
Returns:
The status of a transaction. This is a constants, element of Transaction.UNPREPARED, Transaction.PREPARED, Transaction.RUNNING, Transaction.ABORTED, Transaction.COMITTED.
 o getException
 public TXLayerException getException()
This method can be called to examine the reason of a Transaction.ABORTED status.

Returns:
An Exception that was thrown inside the Transaction and led to the ABORTED status. Beware, this may be null!
 o getTID
 public TransactionID getTID()
Returns:
the TransactionID.
 o setTID
 public boolean setTID(TransactionID tid)
 o addObserver
 public boolean addObserver(TransactionObserver o)
Adds an observer object to the transaction. The observer will be notified about important events. Notification does not happen in a well defined manner up to now! Ask [email protected] or [email protected] if you plan to use this!

Parameters:
o - The observer to be added.
Returns:
true in any case.
 o deleteObserver
 public boolean deleteObserver(TransactionObserver o)
Deletes an observer object from the transaction. Notification does not happen in a well defined manner up to now! Ask [email protected] or [email protected] if you plan to use this!

Parameters:
o - The observer to be deleted.
Returns:
True if o could be deleted, false otherwise.

All Packages  Class Hierarchy  This Package  Previous  Next  Index