Replace @ConditionalOnExpression

This commit replaces @ConditionalOnExpression instances that are
checking for a specific value to @ConditionalOnPropertyValue
pull/1226/head
Stephane Nicoll 10 years ago
parent 270809783c
commit 120ad56a5c

@ -20,6 +20,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.Advice;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@ -39,18 +40,19 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy;
*/
@Configuration
@ConditionalOnClass({ EnableAspectJAutoProxy.class, Aspect.class, Advice.class })
@ConditionalOnExpression("${spring.aop.auto:true}")
@ConditionalOnProperty(value = "spring.aop.auto", match = "true", defaultMatch = true)
public class AopAutoConfiguration {
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = false)
@ConditionalOnExpression("!${spring.aop.proxyTargetClass:false}")
@ConditionalOnProperty(value = "spring.aop.proxyTargetClass", match = "false", defaultMatch = true)
public static class JdkDynamicAutoProxyConfiguration {
}
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = true)
@ConditionalOnExpression("${spring.aop.proxyTargetClass:false}")
@ConditionalOnProperty(value = "spring.aop.proxyTargetClass", match = "true", defaultMatch = false)
public static class CglibAutoProxyConfiguration {
}

@ -34,8 +34,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
@ -78,7 +78,7 @@ public class BatchAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@ConditionalOnExpression("${spring.batch.job.enabled:true}")
@ConditionalOnProperty(value = "spring.batch.job.enabled", match = "true", defaultMatch = true)
public JobLauncherCommandLineRunner jobLauncherCommandLineRunner(
JobLauncher jobLauncher, JobExplorer jobExplorer) {
JobLauncherCommandLineRunner runner = new JobLauncherCommandLineRunner(

@ -19,8 +19,8 @@ package org.springframework.boot.autoconfigure.data.elasticsearch;
import org.elasticsearch.client.Client;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
@ -38,7 +38,8 @@ import org.springframework.data.repository.core.support.RepositoryFactoryBeanSup
*/
@Configuration
@ConditionalOnClass({ Client.class, ElasticsearchRepository.class })
@ConditionalOnExpression("${spring.data.elasticsearch.repositories.enabled:true}")
@ConditionalOnProperty(value = "spring.data.elasticsearch.repositories.enabled",
match = "true", defaultMatch = true)
@ConditionalOnMissingBean(RepositoryFactoryBeanSupport.class)
@Import(ElasticsearchRepositoriesAutoConfigureRegistrar.class)
public class ElasticsearchRepositoriesAutoConfiguration {

@ -22,8 +22,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.annotation.Configuration;
@ -57,7 +57,7 @@ import org.springframework.data.web.config.EnableSpringDataWebSupport;
@ConditionalOnBean(DataSource.class)
@ConditionalOnClass(JpaRepository.class)
@ConditionalOnMissingBean(RepositoryFactoryBeanSupport.class)
@ConditionalOnExpression("${spring.data.jpa.repositories.enabled:true}")
@ConditionalOnProperty(value = "spring.data.jpa.repositories.enabled", match = "true", defaultMatch = true)
@Import(JpaRepositoriesAutoConfigureRegistrar.class)
@AutoConfigureAfter(HibernateJpaAutoConfiguration.class)
public class JpaRepositoriesAutoConfiguration {

@ -19,8 +19,8 @@ package org.springframework.boot.autoconfigure.data.mongo;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -54,7 +54,7 @@ import com.mongodb.Mongo;
@Configuration
@ConditionalOnClass({ Mongo.class, MongoRepository.class })
@ConditionalOnMissingBean(RepositoryFactoryBeanSupport.class)
@ConditionalOnExpression("${spring.data.mongo.repositories.enabled:true}")
@ConditionalOnProperty(value = "spring.data.mongo.repositories.enabled", match="true", defaultMatch = true)
@Import(MongoRepositoriesAutoConfigureRegistrar.class)
@AutoConfigureAfter(MongoAutoConfiguration.class)
public class MongoRepositoriesAutoConfiguration {

@ -18,8 +18,8 @@ package org.springframework.boot.autoconfigure.data.solr;
import org.apache.solr.client.solrj.SolrServer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport;
@ -44,7 +44,7 @@ import org.springframework.data.solr.repository.SolrRepository;
@Configuration
@ConditionalOnClass({ SolrServer.class, SolrRepository.class })
@ConditionalOnMissingBean(RepositoryFactoryBeanSupport.class)
@ConditionalOnExpression("${spring.data.solr.repositories.enabled:true}")
@ConditionalOnProperty(value= "spring.data.solr.repositories.enabled", match="true", defaultMatch = true)
@Import(SolrRepositoriesAutoConfigureRegistrar.class)
public class SolrRepositoriesAutoConfiguration {

@ -20,8 +20,8 @@ import javax.management.MBeanServer;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
import org.springframework.context.annotation.Bean;
@ -51,7 +51,7 @@ public class IntegrationAutoConfiguration {
@Configuration
@ConditionalOnClass(EnableIntegrationMBeanExport.class)
@ConditionalOnMissingBean(value = IntegrationMBeanExporter.class, search = SearchStrategy.CURRENT)
@ConditionalOnExpression("${spring.jmx.enabled:true}")
@ConditionalOnProperty(value = "spring.jmx.enabled", match = "true", defaultMatch = true)
@EnableIntegrationMBeanExport(defaultDomain = "${spring.jmx.default_domain:}", server = "${spring.jmx.server:mbeanServer}")
protected static class IntegrationJmxConfiguration {
}

@ -24,8 +24,8 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -53,7 +53,7 @@ import org.springframework.util.ClassUtils;
*/
@Configuration
@ConditionalOnClass({ MBeanExporter.class })
@ConditionalOnExpression("${spring.jmx.enabled:true}")
@ConditionalOnProperty(value = "spring.jmx.enabled", match = "true", defaultMatch = true)
public class JmxAutoConfiguration {
@Autowired

@ -23,13 +23,12 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
@ -84,7 +83,8 @@ public class DeviceDelegatingViewResolverAutoConfiguration {
@Configuration
@EnableConfigurationProperties(DeviceDelegatingViewResolverProperties.class)
@ConditionalOnMissingBean(name = "deviceDelegatingViewResolver")
@ConditionalOnExpression("${spring.mobile.devicedelegatingviewresolver.enabled:false}")
@ConditionalOnProperty(value = "spring.mobile.devicedelegatingviewresolver.enabled",
match = "true", defaultMatch = false)
protected static class DeviceDelegatingViewResolverConfiguration {
@Configuration

@ -22,8 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -47,7 +47,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@ConditionalOnClass({ SitePreferenceHandlerInterceptor.class,
SitePreferenceHandlerMethodArgumentResolver.class })
@AutoConfigureAfter(DeviceResolverAutoConfiguration.class)
@ConditionalOnExpression("${spring.mobile.sitepreference.enabled:true}")
@ConditionalOnProperty(value ="spring.mobile.sitepreference.enabled", match = "true", defaultMatch = true)
public class SitePreferenceAutoConfiguration {
@Configuration

@ -28,8 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
@ -136,7 +136,7 @@ public abstract class JpaBaseConfiguration implements BeanFactoryAware {
@ConditionalOnWebApplication
@ConditionalOnMissingBean({ OpenEntityManagerInViewInterceptor.class,
OpenEntityManagerInViewFilter.class })
@ConditionalOnExpression("${spring.jpa.openInView:${spring.jpa.open_in_view:true}}")
@ConditionalOnProperty(prefix = "spring.jpa", value = "openInView", match = "true", defaultMatch = true)
protected static class JpaWebConfiguration extends WebMvcConfigurerAdapter {
@Override

Loading…
Cancel
Save