java.lang.Object
org.apache.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 org.apache.ojb.broker.metadata.IsolationLevels:
public final int IL_READ_UNCOMMITTED = 0;
public final int IL_READ_COMMITTED = 1;
public final int IL_REPEATABLE_READ = 2;
public final int IL_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.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
private org.apache.ojb.broker.util.logging.Logger log
LockManagerDefaultImpl
LockManagerDefaultImpl()
- LockManagerDefaultImpl constructor comment.
readLock
public boolean readLock(org.apache.ojb.odmg.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(org.apache.ojb.odmg.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(org.apache.ojb.odmg.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(org.apache.ojb.odmg.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(org.apache.ojb.odmg.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(org.apache.ojb.odmg.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