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.xml
from 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 String
beanName
protected String
changeLog
protected boolean
clearCheckSums
protected String
contexts
protected String
databaseChangeLogLockTable
protected String
databaseChangeLogTable
protected DataSource
dataSource
protected String
defaultSchema
protected boolean
dropFirst
protected String
labelFilter
protected String
liquibaseSchema
protected String
liquibaseTablespace
protected Logger
log
protected Map<String,String>
parameters
protected org.springframework.core.io.ResourceLoader
resourceLoader
protected File
rollbackFile
protected boolean
shouldRun
protected UpdateSummaryEnum
showSummary
protected UpdateSummaryOutputEnum
showSummaryOutput
protected String
tag
protected boolean
testRollbackOnUpdate
protected UIServiceEnum
uiService
-
Constructor Summary
Constructors Constructor Description SpringLiquibase()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
afterPropertiesSet()
Executed automatically when the bean is initialized.protected Database
createDatabase(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 Liquibase
createLiquibase(Connection c)
protected SpringResourceAccessor
createResourceOpener()
Create a new resourceOpener.String
getBeanName()
Gets the Spring-name of this instance.String
getChangeLog()
Returns a Resource that is able to resolve to a file or classpath resource.String
getDatabaseProductName()
DataSource
getDataSource()
The DataSource that liquibase will use to perform the migration.String
getLabels()
Deprecated.use#getLabelFilter()
boolean
isTestRollbackOnUpdate()
Returns whether a rollback should be tested at update time or not.protected void
performUpdate(Liquibase liquibase)
void
setBeanName(String name)
Spring sets this automatically to the instance's configured bean name.void
setChangeLog(String dataModel)
Sets a Spring Resource that is able to resolve to a file or classpath resource.void
setChangeLogParameters(Map<String,String> parameters)
void
setDataSource(DataSource dataSource)
The DataSource that liquibase will use to perform the migration.void
setLabels(String labels)
Deprecated.use#setLabelFilter(String)
void
setShowSummaryOutput(UpdateSummaryOutputEnum showSummaryOutput)
void
setTestRollbackOnUpdate(boolean testRollbackOnUpdate)
If testRollbackOnUpdate is set to true a rollback will be tested at update time.void
setUiService(UIServiceEnum uiService)
String
toString()
-
-
-
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
-
uiService
protected UIServiceEnum uiService
-
-
Method Detail
-
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
.
-
getLabels
public String getLabels()
Deprecated.use#getLabelFilter()
-
setLabels
public void setLabels(String labels)
Deprecated.use#setLabelFilter(String)
-
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 LiquibaseException
Executed automatically when the bean is initialized.- Specified by:
afterPropertiesSet
in 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:
setBeanName
in interfaceorg.springframework.beans.factory.BeanNameAware
-
setShowSummaryOutput
public void setShowSummaryOutput(UpdateSummaryOutputEnum showSummaryOutput)
-
setUiService
public void setUiService(UIServiceEnum uiService)
-
-