All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl._42.boot.docker.autoconfig.postgres.DockerPostgresAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.0.3
Show newest version
package nl._42.boot.docker.autoconfig.postgres;

import liquibase.integration.spring.SpringLiquibase;
import nl._42.boot.docker.postgres.DockerPostgresBootSequence;
import nl._42.boot.docker.postgres.DockerPostgresProperties;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@ConditionalOnProperty(prefix = "docker.postgres", name = "enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnClass(value = DockerPostgresBootSequence.class)
@AutoConfigureAfter({LiquibaseAutoConfiguration.class })
@EnableConfigurationProperties(DockerPostgresProperties.class)
public class DockerPostgresAutoConfiguration {

    public static final String DEPEND_ON_BEAN = "dockerPostgresBean";

    @Configuration
    @EnableConfigurationProperties(DockerPostgresProperties.class)
    public static class Docker42Configuration {

        private final DockerPostgresProperties properties;

        public Docker42Configuration(DockerPostgresProperties properties) {
            this.properties = properties;
        }

        @Bean
        @Conditional(OnDockerPostgresCondition.class)
        public DockerPostgresBean dockerPostgresBean() {
            return new DockerPostgresBean(properties);
        }

    }

    @Bean
    @Conditional(OnDockerPostgresCondition.class)
    public DockerPostgresDependencyPostProcessor docker42DatabaseBeanLiquibaseDependencyPostProcessor() {
        return new DockerPostgresDependencyPostProcessor(DEPEND_ON_BEAN);
    }

    static class OnDockerPostgresCondition extends AllNestedConditions {

        OnDockerPostgresCondition() {
            super(ConfigurationPhase.REGISTER_BEAN);
        }

        @ConditionalOnBean(SpringLiquibase.class)
        static class HasSpringLiquibase {}

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy