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.
-
_observers
- A list of observers that might get notified of
certain state changes.
-
_signal
- status and signal of the transaction.
-
_thr
- This is the thread the transaction runs in.
-
_tid
- The transaction id.
-
_timeout
- This may hold the timeout value that was
passed to us with beginAndBlock(m).
-
ABORTED
-
-
COMMITTED
-
-
NO_SIGNAL
-
-
PREPARED
-
-
RUNNING
-
-
TO_BE_ABORTED
- Constants for defining signals to be given to the transaction.
-
TO_BE_COMMITTED
-
-
UNPREPARED
- Constants for defining the state the transaction is in.
-
Transaction()
- Empty constructor.
-
Transaction(TransactionID)
- Constructor with transaction id as parameter.
-
abort()
- With this method the outer world can set a signal
to abort the transaction.
-
addObserver(TransactionObserver)
- Adds an observer object to the transaction.
-
begin()
- Starts the transaction and returns to main thread
of execution.
-
beginAndBlock()
- Starts the transaction
and blocks as long as it lasts.
-
beginAndBlock(long)
- Starts the transaction
and blocks as long as it lasts, but almost
m milliseconds.
-
checkForSignal()
- Checks if a signal has been set, and consequently
changes the control flow of the program, that means
triggers methods on a signal.
-
commit()
- Makes the transaction real: The last step
in successfully finishing a transaction.
-
deleteObserver(TransactionObserver)
- Deletes an observer object from the transaction.
-
doAbort()
- Does whatever is necessary to abort the transaction.
-
doCommit()
- Does whatever is necessary to commit the transaction.
-
end()
- Executed at the end of join()
Notifies all registered observers.
-
getException()
- This method can be called to examine
the reason of a Transaction.ABORTED status.
-
getStatus()
-
-
getTID()
-
-
join()
- Borrowed from thread.
-
join(long)
- Same as join(), but with a timeout in
milliseconds.
-
newSubTID(int)
- Generates a new subtransaction id that fits to the current tid
and the parameter i.
-
notifyObserver()
- Notify all registered observers.
-
rollback()
- performs the recovery to the last saved
savepoint.
-
run()
- The Thread's run method, for satisfaction
of the Runnable interface.
-
setException(TXLayerException)
- Sets the internal _exception variable,
which will be thrown when somebody calls join() or
beginAndBlock().
-
setSignal(int)
- Used to set a signal to the transaction.
-
setStatus(int)
- Used to set the status of the transaction.
-
setTID(TransactionID)
-
UNPREPARED
public static final int UNPREPARED
- Constants for defining the state the transaction is in.
PREPARED
public static final int PREPARED
RUNNING
public static final int RUNNING
ABORTED
public static final int ABORTED
COMMITTED
public static final int COMMITTED
TO_BE_ABORTED
protected static final int TO_BE_ABORTED
- Constants for defining signals to be given to the transaction.
TO_BE_COMMITTED
protected static final int TO_BE_COMMITTED
NO_SIGNAL
protected static final int NO_SIGNAL
_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.
_tid
protected TransactionID _tid
- The transaction id.
_signal
protected int _signal
- status and signal of the transaction.
_thr
protected transient Thread _thr
- This is the thread the transaction runs in.
_observers
protected Vector _observers
- A list of observers that might get notified of
certain state changes.
Transaction
public Transaction()
- Empty constructor. Can be used, a new transaction id is
generated automatically.
Transaction
public Transaction(TransactionID tid)
- Constructor with transaction id as parameter.
The given id will be used.
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.
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.
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.
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.
doAbort
protected boolean doAbort()
- Does whatever is necessary to abort the transaction.
- Returns:
- true When abort was successfull, false otherwise.
doCommit
protected boolean doCommit()
- Does whatever is necessary to commit the transaction.
- Returns:
- true When abort was successfull, false otherwise.
notifyObserver
protected boolean notifyObserver()
- Notify all registered observers.
Doesn't do anything up to now!
- Returns:
- false When notification failed.
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.
run
public abstract void run()
- The Thread's run method, for satisfaction
of the Runnable interface. DON'T CALL this
method from outside.
begin
public void begin()
- Starts the transaction and returns to main thread
of execution. The transaction runs in the background.
beginAndBlock
public void beginAndBlock() throws TXLayerException
- Starts the transaction
and blocks as long as it lasts.
- Throws: TXLayerException
- On problems in executing the transaction.
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.
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.
rollback
public boolean rollback()
- performs the recovery to the last saved
savepoint.
All observers are notified with onRollback.
- Returns:
- false.
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.
end
public boolean end()
- Executed at the end of join()
Notifies all registered observers.
- Returns:
- false.
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.
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.
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.
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!
getTID
public TransactionID getTID()
- Returns:
- the TransactionID.
setTID
public boolean setTID(TransactionID tid)
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.
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