|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.quartz.impl.jdbcjobstore.JTANonClusteredSemaphore
public class JTANonClusteredSemaphore
Provides in memory thread/resource locking that is JTA
aware.
It is most appropriate for use when using
Transaction
without clustering.
JobStoreCMT
This Semaphore
implementation is not Quartz cluster safe.
When a lock is obtained/released but there is no active JTA
, then this Transaction
Semaphore
operates
just like
.
SimpleSemaphore
By default, this class looks for the
in JNDI under name "java:TransactionManager". If this is not where your Application Server
registers it, you can modify the JNDI lookup location using the
"transactionManagerJNDIName" property.
TransactionManager
IMPORTANT: 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!
SimpleSemaphore
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_TRANSACTION_MANANGER_LOCATION
|
Constructor Summary | |
---|---|
JTANonClusteredSemaphore()
|
Method Summary | |
---|---|
protected org.slf4j.Logger |
getLog()
|
protected javax.transaction.Transaction |
getTransaction()
Helper method to get the current
from the in JNDI. |
boolean |
isLockOwner(java.sql.Connection conn,
java.lang.String lockName)
Determine whether the calling thread owns a lock on the identified resource. |
boolean |
obtainLock(java.sql.Connection conn,
java.lang.String lockName)
Grants a lock on the identified resource to the calling thread (blocking until it is available). |
void |
releaseLock(java.sql.Connection conn,
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 void |
releaseLock(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. |
boolean |
requiresConnection()
This Semaphore implementation does not use the database. |
void |
setTransactionManagerJNDIName(java.lang.String transactionManagerJNDIName)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_TRANSACTION_MANANGER_LOCATION
Constructor Detail |
---|
public JTANonClusteredSemaphore()
Method Detail |
---|
protected org.slf4j.Logger getLog()
public void setTransactionManagerJNDIName(java.lang.String transactionManagerJNDIName)
public boolean obtainLock(java.sql.Connection conn, java.lang.String lockName) throws LockException
obtainLock
in interface Semaphore
conn
- Database connection used to establish lock. Can be null if
Semaphore.requiresConnection()
returns false.
LockException
protected javax.transaction.Transaction getTransaction() throws LockException
Transaction
from the TransactionManager
in JNDI.
Transaction
, null if
not currently in a transaction.
LockException
public void releaseLock(java.sql.Connection conn, java.lang.String lockName) throws LockException
releaseLock
in interface Semaphore
conn
- Database connection used to establish lock. Can be null if
Semaphore.requiresConnection()
returns false.
LockException
protected void releaseLock(java.lang.String lockName, boolean fromSynchronization) throws LockException
fromSynchronization
- True if this method is being invoked from
Synchronization
notified of the enclosing
transaction having completed.
LockException
- Thrown if there was a problem accessing the JTA
Transaction
. Only relevant if fromSynchronization
is false.public boolean isLockOwner(java.sql.Connection conn, java.lang.String lockName)
isLockOwner
in interface Semaphore
conn
- Database connection used to establish lock. Can be null if
Semaphore.requiresConnection()
returns false.public boolean requiresConnection()
requiresConnection
in interface Semaphore
Semaphore.isLockOwner(Connection, String)
,
Semaphore.obtainLock(Connection, String)
,
Semaphore.releaseLock(Connection, String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |