@Repository @Transactional public class DefaultLockRepository extends java.lang.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 java.lang.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(javax.sql.DataSource dataSource)
Constructor that initializes the client id that will be associated for
all the locks persisted by the store instance to a random
UUID. |
DefaultLockRepository(javax.sql.DataSource dataSource,
java.lang.String id)
Constructor that allows the user to specify a client id that will
be associated for all the locks persisted by the store instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
acquire(java.lang.String lock) |
void |
afterPropertiesSet() |
void |
close() |
void |
delete(java.lang.String lock) |
boolean |
isAcquired(java.lang.String lock) |
void |
setPrefix(java.lang.String prefix)
Specify the prefix for target data base table used from queries.
|
void |
setRegion(java.lang.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 java.lang.String DEFAULT_TABLE_PREFIX
public static final int DEFAULT_TTL
@Autowired public DefaultLockRepository(javax.sql.DataSource dataSource)
UUID.dataSource - the DataSource used to maintain the lock repository.public DefaultLockRepository(javax.sql.DataSource dataSource,
java.lang.String id)
dataSource - the DataSource used to maintain the lock repository.id - the client id to be associated with locks handled by the repository.public void setRegion(java.lang.String region)
DEFAULT.region - the region name to setpublic void setPrefix(java.lang.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 java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface LockRepositorypublic void delete(java.lang.String lock)
delete in interface LockRepository@Transactional(isolation=SERIALIZABLE,
timeout=1)
public boolean acquire(java.lang.String lock)
acquire in interface LockRepositorypublic boolean isAcquired(java.lang.String lock)
isAcquired in interface LockRepository