Skip to content

Commit

Permalink
Rebased to 1.3.1-SNAPSHOT version
Browse files Browse the repository at this point in the history
  • Loading branch information
zorglube committed Nov 28, 2022
1 parent 60349e4 commit a09a4a0
Show file tree
Hide file tree
Showing 13 changed files with 330 additions and 953 deletions.
47 changes: 0 additions & 47 deletions autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ limitations under the License.
<parent>
<groupId>net.lbruun.springboot</groupId>
<artifactId>preliquibase-spring-boot-parent</artifactId>
<<<<<<< HEAD
<version>1.3.1-SNAPSHOT</version>
</parent>
=======
<version>1.2.3-SNAPSHOT</version>
</parent>
>>>>>>> branch 'handle_closeable_connexion_and_database' of https://github.com/zorglube/Pre-Liquibase.git

<artifactId>preliquibase-spring-boot-autoconfigure</artifactId>
<packaging>jar</packaging>
Expand Down Expand Up @@ -75,48 +70,6 @@ limitations under the License.
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version> <!-- Must be at least 2.22 for Junit 5 -->
<<<<<<< HEAD
=======
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<javaApiLinks>
<property>
<name>api_1.8</name>
<value>https://docs.oracle.com/javase/8/docs/api/</value>
</property>
</javaApiLinks>
<tags>
<tag>
<name>apiNote</name>
<placement>a</placement>
<head>API Note:</head>
</tag>
<tag>
<name>implSpec</name>
<placement>a</placement>
<head>Implementation Requirements:</head>
</tag>
<tag>
<name>implNote</name>
<placement>a</placement>
<head>Implementation Note:</head>
</tag>

<tag><name>param</name></tag>
<tag><name>return</name></tag>
<tag><name>throws</name></tag>
<tag><name>since</name></tag>
<tag><name>version</name></tag>
<tag><name>serialData</name></tag>
<tag><name>see</name></tag>
</tags>
</configuration>
>>>>>>> branch 'handle_closeable_connexion_and_database' of https://github.com/zorglube/Pre-Liquibase.git
</plugin>

<!-- Do deploy current project -->
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@
*/
package net.lbruun.springboot.preliquibase;

import liquibase.change.DatabaseChange;
import liquibase.integration.spring.SpringLiquibase;
import net.lbruun.springboot.preliquibase.PreLiquibaseAutoConfiguration.EnabledCondition;
import net.lbruun.springboot.preliquibase.PreLiquibaseAutoConfiguration.LiquibaseDataSourceCondition;
import java.util.Objects;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.boot.autoconfigure.AbstractDependsOnBeanFactoryPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
Expand All @@ -38,9 +41,10 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.lang.NonNull;

import javax.sql.DataSource;
import java.util.Objects;
import liquibase.change.DatabaseChange;
import liquibase.integration.spring.SpringLiquibase;
import net.lbruun.springboot.preliquibase.PreLiquibaseAutoConfiguration.EnabledCondition;
import net.lbruun.springboot.preliquibase.PreLiquibaseAutoConfiguration.LiquibaseDataSourceCondition;

