Package edu.wisc.library.ocfl.core.lock
Class PostgresObjectLock
- java.lang.Object
-
- edu.wisc.library.ocfl.core.lock.PostgresObjectLock
-
- All Implemented Interfaces:
ObjectLock
public class PostgresObjectLock extends Object implements ObjectLock
-
-
Constructor Summary
Constructors Constructor Description PostgresObjectLock(String tableName, DataSource dataSource, long waitTime, TimeUnit timeUnit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddoInWriteLock(String objectId, Runnable doInLock)Executes the code block after securing a write lock on the objectId.<T> TdoInWriteLock(String objectId, Callable<T> doInLock)Executes the code block after securing a write lock on the objectId.
-
-
-
Constructor Detail
-
PostgresObjectLock
public PostgresObjectLock(String tableName, DataSource dataSource, long waitTime, TimeUnit timeUnit)
-
-
Method Detail
-
doInWriteLock
public void doInWriteLock(String objectId, Runnable doInLock)
Executes the code block after securing a write lock on the objectId. The lock is released after the block completes.- Specified by:
doInWriteLockin interfaceObjectLock- Parameters:
objectId- id of the objectdoInLock- block to execute within the lock
-
doInWriteLock
public <T> T doInWriteLock(String objectId, Callable<T> doInLock)
Executes the code block after securing a write lock on the objectId. The lock is released after the block completes.- Specified by:
doInWriteLockin interfaceObjectLock- Type Parameters:
T- return type- Parameters:
objectId- id of the objectdoInLock- block to execute within the lock- Returns:
- object
-
-