|
Side of Software Persistence Library 2.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sos.db.AbstractTransactionPolicy sos.db.DefaultTransactionPolicy
public class DefaultTransactionPolicy
A transaction policy that uses a single database lock to ensure that transactions appear to execute sequentially. For any transaction to make progress it must hold the single database lock. An instance of this class should not be shared among databases.
With this policy, there is no chance for deadlock. If the transaction holding the lock never commits or aborts, however, then another transaction would wait forever and no progress would be made. To avoid this starvation, a timeout interval is used. A transaction will wait for a lock the number of milliseconds specified in the constructor.
This policy allows no concurrency in transactions. To allow operations on
different objects to execute concurrently, consider
using DefaultReadWriteTransactionPolicy
instead of this class.
This policy is adequate for applications in which all transactions execute on the same thread or for applications in which there is high transaction contention.
DefaultReadWriteTransactionPolicy
Constructor Summary | |
---|---|
DefaultTransactionPolicy()
Creates an instance of DefaultTransactionPolicy with a default
lock timeout of Long.MAX_VALUE milliseconds. |
|
DefaultTransactionPolicy(long timeout)
Creates an instance of DefaultTransactionPolicy with the specified
lock timeout. |
Method Summary | |
---|---|
protected void |
logLockAcquired(java.lang.String databaseName)
Records that the database lock has been acquired. |
protected void |
logLockReleased(java.lang.String databaseName)
Records that the database lock has been released. |
void |
startTransaction(TransactionSupport support)
Notifies this policy that a top-level transaction is starting for the executing thread. |
Methods inherited from class sos.db.AbstractTransactionPolicy |
---|
getMethodStatus, invoke, logMethodInvocation, prepareForReadOnlyInvocation, prepareForWriteInvocation, registerObject, unregisterObjects |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface sos.db.TransactionPolicy |
---|
invoke, registerObject, unregisterObjects |
Constructor Detail |
---|
public DefaultTransactionPolicy()
DefaultTransactionPolicy
with a default
lock timeout of Long.MAX_VALUE
milliseconds.
DefaultTransactionPolicy(long)
public DefaultTransactionPolicy(long timeout)
DefaultTransactionPolicy
with the specified
lock timeout.
timeout
- maximum time to wait (in milliseconds) for the database lockMethod Detail |
---|
protected void logLockAcquired(java.lang.String databaseName)
This implementation uses the localized message for key "logLockAcquired". The message takes two parameters: the database name and the transaction thread.
databaseName
- name of the databaseprotected void logLockReleased(java.lang.String databaseName)
This implementation uses the localized message for key "logLockReleased". The message takes two parameters: the database name and the transaction thread.
databaseName
- name of the databasepublic void startTransaction(TransactionSupport support) throws java.io.IOException
TransactionPolicy
startTransaction
in interface TransactionPolicy
startTransaction
in class AbstractTransactionPolicy
support
- object to assist in transaction management
java.io.IOException
- if an I/O error occurs
|
Side of Software Persistence Library 2.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |