Package com.iizix.gyro
Class GyroTransaction
- java.lang.Object
- com.iizix.gyro.GyroTransaction
public class GyroTransaction extends java.lang.Object
The gyro transaction class is used to record all changes in a property container for commit/rollback operations.- Author:
- Christopher Mindus
Constructor Summary
Constructors Constructor Description GyroTransaction(PropCnr transactionContainer, IFocusEngine focusEngine)
Creates the gyro transaction for a property container.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
begin()
Begins the transaction.void
commit()
Commits the work done in the property container.void
dispose()
Disposes of the instance.protected void
finalize()
Make sure we're always disposed of if garbage collected.IFocusEngine
getFocusEngine()
Returns the focus engine associated with this Gyro transaction.IFocusComp
getRollbackFocus()
Returns the focus that is to be set due to the rollback.PropCnr
getTransactionContainer()
Returns the transaction property container for the GyroTransaction.IFocusComp
rollback()
Rolls back the work done in the transaction and returns the component who's focus must be restored to.
Constructor Detail
GyroTransaction
public GyroTransaction(PropCnr transactionContainer, IFocusEngine focusEngine)
Creates the gyro transaction for a property container.- Parameters:
transactionContainer
- The property container of the transaction, typically a VirtualSpace.focusEngine
- The focus engine to use, VirtualSpace or Panel, null for none.
Method Detail
getTransactionContainer
public PropCnr getTransactionContainer()
Returns the transaction property container for the GyroTransaction.- Returns:
- The property container.
getFocusEngine
public IFocusEngine getFocusEngine()
Returns the focus engine associated with this Gyro transaction.- Returns:
- The focus engine, or null for none.
getRollbackFocus
public IFocusComp getRollbackFocus()
Returns the focus that is to be set due to the rollback.- Returns:
- The focus component, null for none.
finalize
protected void finalize() throws java.lang.Throwable
Make sure we're always disposed of if garbage collected.- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
- In case finalize doesn't perform too well.
dispose
public void dispose()
Disposes of the instance. This method should be called when the transaction is canceled.Note: Calling this method will cancel commit and rollback possibilities!
begin
public void begin()
Begins the transaction.- Throws:
java.lang.IllegalStateException
- If the state of the transaction is not "ready", i.e. the transaction has begun, been committed or rolled back. The exception is also thrown if the property container has been disposed of.
commit
public void commit()
Commits the work done in the property container.- Throws:
java.lang.IllegalStateException
- If the transaction state is not in "begin" state.
rollback
public IFocusComp rollback() throws PropException
Rolls back the work done in the transaction and returns the component who's focus must be restored to.- Returns:
- The component who had its focus changed first during the transaction and needs to receive focus (perhaps when e.g. the session busy state is released), or
null
if no focus change occurred. - Throws:
java.lang.IllegalStateException
- If the transaction state is not in "begin" state.PropException
- If the rollback operation failed.