Move conditions from boot to autoconfigure

Issue: #54393078
pull/9/head
Phillip Webb 11 years ago
parent 4c067a89fe
commit c83400d265

@ -18,8 +18,8 @@ package org.springframework.boot.ops.autoconfigure;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.ops.audit.AuditEvent;
import org.springframework.boot.ops.audit.AuditEventRepository;
import org.springframework.boot.ops.audit.InMemoryAuditEventRepository;

@ -23,8 +23,8 @@ import java.util.Properties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.bind.PropertiesConfigurationFactory;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.ops.endpoint.BeansEndpoint;
import org.springframework.boot.ops.endpoint.DumpEndpoint;
import org.springframework.boot.ops.endpoint.Endpoint;

@ -25,10 +25,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.properties.ServerProperties;
import org.springframework.boot.ops.endpoint.Endpoint;

@ -21,9 +21,9 @@ import javax.servlet.Filter;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.HierarchicalBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.condition.ConditionalOnBean;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;

@ -20,8 +20,8 @@ import javax.servlet.Servlet;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.ErrorPage;

@ -18,8 +18,8 @@ package org.springframework.boot.ops.autoconfigure;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.ops.properties.ManagementServerProperties;
import org.springframework.context.annotation.Bean;

@ -30,8 +30,8 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnBean;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.ops.metrics.CounterService;
import org.springframework.boot.ops.metrics.GaugeService;
import org.springframework.context.annotation.Bean;

@ -17,7 +17,7 @@
package org.springframework.boot.ops.autoconfigure;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.ops.metrics.CounterService;
import org.springframework.boot.ops.metrics.DefaultCounterService;
import org.springframework.boot.ops.metrics.DefaultGaugeService;

@ -22,8 +22,8 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.ops.endpoint.Endpoint;
import org.springframework.boot.ops.endpoint.mvc.EndpointHandlerMapping;

@ -17,7 +17,7 @@
package org.springframework.boot.ops.autoconfigure;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.ops.trace.InMemoryTraceRepository;
import org.springframework.boot.ops.trace.TraceRepository;
import org.springframework.context.annotation.Bean;

@ -23,7 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.ops.trace.TraceRepository;
import org.springframework.boot.ops.trace.WebRequestTraceFilter;
import org.springframework.context.annotation.Bean;

@ -22,9 +22,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.context.condition.ConditionalOnBean;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
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.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Conditional;

@ -17,7 +17,7 @@
package org.springframework.boot.autoconfigure;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ -16,7 +16,7 @@
package org.springframework.boot.autoconfigure;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ -20,9 +20,9 @@ import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.ExitCodeGenerator;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnBean;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import java.lang.reflect.Method;
import java.util.ArrayList;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import org.apache.commons.logging.Log;
import org.springframework.core.type.AnnotatedTypeMetadata;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import org.springframework.context.annotation.Condition;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import java.util.ArrayList;
import java.util.List;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import java.util.List;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import java.util.ArrayList;
import java.util.List;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import java.util.ArrayList;
import java.util.List;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
/**
* Some named search strategies for beans in the bean factory hierarchy.

@ -17,8 +17,8 @@
package org.springframework.boot.autoconfigure.data;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.repository.JpaRepository;

@ -29,9 +29,9 @@ import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionLogUtils;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionLogUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Condition;

@ -20,9 +20,9 @@ import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnBean;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

@ -22,7 +22,7 @@ import java.util.Map;
import org.hibernate.ejb.HibernateEntityManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;

@ -29,12 +29,12 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.autoconfigure.AutoConfigurationUtils;
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.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDatabaseConfiguration;
import org.springframework.boot.context.condition.ConditionalOnBean;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnExpression;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.JpaTransactionManager;

@ -17,9 +17,9 @@
package org.springframework.boot.autoconfigure.reactor;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

@ -29,9 +29,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
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.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.DefaultResourceLoader;

@ -29,10 +29,10 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration.EmbeddedServletContainerCustomizerBeanPostProcessorRegistrar;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.condition.SearchStrategy;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.ServletContextInitializer;

@ -20,8 +20,8 @@ import javax.servlet.MultipartConfigElement;
import javax.servlet.Servlet;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnBean;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.web;
import org.springframework.beans.BeansException;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.properties.ServerProperties;

@ -27,9 +27,9 @@ import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnBean;
import org.springframework.boot.context.condition.ConditionalOnClass;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

@ -14,11 +14,11 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.boot.context.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ -14,9 +14,11 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import org.junit.Test;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.OnClassCondition;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ -14,11 +14,11 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import org.junit.Test;
import org.springframework.boot.context.condition.ConditionalOnExpression;
import org.springframework.boot.context.condition.OnExpressionCondition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.OnExpressionCondition;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ -14,12 +14,12 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import org.junit.Test;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.condition.OnMissingBeanCondition;
import org.springframework.boot.context.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.OnMissingBeanCondition;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@ -51,7 +51,7 @@ public class OnMissingClassConditionTests {
}
@Configuration
@ConditionalOnMissingClass("org.springframework.boot.context.condition.OnMissingClassConditionTests")
@ConditionalOnMissingClass("org.springframework.boot.autoconfigure.condition.OnMissingClassConditionTests")
protected static class BasicConfiguration {
@Bean
public String bar() {

@ -14,12 +14,12 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import org.junit.Test;
import org.springframework.boot.context.condition.ConditionalOnNotWebApplication;
import org.springframework.boot.context.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.condition.OnNotWebApplicationCondition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.OnNotWebApplicationCondition;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ -14,11 +14,11 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import org.junit.Test;
import org.springframework.boot.context.condition.ConditionalOnResource;
import org.springframework.boot.context.condition.OnResourceCondition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnResource;
import org.springframework.boot.autoconfigure.condition.OnResourceCondition;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ -14,12 +14,12 @@
* limitations under the License.
*/
package org.springframework.boot.context.condition;
package org.springframework.boot.autoconfigure.condition;
import org.junit.Test;
import org.springframework.boot.context.condition.ConditionalOnNotWebApplication;
import org.springframework.boot.context.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.condition.OnWebApplicationCondition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.OnWebApplicationCondition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mock.web.MockServletContext;

