Class JdbcMetadataStore
java.lang.Object
org.springframework.integration.jdbc.metadata.JdbcMetadataStore
- All Implemented Interfaces:
- InitializingBean,- Lifecycle,- Phased,- SmartLifecycle,- ConcurrentMetadataStore,- MetadataStore
public class JdbcMetadataStore
extends Object
implements ConcurrentMetadataStore, InitializingBean, SmartLifecycle
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.
 
 This class implements SmartLifecycle and calls
 SELECT COUNT(METADATA_KEY) FROM %sMETADATA_STORE query
 according to the provided prefix on start() to check if required table is present in DB.
 The application context will fail to start if the table is not present.
 This check can be disabled via setCheckDatabaseOnStart(boolean).
- Since:
- 5.0
- Author:
- Bojan Vukasovic, Artem Bilan, Gary Russell
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringDefault value for the table prefix property.Fields inherited from interface org.springframework.context.SmartLifecycleDEFAULT_PHASE
- 
Constructor SummaryConstructorsConstructorDescriptionJdbcMetadataStore(DataSource dataSource) Instantiate aJdbcMetadataStoreusing provided dataSourceDataSource.JdbcMetadataStore(JdbcOperations jdbcOperations) Instantiate aJdbcMetadataStoreusing provided jdbcOperationsJdbcOperations.
- 
Method SummaryModifier and TypeMethodDescriptionvoidReads a value for the given key from this MetadataStore.booleanbooleanvoidWrites a key value pair to this MetadataStore.putIfAbsent(String key, String value) Atomically insert the key into the store.Remove a value for the given key from this MetadataStore.booleanAtomically replace the value for the key in the store if the old value matches the oldValue argument.voidsetCheckDatabaseOnStart(boolean checkDatabaseOnStart) The flag to perform a database check query on start or not.voidsetLockHint(String lockHint) Specify a row lock hint for the query in the lock-based operations.voidA unique grouping identifier for all messages persisted with this store.voidsetTablePrefix(String tablePrefix) Public setter for the table prefix property.voidstart()voidstop()Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.SmartLifecyclegetPhase, stop
- 
Field Details- 
DEFAULT_TABLE_PREFIXDefault value for the table prefix property.- See Also:
 
 
- 
- 
Constructor Details- 
JdbcMetadataStoreInstantiate aJdbcMetadataStoreusing provided dataSourceDataSource.- Parameters:
- dataSource- a- DataSource
 
- 
JdbcMetadataStoreInstantiate aJdbcMetadataStoreusing provided jdbcOperationsJdbcOperations.- Parameters:
- jdbcOperations- a- JdbcOperations
 
 
- 
- 
Method Details- 
setTablePrefixPublic 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
 
- 
setRegionA 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
 
- 
setLockHintSpecify 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 on the RDBMS vendor, e.g. SQL Server requiresWITH (ROWLOCK).- Parameters:
- lockHint- the RDBMS vendor-specific lock hint.
- Since:
- 5.0.7
 
- 
afterPropertiesSetpublic void afterPropertiesSet()- Specified by:
- afterPropertiesSetin interface- InitializingBean
 
- 
setCheckDatabaseOnStartpublic void setCheckDatabaseOnStart(boolean checkDatabaseOnStart) The flag to perform a database check query on start or not.- Parameters:
- checkDatabaseOnStart- false to not perform the database check.
- Since:
- 6.2
 
- 
isAutoStartuppublic boolean isAutoStartup()- Specified by:
- isAutoStartupin interface- SmartLifecycle
 
- 
startpublic void start()
- 
stoppublic void stop()
- 
isRunningpublic boolean isRunning()
- 
putIfAbsentDescription copied from interface:ConcurrentMetadataStoreAtomically insert the key into the store.- Specified by:
- putIfAbsentin interface- ConcurrentMetadataStore
- Parameters:
- key- The key.
- value- The value.
- Returns:
- null if successful, the old value otherwise.
 
- 
replaceDescription copied from interface:ConcurrentMetadataStoreAtomically replace the value for the key in the store if the old value matches the oldValue argument.- Specified by:
- replacein interface- ConcurrentMetadataStore
- Parameters:
- key- The key.
- oldValue- The old value.
- newValue- The new value.
- Returns:
- true if successful.
 
- 
putDescription copied from interface:MetadataStoreWrites a key value pair to this MetadataStore.- Specified by:
- putin interface- MetadataStore
- Parameters:
- key- The key.
- value- The value.
 
- 
getDescription copied from interface:MetadataStoreReads a value for the given key from this MetadataStore.- Specified by:
- getin interface- MetadataStore
- Parameters:
- key- The key.
- Returns:
- The value.
 
- 
removeDescription copied from interface:MetadataStoreRemove a value for the given key from this MetadataStore.- Specified by:
- removein interface- MetadataStore
- Parameters:
- key- The key.
- Returns:
- The previous value associated with key, or null if there was no mapping for key.
 
 
-