org.helidb.txn
Interface TransactionCollaborator<K,V,P>

All Known Implementing Classes:
SharedReadLockReadOnlyTxnCollaborator

public interface TransactionCollaborator<K,V,P>

A transaction collaborator is used by a database that participates in a transaction. It provides a way for the Transaction to communicate with the Database.

The collaborator contains the state of the database that is associated with one specific transaction.

Database clients do not have to care about transaction collaborators.

Since:
1.0
Author:
Karl Gustafsson
See Also:
Transaction, TransactionalDatabase
In_jar:
helidb-core

Method Summary
 void commit()
          Commit this collaborator's work.
 DatabaseBackend<K,V,P> getBackend()
          Get the database's DatabaseBackend object.
 String getReasonForUnableToCommit()
          Can this collaborator commit its changes? If not, why?
 boolean isFinished()
          Has this collaborator finished or rolled back its part of the transaction?
 boolean isReadOnly()
          Does this collaborator's Database participate in the transaction read only?
 void rollback()
          Roll back this collaborator's work.
 

Method Detail

getReasonForUnableToCommit

String getReasonForUnableToCommit()
Can this collaborator commit its changes? If not, why?

Returns:
null if the collaborator is able to commit its changes to its database, or a reason for why it cannot.

commit

void commit()
            throws IllegalStateException
Commit this collaborator's work. This is called for each collaborator participating in a transaction after getReasonForUnableToCommit() has been called on all collaborators.

This method should really not throw any exceptions since that would put the resources participating in the entire transaction in an undefined state. If the collaborator cannot commit the work in the database, it should say so when asked via the getReasonForUnableToCommit().

Throws:
IllegalStateException - If this collaborator's work has already been committed or rolled back.

rollback

void rollback()
Roll back this collaborator's work.

This method should try to avoid throwing exceptions since that may put the resources participating in the entire transaction in an undefined state.


isReadOnly

boolean isReadOnly()
Does this collaborator's Database participate in the transaction read only?

Returns:
true if this collaborator's Database participates in the transaction read only.

isFinished

boolean isFinished()
Has this collaborator finished or rolled back its part of the transaction?

Returns:
true if this collaborator has finished or rolled back its part of the transaction.

getBackend

DatabaseBackend<K,V,P> getBackend()
Get the database's DatabaseBackend object.

Returns:
The database's DatabaseBackend object.