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

nl._42.boot.docker.autoconfig.postgres.DockerPostgresDependencyPostProcessor 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 org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.util.StringUtils;

import java.util.Arrays;

public class DockerPostgresDependencyPostProcessor implements BeanFactoryPostProcessor {

    private final String dependOnBean;

    public DockerPostgresDependencyPostProcessor(final String dependOnBean) {
        this.dependOnBean = dependOnBean;
    }

    @Override
    public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException {
        Arrays.stream(BeanFactoryUtils.beanNamesForTypeIncludingAncestors(beanFactory, SpringLiquibase.class))
                .map(beanFactory::getBeanDefinition)
                .forEach(beanDefinition -> {
                    String[] dependsOn = beanDefinition.getDependsOn();
                    beanDefinition.setDependsOn(StringUtils.addStringToArray(dependsOn, dependOnBean));
                });
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy