@Repository @Transactional public class DefaultLockRepository extends Object implements LockRepository, org.springframework.beans.factory.InitializingBean
LockRepository based on the
table from the script presented in the org/springframework/integration/jdbc/schema-*.sql.
This repository can't be shared between different JdbcLockRegistry instances.
Otherwise it opens a possibility to break Lock contract,
where JdbcLockRegistry uses non-shared ReentrantLocks
for local synchronizations.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_TABLE_PREFIX
Default value for the table prefix property.
|
static int |
DEFAULT_TTL
Default value for the time-to-live property.
|
| Constructor and Description |
|---|
DefaultLockRepository(DataSource dataSource) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acquire(String lock) |
void |
afterPropertiesSet() |
void |
close() |
void |
delete(String lock) |
boolean |
isAcquired(String lock) |
void |
setPrefix(String prefix)
Specify the prefix for target data base table used from queries.
|
void |
setRegion(String region)
A unique grouping identifier for all locks persisted with this store.
|
void |
setTimeToLive(int timeToLive)
Specify the time (in milliseconds) to expire dead locks.
|
public static final String DEFAULT_TABLE_PREFIX
public static final int DEFAULT_TTL
@Autowired public DefaultLockRepository(DataSource dataSource)
public void setRegion(String region)
DEFAULT.region - the region name to setpublic void setPrefix(String prefix)
prefix - the prefix to set (default INT_).public void setTimeToLive(int timeToLive)
timeToLive - the time to expire dead locks.public void afterPropertiesSet()
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanpublic void close()
close in interface Closeableclose in interface AutoCloseableclose in interface LockRepositorypublic void delete(String lock)
delete in interface LockRepository@Transactional(isolation=SERIALIZABLE,
timeout=1)
public boolean acquire(String lock)
acquire in interface LockRepositorypublic boolean isAcquired(String lock)
isAcquired in interface LockRepository