Semaphore (Quartz Parent POM 2.0.1 API)

Quartz Java



org.quartz.impl.jdbcjobstore Interface Semaphore

All Known Implementing Classes:
DBSemaphore, JTANonClusteredSemaphore, SimpleSemaphore, StdRowLockSemaphore, UpdateLockRowSemaphore

public interface Semaphore

An interface for providing thread/resource locking in order to protect resources from being altered by multiple threads at the same time.

Author:
jhouse

Method Summary
 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()
          Whether this Semaphore implementation requires a database connection for its lock management operations.
 

Method Detail

obtainLock

boolean obtainLock(Connection conn,
                   String lockName)
                   throws LockException
Grants a lock on the identified resource to the calling thread (blocking until it is available).

Parameters:
conn - Database connection used to establish lock. Can be null if requiresConnection() returns false.
Returns:
true if the lock was obtained.
Throws:
LockException

releaseLock

void releaseLock(Connection conn,
                 String lockName)
                 throws LockException
Release the lock on the identified resource if it is held by the calling thread.

Parameters:
conn - Database connection used to establish lock. Can be null if requiresConnection() returns false.
Throws:
LockException

isLockOwner

boolean isLockOwner(Connection conn,
                    String lockName)
                    throws LockException
Determine whether the calling thread owns a lock on the identified resource.

Parameters:
conn - Database connection used to establish lock. Can be null if requiresConnection() returns false.
Throws:
LockException

requiresConnection

boolean requiresConnection()
Whether this Semaphore implementation requires a database connection for its lock management operations.

See Also:
isLockOwner(Connection, String), obtainLock(Connection, String), releaseLock(Connection, String)


Copyright 2001-2011, Terracotta, Inc.