private void executeUpdate(ServletContext servletContext, InitialContext ic) throws NamingException, SQLException, LiquibaseException {
        setDataSource((String) servletValueContainer.getValue(LIQUIBASE_DATASOURCE));
        if (getDataSource() == null) {
            throw new RuntimeException("Cannot run Liquibase, " + LIQUIBASE_DATASOURCE + " is not set");
        }

        setChangeLogFile((String) servletValueContainer.getValue(LIQUIBASE_CHANGELOG));
        if (getChangeLogFile() == null) {
            throw new RuntimeException("Cannot run Liquibase, " + LIQUIBASE_CHANGELOG + " is not set");
        }

        setContexts((String) servletValueContainer.getValue(LIQUIBASE_CONTEXTS));
        setLabels((String) servletValueContainer.getValue(LIQUIBASE_LABELS));
        this.defaultSchema = StringUtil.trimToNull((String) servletValueContainer.getValue(LIQUIBASE_SCHEMA_DEFAULT));

        Connection connection = null;
        Database database = null;
        try {
            DataSource dataSource = (DataSource) ic.lookup(this.dataSourceName);

            connection = dataSource.getConnection();

            Thread currentThread = Thread.currentThread();
            ClassLoader contextClassLoader = currentThread.getContextClassLoader();
            ResourceAccessor threadClFO = new ClassLoaderResourceAccessor(contextClassLoader);

            ResourceAccessor clFO = new ClassLoaderResourceAccessor();
            ResourceAccessor fsFO = new FileSystemResourceAccessor();


            database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
            database.setDefaultSchemaName(getDefaultSchema());
            Liquibase liquibase = new Liquibase(getChangeLogFile(), new CompositeResourceAccessor(clFO, fsFO, threadClFO), database);

            @SuppressWarnings("unchecked")
            Enumeration<String> initParameters = servletContext.getInitParameterNames();
            while (initParameters.hasMoreElements()) {
                String name = initParameters.nextElement().trim();
                if (name.startsWith(LIQUIBASE_PARAMETER + ".")) {
                    liquibase.setChangeLogParameter(name.substring(LIQUIBASE_PARAMETER.length() + 1), servletValueContainer.getValue(name));
                }
            }

            liquibase.update(new Contexts(getContexts()), new LabelExpression(getLabels()));
        }
        finally {
            if (database != null) {
                database.close();
            } else if (connection != null) {
                connection.close();
            }
        }
    }
private void executeUpdate(ServletContext servletContext, InitialContext ic) throws NamingException, SQLException, LiquibaseException {
        setDataSource((String) servletValueContainer.getValue(LIQUIBASE_DATASOURCE));
        if (getDataSource() == null) {
            throw new RuntimeException("Cannot run Liquibase, " + LIQUIBASE_DATASOURCE + " is not set");
        }

        setChangeLogFile((String) servletValueContainer.getValue(LIQUIBASE_CHANGELOG));
        if (getChangeLogFile() == null) {
            throw new RuntimeException("Cannot run Liquibase, " + LIQUIBASE_CHANGELOG + " is not set");
        }

        setContexts((String) servletValueContainer.getValue(LIQUIBASE_CONTEXTS));
        setLabels((String) servletValueContainer.getValue(LIQUIBASE_LABELS));
        this.defaultSchema = StringUtil.trimToNull((String) servletValueContainer.getValue(LIQUIBASE_SCHEMA_DEFAULT));

        Connection connection = null;
        Database database = null;
        try {
            DataSource dataSource = (DataSource) ic.lookup(this.dataSourceName);

            connection = dataSource.getConnection();

            Thread currentThread = Thread.currentThread();
            ClassLoader contextClassLoader = currentThread.getContextClassLoader();
            ResourceAccessor threadClFO = new ClassLoaderResourceAccessor(contextClassLoader);

            ResourceAccessor clFO = new ClassLoaderResourceAccessor();
            ResourceAccessor fsFO = new FileSystemResourceAccessor();


            database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
            database.setDefaultSchemaName(getDefaultSchema());
            Liquibase liquibase = new Liquibase(getChangeLogFile(), new CompositeResourceAccessor(clFO, fsFO, threadClFO), database);

            @SuppressWarnings("unchecked")
            Enumeration<String> initParameters = servletContext.getInitParameterNames();
            while (initParameters.hasMoreElements()) {
                String name = initParameters.nextElement().trim();
                if (name.startsWith(LIQUIBASE_PARAMETER + ".")) {
                    liquibase.setChangeLogParameter(name.substring(LIQUIBASE_PARAMETER.length() + 1), servletValueContainer.getValue(name));
                }
            }

            liquibase.update(new Contexts(getContexts()), new LabelExpression(getLabels()));
        }
        finally {
            if (database != null) {
                database.close();
            } else if (connection != null) {
                connection.close();
            }
        }
    }
