Package liquibase.integration.spring
Class SpringLiquibase
- java.lang.Object
-
- liquibase.integration.spring.SpringLiquibase
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ResourceLoaderAware
public class SpringLiquibase extends Object implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ResourceLoaderAware
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 loaddb-changelog.xmlfrom the classpath and apply it againstmyDataSource.<bean id="myLiquibase" class="liquibase.spring.SpringLiquibase" > <property name="dataSource" ref="myDataSource" /> <property name="changeLog" value="classpath:db-changelog.xml" /> </bean>
-
-
Field Summary
Fields Modifier and Type Field Description protected StringbeanNameprotected StringchangeLogprotected booleanclearCheckSumsprotected Stringcontextsprotected StringdatabaseChangeLogLockTableprotected StringdatabaseChangeLogTableprotected DataSourcedataSourceprotected StringdefaultSchemaprotected booleandropFirstprotected StringlabelFilterprotected StringliquibaseSchemaprotected StringliquibaseTablespaceprotected Loggerlogprotected Map<String,String>parametersprotected org.springframework.core.io.ResourceLoaderresourceLoaderprotected FilerollbackFileprotected booleanshouldRunprotected UpdateSummaryEnumshowSummaryprotected UpdateSummaryOutputEnumshowSummaryOutputprotected Stringtagprotected booleantestRollbackOnUpdate
-
Constructor Summary
Constructors Constructor Description SpringLiquibase()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidafterPropertiesSet()Executed automatically when the bean is initialized.protected DatabasecreateDatabase(Connection c, ResourceAccessor resourceAccessor)Subclasses may override this method to modify the database settings, such as the default schema, before returning the database object.protected LiquibasecreateLiquibase(Connection c)protected SpringResourceAccessorcreateResourceOpener()Create a new resourceOpener.StringgetBeanName()Gets the Spring-name of this instance.StringgetChangeLog()Returns a Resource that is able to resolve to a file or classpath resource.StringgetContexts()StringgetDatabaseChangeLogLockTable()StringgetDatabaseChangeLogTable()StringgetDatabaseProductName()DataSourcegetDataSource()The DataSource that liquibase will use to perform the migration.StringgetDefaultSchema()StringgetLabelFilter()StringgetLabels()Deprecated.usegetLabelFilter()StringgetLiquibaseSchema()StringgetLiquibaseTablespace()org.springframework.core.io.ResourceLoadergetResourceLoader()StringgetTag()booleanisClearCheckSums()booleanisDropFirst()booleanisIgnoreClasspathPrefix()booleanisTestRollbackOnUpdate()Returns whether a rollback should be tested at update time or not.protected voidperformUpdate(Liquibase liquibase)voidsetBeanName(String name)Spring sets this automatically to the instance's configured bean name.voidsetChangeLog(String dataModel)Sets a Spring Resource that is able to resolve to a file or classpath resource.voidsetChangeLogParameters(Map<String,String> parameters)voidsetClearCheckSums(boolean clearCheckSums)voidsetContexts(String contexts)voidsetDatabaseChangeLogLockTable(String databaseChangeLogLockTable)voidsetDatabaseChangeLogTable(String databaseChangeLogTable)voidsetDataSource(DataSource dataSource)The DataSource that liquibase will use to perform the migration.voidsetDefaultSchema(String defaultSchema)voidsetDropFirst(boolean dropFirst)voidsetIgnoreClasspathPrefix(boolean ignoreClasspathPrefix)Deprecated.Always ignoring classpath prefixvoidsetLabelFilter(String labelFilter)voidsetLabels(String labels)Deprecated.voidsetLiquibaseSchema(String liquibaseSchema)voidsetLiquibaseTablespace(String liquibaseTablespace)voidsetResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)voidsetRollbackFile(File rollbackFile)voidsetShouldRun(boolean shouldRun)voidsetShowSummary(UpdateSummaryEnum showSummary)voidsetShowSummaryOutput(UpdateSummaryOutputEnum showSummaryOutput)voidsetTag(String tag)voidsetTestRollbackOnUpdate(boolean testRollbackOnUpdate)If testRollbackOnUpdate is set to true a rollback will be tested at update time.StringtoString()
-
-
-
Field Detail
-
log
protected final Logger log
-
beanName
protected String beanName
-
resourceLoader
protected org.springframework.core.io.ResourceLoader resourceLoader
-
dataSource
protected DataSource dataSource
-
changeLog
protected String changeLog
-
contexts
protected String contexts
-
labelFilter
protected String labelFilter
-
tag
protected String tag
-
defaultSchema
protected String defaultSchema
-
liquibaseSchema
protected String liquibaseSchema
-
databaseChangeLogTable
protected String databaseChangeLogTable
-
databaseChangeLogLockTable
protected String databaseChangeLogLockTable
-
liquibaseTablespace
protected String liquibaseTablespace
-
dropFirst
protected boolean dropFirst
-
clearCheckSums
protected boolean clearCheckSums
-
shouldRun
protected boolean shouldRun
-
rollbackFile
protected File rollbackFile
-
showSummary
protected UpdateSummaryEnum showSummary
-
showSummaryOutput
protected UpdateSummaryOutputEnum showSummaryOutput
-
testRollbackOnUpdate
protected boolean testRollbackOnUpdate
-
-
Method Detail
-
isDropFirst
public boolean isDropFirst()
-
setDropFirst
public void setDropFirst(boolean dropFirst)
-
isClearCheckSums
public boolean isClearCheckSums()
-
setClearCheckSums
public void setClearCheckSums(boolean clearCheckSums)
-
setShouldRun
public void setShouldRun(boolean shouldRun)
-
getDatabaseProductName
public String getDatabaseProductName() throws DatabaseException
- Throws:
DatabaseException
-
getDataSource
public DataSource getDataSource()
The DataSource that liquibase will use to perform the migration.
-
setDataSource
public void setDataSource(DataSource dataSource)
The DataSource that liquibase will use to perform the migration.
-
getChangeLog
public String getChangeLog()
Returns a Resource that is able to resolve to a file or classpath resource.
-
setChangeLog
public void setChangeLog(String dataModel)
Sets a Spring Resource that is able to resolve to a file or classpath resource. An example might beclasspath:db-changelog.xml.
-
getContexts
public String getContexts()
-
setContexts
public void setContexts(String contexts)
-
getLabels
public String getLabels()
Deprecated.usegetLabelFilter()
-
setLabels
public void setLabels(String labels)
Deprecated.
-
getLabelFilter
public String getLabelFilter()
-
setLabelFilter
public void setLabelFilter(String labelFilter)
-
getTag
public String getTag()
-
setTag
public void setTag(String tag)
-
getDefaultSchema
public String getDefaultSchema()
-
setDefaultSchema
public void setDefaultSchema(String defaultSchema)
-
getLiquibaseTablespace
public String getLiquibaseTablespace()
-
setLiquibaseTablespace
public void setLiquibaseTablespace(String liquibaseTablespace)
-
getLiquibaseSchema
public String getLiquibaseSchema()
-
setLiquibaseSchema
public void setLiquibaseSchema(String liquibaseSchema)
-
getDatabaseChangeLogTable
public String getDatabaseChangeLogTable()
-
setDatabaseChangeLogTable
public void setDatabaseChangeLogTable(String databaseChangeLogTable)
-
getDatabaseChangeLogLockTable
public String getDatabaseChangeLogLockTable()
-
setDatabaseChangeLogLockTable
public void setDatabaseChangeLogLockTable(String databaseChangeLogLockTable)
-
isTestRollbackOnUpdate
public boolean isTestRollbackOnUpdate()
Returns whether a rollback should be tested at update time or not.
-
setTestRollbackOnUpdate
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- Parameters:
testRollbackOnUpdate-
-
afterPropertiesSet
public void afterPropertiesSet() throws LiquibaseExceptionExecuted automatically when the bean is initialized.- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
LiquibaseException
-
performUpdate
protected void performUpdate(Liquibase liquibase) throws LiquibaseException
- Throws:
LiquibaseException
-
createLiquibase
protected Liquibase createLiquibase(Connection c) throws LiquibaseException
- Throws:
LiquibaseException
-
createDatabase
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- the connection to the database- Returns:
- a Database implementation retrieved from the
DatabaseFactory - Throws:
DatabaseException- if there is an error retrieving the database implementation
-
createResourceOpener
protected SpringResourceAccessor createResourceOpener()
Create a new resourceOpener.
-
getBeanName
public String getBeanName()
Gets the Spring-name of this instance.- Returns:
-
setBeanName
public void setBeanName(String name)
Spring sets this automatically to the instance's configured bean name.- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
getResourceLoader
public org.springframework.core.io.ResourceLoader getResourceLoader()
-
setResourceLoader
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
- Specified by:
setResourceLoaderin interfaceorg.springframework.context.ResourceLoaderAware
-
setRollbackFile
public void setRollbackFile(File rollbackFile)
-
setShowSummary
public void setShowSummary(UpdateSummaryEnum showSummary)
-
isIgnoreClasspathPrefix
public boolean isIgnoreClasspathPrefix()
-
setIgnoreClasspathPrefix
public void setIgnoreClasspathPrefix(boolean ignoreClasspathPrefix)
Deprecated.Always ignoring classpath prefix
-
setShowSummaryOutput
public void setShowSummaryOutput(UpdateSummaryOutputEnum showSummaryOutput)
-
-