Side of Software
Persistence Library 2.0

sos.db
Interface TransactionPolicy

All Known Implementing Classes:
AbstractTransactionPolicy, DefaultReadWriteTransactionPolicy, DefaultTransactionPolicy

public interface TransactionPolicy

A policy that determines the behavior of database transactions. Specifically, a class that implements this interface is in charge of

A requirement of a database is that its transactions must appear to be atomic and sequential. Typically, an implementation of this class will use a locking scheme to prevent two transactions from accessing the same object in a conflicting manner. In order to resolve deadlock, the implementation might use lock timeouts or a waits-for graph.

Since:
1.0
See Also:
AbstractTransactionPolicy, DefaultTransactionPolicy, DefaultReadWriteTransactionPolicy

Method Summary
 java.lang.Object invoke(TransactionSupport support, java.lang.reflect.Method method, java.lang.Object[] args)
          Invokes the specified method on the object referred to by support.
 void registerObject(TransactionSupport support, java.lang.Object object)
          Notifies this policy that there is a new database object.
 void startTransaction(TransactionSupport support)
          Notifies this policy that a top-level transaction is starting for the executing thread.
 void unregisterObjects(Database db, java.util.Set<java.lang.Object> oldKeys)
          Notifies this policy that objects have been removed from the database.
 

Method Detail

invoke

java.lang.Object invoke(TransactionSupport support,
                        java.lang.reflect.Method method,
                        java.lang.Object[] args)
                        throws java.lang.IllegalAccessException,
                               java.lang.reflect.InvocationTargetException,
                               java.io.IOException
Invokes the specified method on the object referred to by support. The database calls this method to invoke a method on a database object.

If the object can potentially be modified by the execution of method, the implementation should fetch the receiver using getObjectForWrite; otherwise, it should use getObjectForRead.

If the object needs to be locked during the execution of method, the implementation can use the object returned by getKey to identify the lock.

If this method throws a DatabaseException, the current transaction will be aborted and rolled back.

Parameters:
support - object to assist in transaction management
method - method to invoke on the object referred to by support
args - arguments to the method
Returns:
the result of the invocation of method
Throws:
java.lang.IllegalAccessException - if method is not accessible
java.lang.reflect.InvocationTargetException - if the invocation of method throws an exception. The exception returned by getCause is the method's exception.
java.io.IOException - if an I/O error occurs
See Also:
TransactionSupport.getKey(), TransactionSupport.getObjectForRead(), TransactionSupport.getObjectForWrite()

registerObject

void registerObject(TransactionSupport support,
                    java.lang.Object object)
                    throws java.io.IOException
Notifies this policy that there is a new database object. The database calls this method when an object is added to the database.

Parameters:
support - object to assist in transaction management
object - the object added to the database
Throws:
java.io.IOException - if an I/O error occurs

startTransaction

void startTransaction(TransactionSupport support)
                      throws java.io.IOException
Notifies this policy that a top-level transaction is starting for the executing thread. The database calls this method when a top-level transaction is starting.

Parameters:
support - object to assist in transaction management
Throws:
java.io.IOException - if an I/O error occurs
Since:
2.0

unregisterObjects

void unregisterObjects(Database db,
                       java.util.Set<java.lang.Object> oldKeys)
Notifies this policy that objects have been removed from the database. The database calls this method when objects are being removed from the database.

Parameters:
db - database for which the objects have been removed
oldKeys - set of objects that identify the objects being removed from the database

Side of Software
Persistence Library 2.0

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