|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
org.quartz.impl.jdbcjobstore Class DBSemaphore
java.lang.Object org.quartz.impl.jdbcjobstore.DBSemaphore
- All Implemented Interfaces:
- Constants, Semaphore, StdJDBCConstants, TablePrefixAware
- Direct Known Subclasses:
- StdRowLockSemaphore, UpdateLockRowSemaphore
public abstract class DBSemaphore
- extends Object
- implements Semaphore, Constants, StdJDBCConstants, TablePrefixAware
Base class for database based lock handlers for providing thread/resource locking in order to protect resources from being altered by multiple threads at the same time.
Field Summary |
---|
Constructor Summary | |
---|---|
DBSemaphore(String tablePrefix,
String schedName,
String defaultSQL,
String defaultInsertSQL)
|
Method Summary | |
---|---|
protected abstract void |
executeSQL(Connection conn,
String lockName,
String expandedSQL,
String expandedInsertSQL)
Execute the SQL that will lock the proper database row. |
protected org.slf4j.Logger |
getLog()
|
String |
getSchedName()
|
protected String |
getSchedulerNameLiteral()
|
protected String |
getSQL()
|
protected String |
getTablePrefix()
|
boolean |
isLockOwner(Connection conn,
String lockName)
Determine whether the calling thread owns a lock on the identified resource. |
boolean |
obtainLock(Connection conn,
String lockName)
Grants a lock on the identified resource to the calling thread (blocking until it is available). |
void |
releaseLock(Connection conn,
String lockName)
Release the lock on the identified resource if it is held by the calling thread. |
boolean |
requiresConnection()
This Semaphore implementation does use the database. |
protected void |
setInsertSQL(String insertSql)
|
void |
setSchedName(String schedName)
|
protected void |
setSQL(String sql)
|
void |
setTablePrefix(String tablePrefix)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
DBSemaphore
public DBSemaphore(String tablePrefix, String schedName, String defaultSQL, String defaultInsertSQL)
Method Detail |
---|
getLog
protected org.slf4j.Logger getLog()
executeSQL
protected abstract void executeSQL(Connection conn, String lockName, String expandedSQL, String expandedInsertSQL) throws LockException
- Execute the SQL that will lock the proper database row.
- Throws:
LockException
obtainLock
public boolean obtainLock(Connection conn, String lockName) throws LockException
- Grants a lock on the identified resource to the calling thread (blocking
until it is available).
- Specified by:
obtainLock
in interfaceSemaphore
- Parameters:
conn
- Database connection used to establish lock. Can be null ifSemaphore.requiresConnection()
returns false.- Returns:
- true if the lock was obtained.
- Throws:
LockException
releaseLock
public void releaseLock(Connection conn, String lockName)
- Release the lock on the identified resource if it is held by the calling
thread.
- Specified by:
releaseLock
in interfaceSemaphore
- Parameters:
conn
- Database connection used to establish lock. Can be null ifSemaphore.requiresConnection()
returns false.
isLockOwner
public boolean isLockOwner(Connection conn, String lockName)
- Determine whether the calling thread owns a lock on the identified
resource.
- Specified by:
isLockOwner
in interfaceSemaphore
- Parameters:
conn
- Database connection used to establish lock. Can be null ifSemaphore.requiresConnection()
returns false.
requiresConnection
public boolean requiresConnection()
- This Semaphore implementation does use the database.
- Specified by:
requiresConnection
in interfaceSemaphore
getSQL
protected String getSQL()
setSQL
protected void setSQL(String sql)
setInsertSQL
protected void setInsertSQL(String insertSql)
getSchedulerNameLiteral
protected String getSchedulerNameLiteral()
getSchedName
public String getSchedName()
setSchedName
public void setSchedName(String schedName)
- Specified by:
setSchedName
in interfaceTablePrefixAware
getTablePrefix
protected String getTablePrefix()
setTablePrefix
public void setTablePrefix(String tablePrefix)
- Specified by:
setTablePrefix
in interfaceTablePrefixAware
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 2001-2011, Terracotta, Inc.