Class 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 load db-changelog.xml from the classpath and apply it against myDataSource.

     <bean id="myLiquibase"
          <property name="dataSource" ref="myDataSource" />
          <property name="changeLog" value="classpath:db-changelog.xml" />
    • Field Detail

      • log

        protected final Logger log
      • beanName

        protected String beanName
      • resourceLoader

        protected resourceLoader
      • changeLog

        protected String changeLog
      • contexts

        protected String contexts
      • labelFilter

        protected String labelFilter
      • 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
      • testRollbackOnUpdate

        protected boolean testRollbackOnUpdate
    • Constructor Detail

      • SpringLiquibase

        public SpringLiquibase()
    • 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)
      • 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 be classpath:db-changelog.xml.
      • getContexts

        public String getContexts()
      • setContexts

        public void setContexts​(String contexts)
      • 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
        testRollbackOnUpdate -
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws LiquibaseException
        Executed automatically when the bean is initialized.
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      • 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.
        c - the connection to the database
        a Database implementation retrieved from the DatabaseFactory
        DatabaseException - if there is an error retrieving the database implementation
      • setChangeLogParameters

        public void setChangeLogParameters​(Map<String,​String> parameters)
      • getBeanName

        public String getBeanName()
        Gets the Spring-name of this instance.
      • setBeanName

        public void setBeanName​(String name)
        Spring sets this automatically to the instance's configured bean name.
        Specified by:
        setBeanName in interface org.springframework.beans.factory.BeanNameAware
      • getResourceLoader

        public getResourceLoader()
      • setResourceLoader

        public void setResourceLoader​( resourceLoader)
        Specified by:
        setResourceLoader in interface org.springframework.context.ResourceLoaderAware
      • setRollbackFile

        public void setRollbackFile​(File rollbackFile)
      • isIgnoreClasspathPrefix

        public boolean isIgnoreClasspathPrefix()
      • setIgnoreClasspathPrefix

        public void setIgnoreClasspathPrefix​(boolean ignoreClasspathPrefix)
        Always ignoring classpath prefix
      • setUiService

        public void setUiService​(UIServiceEnum uiService)