ojb.odmg.locking
Class LockManagerDefaultImpl

java.lang.Object
  |
  +--ojb.odmg.locking.LockManagerDefaultImpl
All Implemented Interfaces:
LockManager

public class LockManagerDefaultImpl
extends java.lang.Object
implements LockManager

The OJB default implementation of a Locking mechanism. This Implementation supports 4 transaction isolation levels as specified in the interface ojb.broker.metadata.IsolationLevels: public final int RW_READ_UNCOMMITTED = 0; public final int RW_READ_COMMITTED = 1; public final int RW_REPEATABLE_READ = 2; public final int RW_SERIALIZABLE = 3; Isolationlevels can be adjusted per class. The proper lockhandling is done in the respective LockStrategy implementation. This default implementation provides persistent Locks that are stored in a special database table. To keep the locks in the database and not in memory allows to use them accross multiple distributed ODMG clients. Of course this solution causes a lot of database reads and writes even if no real application data is written to the database. This solution may thus not be suited for all environments. As the LockManager is pluggable its possible to replace the default implementation by user defined implementations. A different solution might be to implement the LockManager as an additional standalone server, that allows to elminate additional db reads and writes.

Author:
thma

Constructor Summary
(package private) LockManagerDefaultImpl()
          LockManagerDefaultImpl constructor comment.
 
Method Summary
 boolean checkRead(TransactionImpl tx, java.lang.Object obj)
          checks if there is a readlock for transaction tx on object obj.
 boolean checkWrite(TransactionImpl tx, java.lang.Object obj)
          checks if there is a writelock for transaction tx on object obj.
 boolean readLock(TransactionImpl tx, java.lang.Object obj)
          aquires a readlock for transaction tx on object obj.
 boolean releaseLock(TransactionImpl tx, java.lang.Object obj)
          releases a lock for transaction tx on object obj.
 boolean upgradeLock(TransactionImpl tx, java.lang.Object obj)
          upgrades readlock for transaction tx on object obj to a writelock.
 boolean writeLock(TransactionImpl tx, java.lang.Object obj)
          aquires a writelock for transaction tx on object obj.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockManagerDefaultImpl

LockManagerDefaultImpl()
LockManagerDefaultImpl constructor comment.

Method Detail

readLock

public boolean readLock(TransactionImpl tx,
                        java.lang.Object obj)
aquires a readlock for transaction tx on object obj. Returns true if successful, else false.

Specified by:
readLock in interface LockManager

writeLock

public boolean writeLock(TransactionImpl tx,
                         java.lang.Object obj)
aquires a writelock for transaction tx on object obj. Returns true if successful, else false.

Specified by:
writeLock in interface LockManager

upgradeLock

public boolean upgradeLock(TransactionImpl tx,
                           java.lang.Object obj)
upgrades readlock for transaction tx on object obj to a writelock. If no readlock existed a writelock is acquired anyway. Returns true if successful, else false.

Specified by:
upgradeLock in interface LockManager

releaseLock

public boolean releaseLock(TransactionImpl tx,
                           java.lang.Object obj)
releases a lock for transaction tx on object obj. Returns true if successful, else false.

Specified by:
releaseLock in interface LockManager

checkRead

public boolean checkRead(TransactionImpl tx,
                         java.lang.Object obj)
checks if there is a readlock for transaction tx on object obj. Returns true if so, else false.

Specified by:
checkRead in interface LockManager

checkWrite

public boolean checkWrite(TransactionImpl tx,
                          java.lang.Object obj)
checks if there is a writelock for transaction tx on object obj. Returns true if so, else false.

Specified by:
checkWrite in interface LockManager


Authors: Thomas Mahler and others. (C) 2000, 2001.
All rights reserved. Published under the Gnu Public License.
http://objectbridge.sourceforge.net
Version: 0.8.375, 2002-04-04