Class DefaultLockRepository
java.lang.Object
org.springframework.integration.jdbc.lock.DefaultLockRepository
- All Implemented Interfaces:
Closeable
,AutoCloseable
,InitializingBean
,LockRepository
@Repository
public class DefaultLockRepository
extends Object
implements LockRepository, InitializingBean
The default implementation of the
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 ReentrantLock
s
for local synchronizations.
- Since:
- 4.3
- Author:
- Dave Syer, Artem Bilan, Glenn Renfro, Gary Russell, Alexandre Strubel, Ruslan Stelmachenko
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Default value for the table prefix property.static final int
Default value for the time-to-live property. -
Constructor Summary
ConstructorDescriptionDefaultLockRepository
(DataSource dataSource) Constructor that initializes the client id that will be associated for all the locks persisted by the store instance to a randomUUID
.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. -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
void
close()
void
void
boolean
isAcquired
(String lock) boolean
void
Specify the prefix for target data base table used from queries.void
A unique grouping identifier for all locks persisted with this store.void
setTimeToLive
(int timeToLive) Specify the time (in milliseconds) to expire dead locks.
-
Field Details
-
DEFAULT_TABLE_PREFIX
Default value for the table prefix property.- See Also:
-
DEFAULT_TTL
public static final int DEFAULT_TTLDefault value for the time-to-live property.- See Also:
-
-
Constructor Details
-
DefaultLockRepository
Constructor that initializes the client id that will be associated for all the locks persisted by the store instance to a randomUUID
.- Parameters:
dataSource
- theDataSource
used to maintain the lock repository.
-
DefaultLockRepository
Constructor that allows the user to specify a client id that will be associated for all the locks persisted by the store instance.- Parameters:
dataSource
- theDataSource
used to maintain the lock repository.id
- the client id to be associated with locks handled by the repository.- Since:
- 4.3.13
-
-
Method Details
-
setRegion
A unique grouping identifier for all locks persisted with this store. Using multiple regions allows the store to be partitioned (if necessary) for different purposes. Defaults toDEFAULT
.- Parameters:
region
- the region name to set
-
setPrefix
Specify the prefix for target data base table used from queries.- Parameters:
prefix
- the prefix to set (default INT_).
-
setTimeToLive
public void setTimeToLive(int timeToLive) Specify the time (in milliseconds) to expire dead locks.- Parameters:
timeToLive
- the time to expire dead locks.
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceInitializingBean
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceLockRepository
-
delete
- Specified by:
delete
in interfaceLockRepository
-
acquire
@Transactional(propagation=REQUIRES_NEW, isolation=SERIALIZABLE) public boolean acquire(String lock) - Specified by:
acquire
in interfaceLockRepository
-
isAcquired
- Specified by:
isAcquired
in interfaceLockRepository
-
deleteExpired
- Specified by:
deleteExpired
in interfaceLockRepository
-
renew
- Specified by:
renew
in interfaceLockRepository
-