private void executeUpdate ( ServletContext servletContext , InitialContext ic ) throws NamingException , SQLException , LiquibaseException { setDataSource ( ( String ) servletValueContainer . getValue ( LIQUIBASE_DATASOURCE ) ) ; if ( getDataSource ( ) == null ) { throw new RuntimeException ( "Cannot run Liquibase, " + LIQUIBASE_DATASOURCE + " is not set" ) ; } setChangeLogFile ( ( String ) servletValueContainer . getValue ( LIQUIBASE_CHANGELOG ) ) ; if ( getChangeLogFile ( ) == null ) { throw new RuntimeException ( "Cannot run Liquibase, " + LIQUIBASE_CHANGELOG + " is not set" ) ; } setContexts ( ( String ) servletValueContainer . getValue ( LIQUIBASE_CONTEXTS ) ) ; setLabels ( ( String ) servletValueContainer . getValue ( LIQUIBASE_LABELS ) ) ; this . defaultSchema = StringUtil . trimToNull ( ( String ) servletValueContainer . getValue ( LIQUIBASE_SCHEMA_DEFAULT ) ) ; Connection connection = null ; Database database = null ; try { DataSource dataSource = ( DataSource ) ic . lookup ( this . dataSourceName ) ; connection = dataSource . getConnection ( ) ; Thread currentThread = Thread . currentThread ( ) ; ClassLoader contextClassLoader = currentThread . getContextClassLoader ( ) ; ResourceAccessor threadClFO = new ClassLoaderResourceAccessor ( contextClassLoader ) ; ResourceAccessor clFO = new ClassLoaderResourceAccessor ( ) ; ResourceAccessor fsFO = new FileSystemResourceAccessor ( ) ; database = DatabaseFactory . getInstance ( ) . findCorrectDatabaseImplementation ( new JdbcConnection ( connection ) ) ; database . setDefaultSchemaName ( getDefaultSchema ( ) ) ; Liquibase liquibase = new Liquibase ( getChangeLogFile ( ) , new CompositeResourceAccessor ( clFO , fsFO , threadClFO ) , database ) ; @ SuppressWarnings ( "unchecked" ) Enumeration < String > initParameters = servletContext . getInitParameterNames ( ) ; while ( initParameters . hasMoreElements ( ) ) { String name = initParameters . nextElement ( ) . trim ( ) ; if ( name . startsWith ( LIQUIBASE_PARAMETER + "." ) ) { liquibase . setChangeLogParameter ( name . substring ( LIQUIBASE_PARAMETER . length ( ) + 1 ) , servletValueContainer . getValue ( name ) ) ; } } liquibase . update ( new Contexts ( getContexts ( ) ) , new LabelExpression ( getLabels ( ) ) ) ; } finally { if ( database != null ) { database . close ( ) ; } else if ( connection != null ) { connection . close ( ) ; } } }
Executes the Liquibase update.
Executes the Liquibase update .