Top Description Fields Constructors Methods
liquibase.integration.spring

public Class SpringLiquibase

extends Object
implements InitializingBean, BeanNameAware, ResourceLoaderAware
Class Inheritance
All Implemented Interfaces
org.springframework.context.ResourceLoaderAware, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean
Imports
liquibase.*, liquibase.configuration.ConfiguredValue, liquibase.database.Database, .DatabaseConnection, .DatabaseFactory, .OfflineConnection, liquibase.database.core.DerbyDatabase, liquibase.database.jvm.JdbcConnection, liquibase.exception.DatabaseException, .LiquibaseException, .UnexpectedLiquibaseException, liquibase.integration.commandline.LiquibaseCommandLineConfiguration, liquibase.logging.Logger, liquibase.resource.ResourceAccessor, liquibase.ui.UIServiceEnum, liquibase.util.StringUtil, org.springframework.beans.factory.BeanNameAware, .InitializingBean, org.springframework.context.ResourceLoaderAware, org.springframework.core.io.ResourceLoader, javax.sql.DataSource, java.io.*, java.nio.file.Files, java.sql.Connection, .SQLException, java.util.Map

A Spring-ified wrapper for Liquibase.

Example Configuration:

This Spring configuration example will cause liquibase to run automatically when the Spring context is initialized. It will load db-changelog.xml from the classpath and apply it against myDataSource.

<bean id="myLiquibase"
         class="liquibase.spring.SpringLiquibase"
         >

     <property name="dataSource" ref="myDataSource" />

     <property name="changeLog" value="classpath:db-changelog.xml" />

</bean>

Author
Rob Schoening

Field Summary

Modifier and TypeField and Description
protected String
protected String
protected boolean
protected String
protected String
protected String
protected DataSource
protected String
protected boolean
protected String
protected String
protected String
protected final Logger
protected Map<String, String>
protected ResourceLoader
protected File
protected boolean
protected UpdateSummaryEnum
protected UpdateSummaryOutputEnum
protected String
protected boolean
protected UIServiceEnum

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Executed automatically when the bean is initialized.

protected Database

Returns:

a Database implementation retrieved from the DatabaseFactory
createDatabase
(Connection
the connection to the database
c
,
ResourceAccessor resourceAccessor)

Subclasses may override this method to modify the database settings, such as the default schema, before returning the database object.

protected Liquibase
protected SpringResourceAccessor
createResourceOpener()

Create a new resourceOpener.

private void
public String
getBeanName()

Gets the Spring-name of this instance.

public String
getChangeLog()

Returns a Resource that is able to resolve to a file or classpath resource.

public String
public String
public String
public String
public DataSource
getDataSource()

The DataSource that liquibase will use to perform the migration.

public String
public String
public String
getLabels()
Deprecated use getLabelFilter()

public String
public String
public ResourceLoader
public String
public UIServiceEnum
public boolean
public boolean
public boolean
public boolean
isTestRollbackOnUpdate()

Returns whether a rollback should be tested at update time or not.

protected void
public void
setBeanName(String
the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the BeanFactoryUtils#originalBeanName(String) method to extract the original bean name (without suffix), if desired.
name
)

Implements org.springframework.beans.factory.BeanNameAware.setBeanName.

Spring sets this automatically to the instance's configured bean name.

public void
setChangeLog(String dataModel)

Sets a Spring Resource that is able to resolve to a file or classpath resource.

public void
public void
setClearCheckSums(boolean clearCheckSums)

public void
setContexts(String contexts)

public void
setDatabaseChangeLogLockTable(String databaseChangeLogLockTable)

public void
setDatabaseChangeLogTable(String databaseChangeLogTable)

public void
setDataSource(DataSource dataSource)

The DataSource that liquibase will use to perform the migration.

public void
setDefaultSchema(String defaultSchema)

public void
setDropFirst(boolean dropFirst)

public void
setIgnoreClasspathPrefix(boolean ignoreClasspathPrefix)
Deprecated Always ignoring classpath prefix

public void
setLabelFilter(String labelFilter)