@ -21,8 +21,8 @@ import javax.servlet.Servlet;
import org.junit.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.context.condition.ConditionalOnExpression;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;

@ -1,62 +0,0 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.context.condition;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Conditional;
/**
* {@link Conditional} that only matches when the specified bean classes and/or names are
* not already contained in the {@link BeanFactory}, and throws an exception otherwise.
*
* @author Dave Syer
* @see ConditionalOnMissingBean
*/
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Conditional(AssertMissingBeanCondition.class)
public @interface AssertMissingBean {
/**
* The class type of bean that should be checked. The condition matches when each
* class specified is missing in the {@link ApplicationContext}.
* @return the class types of beans to check
*/
Class<?>[] value() default {};
/**
* The names of beans to check. The condition matches when each bean name specified is
* missing in the {@link ApplicationContext}.
* @return the name of beans to check
*/
String[] name() default {};
/**
* If the application context hierarchy (parent contexts) should be considered.
*/
boolean considerHierarchy() default true;
}

@ -1,51 +0,0 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.context.condition;
import java.util.List;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.context.condition.OnMissingBeanCondition;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* {@link Condition} that checks that specific beans are missing.
*
* @author Dave Syer
* @see AssertMissingBean
*/
class AssertMissingBeanCondition extends OnMissingBeanCondition {
@Override
protected Class<?> annotationClass() {
return AssertMissingBean.class;
}
@Override
protected boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata,
List<String> beanClasses, List<String> beanNames) throws LinkageError {
boolean result = super.matches(context, metadata, beanClasses, beanNames);
if (!result) {
throw new BeanCreationException("Found existing bean for classes="
+ beanClasses + " and names=" + beanNames);
}
return result;
}
}

@ -23,11 +23,8 @@ import java.util.List;
import javax.annotation.PostConstruct;
import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.TestUtils;
import org.springframework.boot.context.condition.AssertMissingBean;
import org.springframework.boot.context.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -90,30 +87,9 @@ public class EnableConfigurationPropertiesTests {
assertEquals("bar", this.context.getBean(TestProperties.class).getName());
}
@Test(expected = BeanCreationException.class)
public void testPropertiesBindingWithDefaultsInBeanMethodReverseOrder() {
this.context.register(TestBeanConfiguration.class, DefaultConfiguration.class);
this.context.refresh();
String[] beanNames = this.context.getBeanNamesForType(TestProperties.class);
assertEquals("Wrong beans: " + Arrays.asList(beanNames), 1, beanNames.length);
assertEquals("bar", this.context.getBean(TestProperties.class).getName());
}
@Test
public void testPropertiesBindingWithDefaultsInBeanMethod() {
this.context.register(DefaultConfiguration.class, TestBeanConfiguration.class);
this.context.refresh();
String[] beanNames = this.context.getBeanNamesForType(TestProperties.class);
assertEquals("Wrong beans: " + Arrays.asList(beanNames), 1, beanNames.length);
assertEquals("bar", this.context.getBean(TestProperties.class).getName());
}
// Maybe we could relax the condition that causes this exception but Spring makes it
// difficult because it is impossible for DefaultConfiguration to override a bean
// definition created with a direct registration (as opposed to a @Bean)
@Test(expected = BeanCreationException.class)
public void testPropertiesBindingWithDefaults() {
this.context.register(TestConfiguration.class, DefaultConfiguration.class);
this.context.register(DefaultConfiguration.class);
this.context.refresh();
String[] beanNames = this.context.getBeanNamesForType(TestProperties.class);
assertEquals("Wrong beans: " + Arrays.asList(beanNames), 1, beanNames.length);
@ -204,20 +180,9 @@ public class EnableConfigurationPropertiesTests {
protected static class TestConfiguration {
}
@Configuration
@EnableConfigurationProperties
protected static class TestBeanConfiguration {
@ConditionalOnMissingBean(TestProperties.class)
@Bean(name = "org.springframework.boot.context.annotation.EnableConfigurationPropertiesTests$TestProperties")
public TestProperties testProperties() {
return new TestProperties();
}
}
@Configuration
protected static class DefaultConfiguration {
@Bean
@AssertMissingBean(TestProperties.class)
public TestProperties testProperties() {
TestProperties test = new TestProperties();
test.setName("bar");

Loading…
Cancel
Save