arminw 2005/08/27 05:13:38
Modified: src/java/org/apache/ojb/broker/locking LockManager.java
Added: src/java/org/apache/ojb/broker/locking
CommonsOJBLockManager.java IsolationLevels.java
LockHelper.java LockIsolation.java
LockIsolationManager.java
LockManagerCommonsImpl.java
LockManagerInMemoryImpl.java
LockManagerRemoteImpl.java LockManagerServlet.java
LockRuntimeException.java
Removed: src/java/org/apache/ojb/broker/locking
AbstractLockStrategy.java LockEntry.java
LockManagerDefaultImpl.java LockMap.java
LockMapInMemoryImpl.java LockMapRemoteImpl.java
LockServerServlet.java LockStrategy.java
LockStrategyManager.java ReadCommittedStrategy.java
ReadUncommittedStrategy.java
RepeatableReadStrategy.java
SerializableStrategy.java
Log:
merge 1.0.x branch with 1.x trunk
Revision Changes Path
1.4 +114 -28
db-ojb/src/java/org/apache/ojb/broker/locking/LockManager.java
Index: LockManager.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/locking/LockManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LockManager.java 11 Nov 2004 23:39:01 -0000 1.3
+++ LockManager.java 27 Aug 2005 12:13:37 -0000 1.4
@@ -16,65 +16,151 @@
*/
-
/**
- * This interface declares the functionality of the OJB internal
- * pessimistic Locking mechanism.
+ * This interface declares the functionality of the OJB locking-api for
support of
+ * pessimistic locking.
* <p>
- * A default implementaion [EMAIL PROTECTED] LockManagerDefaultImpl} is
provided.
* OJB allows to provide user defined implementations of this interface.
* To activate a user defined LockManager implementation it must be
configured in
- * the OJB.properties file. Normally the default implementation of this
class fit
- * all requirements.
+ * the OJB.properties file.
* </p>
* <p>
- * Much more important are the pluggable [EMAIL PROTECTED] LockMap}
implementations, these implementations
- * keep the lock keys and the locked objects.
+ * All locks have to be reentrant, this means if you already have a lock for
+ * writing and you try to acquire write access again you will not be blocked
+ * by this first lock.
+ * </p>
+ * <p>
+ * It's optional to support the <em>lockTimeout</em> and
<em>blockTimeout</em> properties.
* </p>
*
- * @see LockManagerDefaultImpl
- * @see LockStrategy
- * @see LockMap
- *
- * @author thma
+ * @see LockManagerInMemoryImpl
+ * @see LockManagerCommonsImpl
* @version $Id$
*/
-public interface LockManager
+public interface LockManager extends IsolationLevels
{
/**
- * Aquires a readlock for lock key on resource object.
- * Returns true if successful, else false.
+ * Default lock timeout value - set to 60000 ms.
+ */
+ public final static long DEFAULT_LOCK_TIMEOUT = 60000;
+
+ /**
+ * Default lock wait time in millisecond - set to 1000 ms;
*/
- public abstract boolean readLock(Object key, Object resourceId, int
isolationLevel);
+ public final static long DEFAULT_BLOCK_TIMEOUT = 1000;
/**
- * Aquires a writelock for lock key on resource object.
+ * The maximal time to wait for acquire a lock.
+ *
+ * @return
+ */
+ public long getBlockTimeout();
+
+ /**
+ * Set the maximal time to wait for acquire a lock in milliseconds.
+ * All so called <em>non-blocking</em> implementation will ignore this
setting.
+ *
+ * @param timeout The time to wait for acquire a lock.
+ */
+ public void setBlockTimeout(long timeout);
+
+ /**
+ * Get the current used lock timeout value in milliseconds.
+ * @return Current used locking timeout value in ms.
+ */
+ public long getLockTimeout();
+
+ /**
+ * Set the lock timeout value in milliseconds. If timeout was set to
<em>-1</em>
+ * the never will never timeout.
+ *
+ * @param timeout The lock timeout in <em>ms</em> of acquired
read/write/upgrade locks.
+ */
+ public void setLockTimeout(long timeout);
+
+ /**
+ * Returns info about the used lock manager implementation and the state
+ * of the lock manager.
+ */
+ public String getLockInfo();
+
+ /**
+ * Acquires a readlock for lock key on resource object.
* Returns true if successful, else false.
+ *
+ * @param key The owner key of the lock.
+ * @param resourceId The resource to lock.
+ * @param isolationLevel The isolation level of the lock.
+ * @return <em>True</em> if the lock was successfully acquired.
*/
- public abstract boolean writeLock(Object key, Object resourceId, int
isolationLevel);
+ public boolean readLock(Object key, Object resourceId, int
isolationLevel);
/**
- * Upgrades readlock for lock key on resource object.
- * If no readlock existed a writelock is acquired anyway.
+ * Acquires a write lock for lock key on resource object.
* Returns true if successful, else false.
+ *
+ * @param key The owner key of the lock.
+ * @param resourceId The resource to lock.
+ * @param isolationLevel The isolation level of the lock.
+ * @return <em>True</em> if the lock was successfully acquired.
+ */
+ public boolean writeLock(Object key, Object resourceId, int
isolationLevel);
+
+ /**
+ * Acquire an upgrade lock.
+ * (Current implementations always acquire a write lock instead).
+ *
+ * @param key The owner key of the lock.
+ * @param resourceId The resource to lock.
+ * @param isolationLevel The isolation level of the lock.
+ * @return <em>True</em> if the lock was successfully acquired.
*/
- public abstract boolean upgradeLock(Object key, Object resourceId, int
isolationLevel);
+ public boolean upgradeLock(Object key, Object resourceId, int
isolationLevel);
/**
* Releases a lock for lock key on resource object.
* Returns true if successful, else false.
+ *
+ * @param key The owner key of the lock.
+ * @param resourceId The resource to release.
+ * @return <em>True</em> if the lock was successfully released.
+ */
+ public boolean releaseLock(Object key, Object resourceId);
+
+ /**
+ * Release all resource locks hold by the specified owner key.
+ *
+ * @param key The owner key to release all associated locks.
+ */
+ public void releaseLocks(Object key);
+
+ /**
+ * Checks if there is a read lock for owner key on resource object.
+ * Returns true if so, else false.
+ *
+ * @param key The owner key of the lock.
+ * @param resourceId The resource to check.
+ * @return <em>True</em> if the lock exists.
*/
- public abstract boolean releaseLock(Object key, Object resourceId, int
isolationLevel);
+ public boolean hasRead(Object key, Object resourceId);
/**
- * Checks if there is a readlock for lock key on resource object.
+ * Checks if there is a write lock for lock key on resource object.
* Returns true if so, else false.
+ *
+ * @param key The owner key of the lock.
+ * @param resourceId The resource to check.
+ * @return <em>True</em> if the lock exists.
*/
- public abstract boolean checkRead(Object key, Object resourceId, int
isolationLevel);
+ public boolean hasWrite(Object key, Object resourceId);
/**
- * Checks if there is a writelock for lock key on resource object.
+ * Checks if there is a upgrade lock for lock key on resource object.
* Returns true if so, else false.
+ *
+ * @param key The owner key of the lock.
+ * @param resourceId The resource to check.
+ * @return <em>True</em> if the lock exists.
*/
- public abstract boolean checkWrite(Object key, Object resourceId, int
isolationLevel);
+ public boolean hasUpgrade(Object key, Object resourceId);
}
1.2 +454 -0
db-ojb/src/java/org/apache/ojb/broker/locking/CommonsOJBLockManager.java
1.2 +153 -0
db-ojb/src/java/org/apache/ojb/broker/locking/IsolationLevels.java
1.2 +141 -0
db-ojb/src/java/org/apache/ojb/broker/locking/LockHelper.java
1.2 +59 -0
db-ojb/src/java/org/apache/ojb/broker/locking/LockIsolation.java
1.2 +239 -0
db-ojb/src/java/org/apache/ojb/broker/locking/LockIsolationManager.java
1.2 +321 -0
db-ojb/src/java/org/apache/ojb/broker/locking/LockManagerCommonsImpl.java
1.2 +784 -0
db-ojb/src/java/org/apache/ojb/broker/locking/LockManagerInMemoryImpl.java
1.2 +467 -0
db-ojb/src/java/org/apache/ojb/broker/locking/LockManagerRemoteImpl.java
1.2 +256 -0
db-ojb/src/java/org/apache/ojb/broker/locking/LockManagerServlet.java
1.2 +46 -0
db-ojb/src/java/org/apache/ojb/broker/locking/LockRuntimeException.java
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]