Class JdbcMetadataStore
java.lang.Object
org.springframework.integration.jdbc.metadata.JdbcMetadataStore
- All Implemented Interfaces:
InitializingBean,ConcurrentMetadataStore,MetadataStore
public class JdbcMetadataStore extends Object implements ConcurrentMetadataStore, InitializingBean
Implementation of
ConcurrentMetadataStore using a relational database via JDBC.
SQL scripts to create the necessary tables are packaged as
org/springframework/integration/jdbc/schema-*.sql,
where * is the target database type.
The transaction management is required to use this ConcurrentMetadataStore.
- Since:
- 5.0
- Author:
- Bojan Vukasovic, Artem Bilan, Gary Russell
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_TABLE_PREFIXDefault value for the table prefix property. -
Constructor Summary
Constructors Constructor Description JdbcMetadataStore(DataSource dataSource)Instantiate aJdbcMetadataStoreusing provided dataSourceDataSource.JdbcMetadataStore(JdbcOperations jdbcOperations)Instantiate aJdbcMetadataStoreusing provided jdbcOperationsJdbcOperations. -
Method Summary
Modifier and Type Method Description voidafterPropertiesSet()Stringget(String key)Reads a value for the given key from this MetadataStore.voidput(String key, String value)Writes a key value pair to this MetadataStore.StringputIfAbsent(String key, String value)Atomically insert the key into the store.Stringremove(String key)Remove a value for the given key from this MetadataStore.booleanreplace(String key, String oldValue, String newValue)Atomically replace the value for the key in the store if the old value matches the oldValue argument.voidsetLockHint(String lockHint)Specify a row lock hint for the query in the lock-based operations.voidsetRegion(String region)A unique grouping identifier for all messages persisted with this store.voidsetTablePrefix(String tablePrefix)Public setter for the table prefix property.
-
Field Details
-
DEFAULT_TABLE_PREFIX
Default value for the table prefix property.- See Also:
- Constant Field Values
-
-
Constructor Details
-
JdbcMetadataStore
Instantiate aJdbcMetadataStoreusing provided dataSourceDataSource.- Parameters:
dataSource- aDataSource
-
JdbcMetadataStore
Instantiate aJdbcMetadataStoreusing provided jdbcOperationsJdbcOperations.- Parameters:
jdbcOperations- aJdbcOperations
-
-
Method Details
-
setTablePrefix
Public setter for the table prefix property. This will be prefixed to all the table names before queries are executed. Defaults toDEFAULT_TABLE_PREFIX.- Parameters:
tablePrefix- the tablePrefix to set
-
setRegion
A unique grouping identifier for all messages 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
-
setLockHint
Specify a row lock hint for the query in the lock-based operations. Defaults toFOR UPDATE. Can be specified as an empty string, if the target RDBMS doesn't support locking on tables from queries. The value depends from RDBMS vendor, e.g. SQL Server requiresWITH (ROWLOCK).- Parameters:
lockHint- the RDBMS vendor-specific lock hint.- Since:
- 5.0.7
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceInitializingBean
-
putIfAbsent
Description copied from interface:ConcurrentMetadataStoreAtomically insert the key into the store.- Specified by:
putIfAbsentin interfaceConcurrentMetadataStore- Parameters:
key- The key.value- The value.- Returns:
- null if successful, the old value otherwise.
-
replace
Description copied from interface:ConcurrentMetadataStoreAtomically replace the value for the key in the store if the old value matches the oldValue argument.- Specified by:
replacein interfaceConcurrentMetadataStore- Parameters:
key- The key.oldValue- The old value.newValue- The new value.- Returns:
- true if successful.
-
put
Description copied from interface:MetadataStoreWrites a key value pair to this MetadataStore.- Specified by:
putin interfaceMetadataStore- Parameters:
key- The key.value- The value.
-
get
Description copied from interface:MetadataStoreReads a value for the given key from this MetadataStore.- Specified by:
getin interfaceMetadataStore- Parameters:
key- The key.- Returns:
- The value.
-
remove
Description copied from interface:MetadataStoreRemove a value for the given key from this MetadataStore.- Specified by:
removein interfaceMetadataStore- Parameters:
key- The key.- Returns:
- The previous value associated with key, or null if there was no mapping for key.
-