/**
* Auto-configuration for Pre-Liquibase.
Expand All @@ -56,13 +60,13 @@ public class PreLiquibaseAutoConfiguration {

Logger logger = LoggerFactory.getLogger(PreLiquibaseAutoConfiguration.class);

/**
* Returns provider which will tell which {@code DataSource} to use for
* Pre-Liquibase. This will return a provider which will resolve to the same
* DataSource as used by Liquibase itself, however an application can
* configure its own bean of type {@code PreLiquibaseDataSourceProvider} and
* thereby override which DataSource to use for Pre-Liquibase.
*/
/**
* Returns provider which will tell which {@code DataSource} to use for Pre-Liquibase. This will
* return a provider which will resolve to the same DataSource as used by Liquibase itself,
* however an application can configure its own bean of type
* {@code PreLiquibaseDataSourceProvider} and thereby override which DataSource to use for
* Pre-Liquibase.
*/
@ConditionalOnMissingBean({PreLiquibaseDataSourceProvider.class})
@Bean
public PreLiquibaseDataSourceProvider preLiquibaseDataSourceProvider(
Expand All @@ -89,7 +93,7 @@ public PreLiquibase preLiquibase(
ApplicationContext applicationContext) {
logger.debug("Instantiation of PreLiquibase");

PreLiquibase preLiquibase = new PreLiquibase(
final PreLiquibase preLiquibase = new PreLiquibase(
environment,
dataSourceProvider.getDataSource(),
properties,
Expand All @@ -106,10 +110,9 @@ public PreLiquibase preLiquibase(
* declaring that Pre-Liquibase must execute before Liquibase, we declare
* the opposite: that Liquibase must execute after Pre-Liquibase.
*/
@Configuration()
@Configuration
@ConditionalOnClass(SpringLiquibase.class)
static class LiquibaseOnPreLiquibaseDependencyPostProcessor
extends AbstractDependsOnBeanFactoryPostProcessor {
static class LiquibaseOnPreLiquibaseDependencyPostProcessor extends AbstractDependsOnBeanFactoryPostProcessor {

Logger logger = LoggerFactory.getLogger(LiquibaseOnPreLiquibaseDependencyPostProcessor.class);

Expand All @@ -125,7 +128,6 @@ static class LiquibaseOnPreLiquibaseDependencyPostProcessor
* Liquibase.
*/
static final class LiquibaseDataSourceCondition extends AnyNestedCondition {

LiquibaseDataSourceCondition() {
super(ConfigurationPhase.REGISTER_BEAN);
}
Expand Down Expand Up @@ -197,19 +199,17 @@ public DefaultPreLiquibaseDataSourceProvider(
@NonNull ObjectProvider<DataSource> dataSource,
@NonNull ObjectProvider<DataSource> liquibaseDataSource) {

// Here we re-use Spring Boot's own LiquibaseAutoConfiguration
// so that we figure out which DataSource will (later) be used
// by LiquibaseAutoConfiguration. This ensures that we use the same
// logic for figuring out which DataSource to use.
// Note that SpringLiquibase object below gets instantiated OUTSIDE
// of the IoC container, meaning it is just normal "new" instantiaion.
// This is important as we do not want the SpringLiquibase's
// afterPropertiesSet method to kick in. All we are interested in
// is to figure out which datasource Liquibase would be using.
LiquibaseAutoConfiguration.LiquibaseConfiguration liquibaseConfiguration
= new LiquibaseAutoConfiguration.LiquibaseConfiguration(liquibaseProperties);
SpringLiquibase liquibase = liquibaseConfiguration.liquibase(
dataSource, liquibaseDataSource);
// Here we re-use Spring Boot's own LiquibaseAutoConfiguration
// so that we figure out which DataSource will (later) be used
// by LiquibaseAutoConfiguration. This ensures that we use the same
// logic for figuring out which DataSource to use.
// Note that SpringLiquibase object below gets instantiated OUTSIDE
// of the IoC container, meaning it is just normal "new" instantiaion.
// This is important as we do not want the SpringLiquibase's
// afterPropertiesSet method to kick in. All we are interested in
// is to figure out which datasource Liquibase would be using.
final LiquibaseAutoConfiguration.LiquibaseConfiguration liquibaseConfiguration = new LiquibaseAutoConfiguration.LiquibaseConfiguration(liquibaseProperties);
final SpringLiquibase liquibase = liquibaseConfiguration.liquibase(dataSource, liquibaseDataSource);

// Sanity check
Objects.requireNonNull(liquibase.getDataSource(), "Unexpected: null value for DataSource returned from SpringLiquibase class");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public PreLiquibaseException(String message) {

public PreLiquibaseException(String message, Throwable cause) {
super(message, cause);

}

/**
Expand Down

0 comments on commit a09a4a0

Please sign in to comment.