|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.anthonyeden.lib.db.LockManager
A database-independent lock manager. Applications can aquire a named lock and execute actions on that lock.
When a lock is aquired it is mapped to the current thread. Only that thread can do operations with that lock. The lock is leased for a limited amount of time. If the lock is not released prior to that time then a LeaseMonitorThread will force the release of the lock.
The aquireLock() method can try more than once to aquire a lock for a caller. The number of retries and the delay between retries can be specified for each LockManager.
Field Summary | |
static int |
DEFAULT_LEASE_TIME
The default lease time (30 seconds). |
static int |
DEFAULT_RETRY_DELAY
The default retry delay (5 seconds). |
static int |
DEFAULT_RETRY_LIMIT
The default retry limit (3). |
Constructor Summary | |
LockManager(java.sql.Connection connection)
Construct a new LockManager using the given JDBC connection. |
Method Summary | |
void |
aquireLock(java.lang.String name)
Aquire a named lock. |
int |
getLeaseTime()
Get the lease time. |
int |
getRetryDelay()
Get the retry delay. |
int |
getRetryLimit()
Get the retry limit. |
void |
releaseLock(java.lang.String name)
Release a named lock. |
void |
setLeaseTime(int leaseTime)
Set the lease time. |
void |
setRetryDelay(int retryDelay)
Set the retry delay. |
void |
setRetryLimit(int retryLimit)
Set the retry limit. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_LEASE_TIME
public static final int DEFAULT_RETRY_LIMIT
public static final int DEFAULT_RETRY_DELAY
Constructor Detail |
public LockManager(java.sql.Connection connection) throws java.sql.SQLException
connection
- The JDBC connection
java.sql.SQLException
Method Detail |
public void aquireLock(java.lang.String name) throws LockException
name
- The name of the lock
LockException
- If the lock cannot be aquiredpublic void releaseLock(java.lang.String name) throws LockException
name
- The lock name
LockException
- If the lock release failspublic int getLeaseTime()
public void setLeaseTime(int leaseTime)
leaseTime
- The lease time in millisecondspublic int getRetryLimit()
public void setRetryLimit(int retryLimit)
retryLimit
- The retry limitpublic int getRetryDelay()
public void setRetryDelay(int retryDelay)
retryDelay
- The retry delay in milliseconds
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |