@Repository @Transactional public class DefaultLockRepository extends Object implements LockRepository, 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)
Constructor that initializes the client id that will be associated for
all the locks persisted by the store instance to a random
UUID. |
DefaultLockRepository(DataSource dataSource,
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(String lock) |
void |
afterPropertiesSet() |
void |
close() |
void |
delete(String lock) |
void |
deleteExpired() |
boolean |
isAcquired(String lock) |
boolean |
renew(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)
UUID.dataSource - the DataSource used to maintain the lock repository.public DefaultLockRepository(DataSource dataSource, 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(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 InitializingBeanpublic void close()
close in interface Closeableclose in interface AutoCloseableclose in interface LockRepositorypublic void delete(String lock)
delete in interface LockRepository@Transactional(isolation=SERIALIZABLE) public boolean acquire(String lock)
acquire in interface LockRepositorypublic boolean isAcquired(String lock)
isAcquired in interface LockRepositorypublic void deleteExpired()
deleteExpired in interface LockRepositorypublic boolean renew(String lock)
renew in interface LockRepository