Side of Software
Persistence Library 2.0

sos.db
Interface TransactionSupport


public interface TransactionSupport

An auxiliary class that allows a TransactionPolicy to register commit and abort actions and to signal that an object's state has changed.

Since:
1.0
See Also:
TransactionPolicy

Method Summary
 void addAbortAction(java.lang.Runnable action)
          Registers an action to be run when the transaction aborts.
 void addCommitAction(java.lang.Runnable action)
          Registers an action to be run when the top-level transaction commits.
 Database getDatabase()
          Returns the database for which this transaction is occurring.
 java.lang.Object getKey()
          Returns a key that uniquely identifies the object.
 java.lang.Object getObjectForRead()
          Prepares and returns the object for reading.
 java.lang.Object getObjectForWrite()
          Prepares and returns the object for writing.
 java.lang.Object getProxy()
          Returns the database proxy object overseeing the object.
 void notifyChanged(java.lang.Object object, boolean garbagePossible)
          Informs the transaction that the object's state has changed and the object needs to be resaved in the database.
 

Method Detail

addCommitAction

void addCommitAction(java.lang.Runnable action)
Registers an action to be run when the top-level transaction commits.

Parameters:
action - code to be executed when the top-level transaction commits
Throws:
java.lang.NullPointerException - if action is null

addAbortAction

void addAbortAction(java.lang.Runnable action)
Registers an action to be run when the transaction aborts.

Parameters:
action - code to be executed when the transaction aborts
Throws:
java.lang.NullPointerException - if action is null

getDatabase

Database getDatabase()
Returns the database for which this transaction is occurring.

Returns:
the database for which ths transaction is occurring

getKey

java.lang.Object getKey()
Returns a key that uniquely identifies the object. It is safe to invoke hashCode, equals, and toString on the returned key.

Returns:
a non-null object that uniquely identifies the object

getObjectForRead

java.lang.Object getObjectForRead()
                                  throws java.io.IOException
Prepares and returns the object for reading.

Returns:
the object that can be read
Throws:
java.io.IOException - if an I/O error occurs

getObjectForWrite

java.lang.Object getObjectForWrite()
                                   throws java.io.IOException
Prepares and returns the object for writing.

Returns:
the object that can be written to
Throws:
java.io.IOException - if an I/O error occurs

getProxy

java.lang.Object getProxy()
Returns the database proxy object overseeing the object.

Returns:
the object's proxy
Since:
1.2

notifyChanged

void notifyChanged(java.lang.Object object,
                   boolean garbagePossible)
                   throws java.io.IOException
Informs the transaction that the object's state has changed and the object needs to be resaved in the database.

Parameters:
object - the modified object
garbagePossible - true if the object has changed in such a way that previously reachable database object may now be unreachable
Throws:
java.lang.IllegalStateException - if this database is open in read-only mode
java.io.IOException - if an I/O error occurs

Side of Software
Persistence Library 2.0

Copyright 2004-08 Side of Software (SOS). All rights reserved.