Package org.quartz.impl.jdbcjobstore
Class JTANonClusteredSemaphore
- java.lang.Object
- 
- org.quartz.impl.jdbcjobstore.JTANonClusteredSemaphore
 
- 
- All Implemented Interfaces:
- Semaphore
 
 public class JTANonClusteredSemaphore extends java.lang.Object implements Semaphore Provides in memory thread/resource locking that is JTATransactionJobStoreCMTThis Semaphoreimplementation is not Quartz cluster safe.When a lock is obtained/released but there is no active JTA TransactionSemaphoreoperates just likeSimpleSemaphoreBy default, this class looks for the TransactionManagerIMPORTANT: This Semaphore implementation is currently experimental. It has been tested a limited amount on JBoss 4.0.3SP1. If you do choose to use it, any feedback would be most appreciated! - See Also:
- SimpleSemaphore
 
- 
- 
Field SummaryFields Modifier and Type Field Description static java.lang.StringDEFAULT_TRANSACTION_MANAGER_LOCATION
 - 
Constructor SummaryConstructors Constructor Description JTANonClusteredSemaphore()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.slf4j.LoggergetLog()protected jakarta.transaction.TransactiongetTransaction()Helper method to get the currentTransactionTransactionManagerbooleanisLockOwner(java.sql.Connection conn, java.lang.String lockName)Determine whether the calling thread owns a lock on the identified resource.booleanobtainLock(java.sql.Connection conn, java.lang.String lockName)Grants a lock on the identified resource to the calling thread (blocking until it is available).voidreleaseLock(java.lang.String lockName)Release the lock on the identified resource if it is held by the calling thread, unless currently in a JTA transaction.protected voidreleaseLock(java.lang.String lockName, boolean fromSynchronization)Release the lock on the identified resource if it is held by the calling thread, unless currently in a JTA transaction.booleanrequiresConnection()This Semaphore implementation does not use the database.voidsetTransactionManagerJNDIName(java.lang.String transactionManagerJNDIName)
 
- 
- 
- 
Field Detail- 
DEFAULT_TRANSACTION_MANAGER_LOCATIONpublic static final java.lang.String DEFAULT_TRANSACTION_MANAGER_LOCATION - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getLogprotected org.slf4j.Logger getLog() 
 - 
setTransactionManagerJNDINamepublic void setTransactionManagerJNDIName(java.lang.String transactionManagerJNDIName) 
 - 
obtainLockpublic boolean obtainLock(java.sql.Connection conn, java.lang.String lockName) throws LockExceptionGrants a lock on the identified resource to the calling thread (blocking until it is available).- Specified by:
- obtainLockin interface- Semaphore
- Parameters:
- conn- Database connection used to establish lock. Can be null if- Semaphore.requiresConnection()
- Returns:
- true if the lock was obtained.
- Throws:
- LockException
 
 - 
getTransactionprotected jakarta.transaction.Transaction getTransaction() throws LockExceptionHelper method to get the currentTransactionTransactionManager- Returns:
- The current Transaction
- Throws:
- LockException
 
 - 
releaseLockpublic void releaseLock(java.lang.String lockName) throws LockExceptionRelease the lock on the identified resource if it is held by the calling thread, unless currently in a JTA transaction.- Specified by:
- releaseLockin interface- Semaphore
- Throws:
- LockException
 
 - 
releaseLockprotected void releaseLock(java.lang.String lockName, boolean fromSynchronization) throws LockExceptionRelease the lock on the identified resource if it is held by the calling thread, unless currently in a JTA transaction.- Parameters:
- fromSynchronization- True if this method is being invoked from- Synchronization
- Throws:
- LockException- Thrown if there was a problem accessing the JTA- Transaction. Only relevant if- fromSynchronizationis false.
 
 - 
isLockOwnerpublic boolean isLockOwner(java.sql.Connection conn, java.lang.String lockName)Determine whether the calling thread owns a lock on the identified resource.
 - 
requiresConnectionpublic boolean requiresConnection() This Semaphore implementation does not use the database.- Specified by:
- requiresConnectionin interface- Semaphore
- See Also:
- Semaphore.obtainLock(Connection, String),- Semaphore.releaseLock(String)
 
 
- 
 
-