org.zodiac.autoconfigure.compatibility.CompatibilityVerifierAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.compatibility;
import java.util.List;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.zodiac.commons.constants.SystemPropertiesConstants;
import org.zodiac.core.compatibility.CompatibilityVerifier;
import org.zodiac.core.compatibility.CompositeCompatibilityVerifier;
import org.zodiac.core.compatibility.SpringBootVersionVerifier;
import org.zodiac.core.compatibility.SpringVersionVerifier;
@AutoConfigureOrder(0)
@SpringBootConfiguration
@ConditionalOnProperty(value = SystemPropertiesConstants.Zodiac.SPRING_COMPATIBILITY_VERIFIER_ENABLED,
matchIfMissing = true)
@EnableConfigurationProperties(value = {CompatibilityVerifierProperties.class})
public class CompatibilityVerifierAutoConfiguration {
@Bean
@ConditionalOnMissingBean
SpringBootVersionVerifier springBootVersionVerifier(CompatibilityVerifierProperties properties) {
return new SpringBootVersionVerifier(properties.getCompatibleSpringBootVersions());
}
@Bean
@ConditionalOnMissingBean
SpringVersionVerifier springVersionVerifier(CompatibilityVerifierProperties properties) {
return new SpringVersionVerifier(properties.getCompatibleSpringVersions());
}
@Bean
@ConditionalOnMissingBean
CompositeCompatibilityVerifier compositeCompatibilityVerifier(List verifiers) {
CompositeCompatibilityVerifier verifier = new CompositeCompatibilityVerifier(verifiers);
verifier.verifyDependencies();
return verifier;
}
}