public void
setLabels(String labels)
Deprecated use setLabelFilter(String)

public void
setLiquibaseSchema(String liquibaseSchema)

public void
setLiquibaseTablespace(String liquibaseTablespace)

public void
setResourceLoader(ResourceLoader
the ResourceLoader object to be used by this object
resourceLoader
)

Implements org.springframework.context.ResourceLoaderAware.setResourceLoader.

Set the ResourceLoader that this object runs in.

This might be a ResourcePatternResolver, which can be checked through instanceof ResourcePatternResolver.

public void
setRollbackFile(File rollbackFile)

public void
setShouldRun(boolean shouldRun)

public void
public void
public void
public void
setTestRollbackOnUpdate(boolean testRollbackOnUpdate)

If testRollbackOnUpdate is set to true a rollback will be tested at update time.

public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

beanNameback to summary
protected String beanName
changeLogback to summary
protected String changeLog
clearCheckSumsback to summary
protected boolean clearCheckSums
contextsback to summary
protected String contexts
databaseChangeLogLockTableback to summary
protected String databaseChangeLogLockTable
databaseChangeLogTableback to summary
protected String databaseChangeLogTable
dataSourceback to summary
protected DataSource dataSource
defaultSchemaback to summary
protected String defaultSchema
dropFirstback to summary
protected boolean dropFirst
labelFilterback to summary
protected String labelFilter
liquibaseSchemaback to summary
protected String liquibaseSchema
liquibaseTablespaceback to summary
protected String liquibaseTablespace
logback to summary
protected final Logger log
parametersback to summary
protected Map<String, String> parameters
resourceLoaderback to summary
protected ResourceLoader resourceLoader
rollbackFileback to summary
protected File rollbackFile
shouldRunback to summary
protected boolean shouldRun
showSummaryback to summary
protected UpdateSummaryEnum showSummary
showSummaryOutputback to summary
protected UpdateSummaryOutputEnum showSummaryOutput
tagback to summary
protected String tag
testRollbackOnUpdateback to summary
protected boolean testRollbackOnUpdate
uiServiceback to summary
protected UIServiceEnum uiService

Constructor Detail

SpringLiquibaseback to summary
public SpringLiquibase()

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet() throws LiquibaseException

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Executed automatically when the bean is initialized.

Annotations
@Override
createDatabaseback to summary
protected Database createDatabase(Connection c, ResourceAccessor resourceAccessor) throws DatabaseException

Subclasses may override this method to modify the database settings, such as the default schema, before returning the database object.

Parameters
c:Connection

the connection to the database

Returns:Database

a Database implementation retrieved from the DatabaseFactory

Exceptions
DatabaseException:
if there is an error retrieving the database implementation
createLiquibaseback to summary
protected Liquibase createLiquibase(Connection c) throws LiquibaseException
Annotations
@SuppressWarnings:squid:S2095
createResourceOpenerback to summary
protected SpringResourceAccessor createResourceOpener()

Create a new resourceOpener.

generateRollbackFileback to summary
private void generateRollbackFile(Liquibase liquibase) throws LiquibaseException
getBeanNameback to summary
public String getBeanName()

Gets the Spring-name of this instance.

getChangeLogback to summary
public String getChangeLog()

Returns a Resource that is able to resolve to a file or classpath resource.

getContextsback to summary
public String getContexts()
getDatabaseChangeLogLockTableback to summary
public String getDatabaseChangeLogLockTable()
getDatabaseChangeLogTableback to summary
public String getDatabaseChangeLogTable()
getDatabaseProductNameback to summary
public String getDatabaseProductName() throws DatabaseException
Annotations
@SuppressWarnings:squid:S2095
getDataSourceback to summary
public DataSource getDataSource()

The DataSource that liquibase will use to perform the migration.

getDefaultSchemaback to summary
public String getDefaultSchema()
getLabelFilterback to summary
public String getLabelFilter()
getLabelsback to summary
public String getLabels()

Deprecated

use getLabelFilter()

getLiquibaseSchemaback to summary
public String getLiquibaseSchema()
getLiquibaseTablespaceback to summary
public String getLiquibaseTablespace()
getResourceLoaderback to summary
public ResourceLoader getResourceLoader()
getTagback to summary
public String getTag()
getUiServiceback to summary
public UIServiceEnum getUiService()
isClearCheckSumsback to summary
public boolean isClearCheckSums()
isDropFirstback to summary
public boolean isDropFirst()
isIgnoreClasspathPrefixback to summary
public boolean isIgnoreClasspathPrefix()
isTestRollbackOnUpdateback to summary
public boolean isTestRollbackOnUpdate()

Returns whether a rollback should be tested at update time or not.

performUpdateback to summary
protected void performUpdate(Liquibase liquibase) throws LiquibaseException
setBeanNameback to summary
public void setBeanName(String name)

Implements org.springframework.beans.factory.BeanNameAware.setBeanName.

Spring sets this automatically to the instance's configured bean name.

Parameters
name:String

Doc from org.springframework.beans.factory.BeanNameAware.setBeanName.

the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the BeanFactoryUtils#originalBeanName(String) method to extract the original bean name (without suffix), if desired.

Annotations
@Override
setChangeLogback to summary
public void setChangeLog(String dataModel)

Sets a Spring Resource that is able to resolve to a file or classpath resource. An example might be classpath:db-changelog.xml.

setChangeLogParametersback to summary
public void setChangeLogParameters(Map<String, String> parameters)
setClearCheckSumsback to summary
public void setClearCheckSums(boolean clearCheckSums)
setContextsback to summary
public void setContexts(String contexts)
setDatabaseChangeLogLockTableback to summary
public void setDatabaseChangeLogLockTable(String databaseChangeLogLockTable)
setDatabaseChangeLogTableback to summary
public void setDatabaseChangeLogTable(String databaseChangeLogTable)
setDataSourceback to summary
public void setDataSource(DataSource dataSource)

The DataSource that liquibase will use to perform the migration.

setDefaultSchemaback to summary
public void setDefaultSchema(String defaultSchema)
setDropFirstback to summary
public void setDropFirst(boolean dropFirst)
setIgnoreClasspathPrefixback to summary
public void setIgnoreClasspathPrefix(boolean ignoreClasspathPrefix)

Deprecated

Always ignoring classpath prefix

setLabelFilterback to summary
public void setLabelFilter(String labelFilter)
setLabelsback to summary
public void setLabels(String labels)

Deprecated

use setLabelFilter(String)

setLiquibaseSchemaback to summary
public void setLiquibaseSchema(String liquibaseSchema)
setLiquibaseTablespaceback to summary
public void setLiquibaseTablespace(String liquibaseTablespace)
setResourceLoaderback to summary
public void setResourceLoader(ResourceLoader resourceLoader)

Implements org.springframework.context.ResourceLoaderAware.setResourceLoader.

Doc from org.springframework.context.ResourceLoaderAware.setResourceLoader.

Set the ResourceLoader that this object runs in.

This might be a ResourcePatternResolver, which can be checked through instanceof ResourcePatternResolver. See also the ResourcePatternUtils.getResourcePatternResolver method.

Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked before ApplicationContextAware's setApplicationContext.

Parameters
resourceLoader:ResourceLoader

the ResourceLoader object to be used by this object

Annotations
@Override
setRollbackFileback to summary
public void setRollbackFile(File rollbackFile)
setShouldRunback to summary
public void setShouldRun(boolean shouldRun)
setShowSummaryback to summary
public void setShowSummary(UpdateSummaryEnum showSummary)
setShowSummaryOutputback to summary
public void setShowSummaryOutput(UpdateSummaryOutputEnum showSummaryOutput)
setTagback to summary
public void setTag(String tag)
setTestRollbackOnUpdateback to summary
public void setTestRollbackOnUpdate(boolean testRollbackOnUpdate)

If testRollbackOnUpdate is set to true a rollback will be tested at update time. For doing so when the update is performed

setUiServiceback to summary
public void setUiService(UIServiceEnum uiService)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override