diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java index 201a88036d..a69bc7077e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java @@ -16,7 +16,6 @@ package org.springframework.boot.autoconfigure.amqp; -import com.rabbitmq.client.Channel; import org.springframework.amqp.core.AmqpAdmin; import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; import org.springframework.amqp.rabbit.connection.ConnectionFactory; @@ -31,70 +30,89 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import com.rabbitmq.client.Channel; + /** - *

{@link EnableAutoConfiguration Auto-configuration} for {@link RabbitTemplate}. - * - *

This configuration class is active only when the RabbitMQ and Spring AMQP client libraries are on the classpath. - * - *

Registers a {@link org.springframework.amqp.rabbit.core.RabbitTemplate RabbitTemplate} instance if there - * is no other bean of the same type in the context. Registers a {@link org.springframework.amqp.rabbit.connection.CachingConnectionFactory CachingConnectionFactory} - * instance if there is no other bean of the same type in the context. - * - *

Registers a {@link org.springframework.amqp.core.AmqpAdmin } instance as long as {@literal spring.rabbitmq.dynamic=true}. - * + * {@link EnableAutoConfiguration Auto-configuration} for {@link RabbitTemplate}. *

- * The {@link org.springframework.amqp.rabbit.connection.CachingConnectionFactory} honors the following properties: - * {@literal spring.rabbitmq.port} is used to specify the port to which the client should connect, and defaults to 5672. - * {@literal spring.rabbitmq.username} is used to specify the (optional) username, and - * {@literal spring.rabbitmq.password} is used to specify the (optional) password. - * {@literal spring.rabbitmq.host} is used to specify the host, and defaults to {@literal localhost}. - * {@literal spring.rabbitmq.virtualHost} is used to specify the (optional) virtual host to which the client should connect. - * + * This configuration class is active only when the RabbitMQ and Spring AMQP client + * libraries are on the classpath. + *

+ * Registers the following beans: + *

+ *

+ * The {@link org.springframework.amqp.rabbit.connection.CachingConnectionFactory} honors + * the following properties: + *

* @author Greg Turnquist * @author Josh Long */ @Configuration -@ConditionalOnClass({RabbitTemplate.class, Channel.class}) +@ConditionalOnClass({ RabbitTemplate.class, Channel.class }) @EnableConfigurationProperties(RabbitProperties.class) public class RabbitAutoConfiguration { - @Bean - @ConditionalOnExpression("${spring.rabbitmq.dynamic:true}") - @ConditionalOnMissingBean(AmqpAdmin.class) - public AmqpAdmin amqpAdmin(CachingConnectionFactory connectionFactory) { - return new RabbitAdmin(connectionFactory); - } + @Bean + @ConditionalOnExpression("${spring.rabbitmq.dynamic:true}") + @ConditionalOnMissingBean(AmqpAdmin.class) + public AmqpAdmin amqpAdmin(CachingConnectionFactory connectionFactory) { + return new RabbitAdmin(connectionFactory); + } - @Autowired - private ConnectionFactory connectionFactory; + @Autowired + private ConnectionFactory connectionFactory; - @Bean - @ConditionalOnMissingBean(RabbitTemplate.class) - public RabbitTemplate rabbitTemplate() { - return new RabbitTemplate(this.connectionFactory); - } + @Bean + @ConditionalOnMissingBean(RabbitTemplate.class) + public RabbitTemplate rabbitTemplate() { + return new RabbitTemplate(this.connectionFactory); + } - @Configuration - @ConditionalOnMissingBean(ConnectionFactory.class) - protected static class RabbitConnectionFactoryCreator { + @Configuration + @ConditionalOnMissingBean(ConnectionFactory.class) + protected static class RabbitConnectionFactoryCreator { - @Bean - public ConnectionFactory rabbitConnectionFactory(RabbitProperties config) { - CachingConnectionFactory factory = new CachingConnectionFactory( - config.getHost()); - factory.setPort(config.getPort()); - if (config.getUsername() != null) { - factory.setUsername(config.getUsername()); - } - if (config.getPassword() != null) { - factory.setPassword(config.getPassword()); - } - if (config.getVirtualHost() != null) { - factory.setVirtualHost(config.getVirtualHost()); - } - return factory; - } + @Bean + public ConnectionFactory rabbitConnectionFactory(RabbitProperties config) { + CachingConnectionFactory factory = new CachingConnectionFactory( + config.getHost()); + factory.setPort(config.getPort()); + if (config.getUsername() != null) { + factory.setUsername(config.getUsername()); + } + if (config.getPassword() != null) { + factory.setPassword(config.getPassword()); + } + if (config.getVirtualHost() != null) { + factory.setVirtualHost(config.getVirtualHost()); + } + return factory; + } - } + } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.java index 1cf302e1fa..68e2f9e5c4 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -24,15 +24,14 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; /** - * - *

* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration * Auto-configuration} for Spring's AOP support. Equivalent to enabling * {@link org.springframework.context.annotation.EnableAspectJAutoProxy} in your - * configuration. The configuration will not be activated if - * {@literal spring.aop.auto=false}. The {@literal proxyTargetClass} attribute will be - * {@literal false}, by default, but can be overridden by specifying - * {@literal spring.aop.proxyTargetClass=true}. + * configuration. + *

+ * The configuration will not be activated if {@literal spring.aop.auto=false}. The + * {@literal proxyTargetClass} attribute will be {@literal false}, by default, but can be + * overridden by specifying {@literal spring.aop.proxyTargetClass=true}. * * @author Dave Syer * @author Josh Long diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/AbstractRepositoryConfigurationSourceSupport.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/AbstractRepositoryConfigurationSourceSupport.java index 30bd8b6490..57b46b5028 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/AbstractRepositoryConfigurationSourceSupport.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/AbstractRepositoryConfigurationSourceSupport.java @@ -53,7 +53,8 @@ public abstract class AbstractRepositoryConfigurationSourceSupport implements private Environment environment; @Override - public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { + public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, + BeanDefinitionRegistry registry) { new RepositoryConfigurationDelegate(getConfigurationSource(), this.resourceLoader) .registerRepositoriesIn(registry, getRepositoryConfigurationExtension()); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/JpaRepositoriesAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/JpaRepositoriesAutoConfiguration.java index 019ce2add5..afb36e117a 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/JpaRepositoriesAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/JpaRepositoriesAutoConfiguration.java @@ -35,16 +35,19 @@ import org.springframework.data.web.config.EnableSpringDataWebSupport; /** * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's JPA Repositories. - * - *

Activates when there is a bean of type {@link javax.sql.DataSource} configured in the context, - * the Spring Data JPA {@link org.springframework.data.jpa.repository.JpaRepository} type is on the classpath, - * and there is no other, existing {@link org.springframework.data.jpa.repository.JpaRepository} configured. - * - *

Once in effect, the auto-configuration is the equivalent of enabling JPA repositories using - * the {@link org.springframework.data.jpa.repository.config.EnableJpaRepositories} annotation. - * - *

This configuration class will activate after the Hibernate auto-configuration. - * + *

+ * Activates when there is a bean of type {@link javax.sql.DataSource} configured in the + * context, the Spring Data JPA + * {@link org.springframework.data.jpa.repository.JpaRepository} type is on the classpath, + * and there is no other, existing + * {@link org.springframework.data.jpa.repository.JpaRepository} configured. + *

+ * Once in effect, the auto-configuration is the equivalent of enabling JPA repositories + * using the {@link org.springframework.data.jpa.repository.config.EnableJpaRepositories} + * annotation. + *

+ * This configuration class will activate after the Hibernate auto-configuration. + * * @author Phillip Webb * @author Josh Long * @see EnableJpaRepositories diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/MongoRepositoriesAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/MongoRepositoriesAutoConfiguration.java index e6bd340e36..dfb43435a3 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/MongoRepositoriesAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/MongoRepositoriesAutoConfiguration.java @@ -30,14 +30,19 @@ import com.mongodb.Mongo; /** * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Mongo * Repositories. - * - *

Activates when there is no bean of type {@link org.springframework.data.mongodb.repository.support.MongoRepositoryFactoryBean} configured in the context, - * the Spring Data Mongo {@link org.springframework.data.mongodb.repository.MongoRepository} type is on the classpath, - * the Mongo client driver API is on the classpath, and there is no other configured {@link org.springframework.data.mongodb.repository.MongoRepository}. - * - *

Once in effect, the auto-configuration is the equivalent of enabling Mongo repositories using - * the {@link org.springframework.data.mongodb.repository.config.EnableMongoRepositories} annotation. - * + *

+ * Activates when there is no bean of type + * {@link org.springframework.data.mongodb.repository.support.MongoRepositoryFactoryBean} + * configured in the context, the Spring Data Mongo + * {@link org.springframework.data.mongodb.repository.MongoRepository} type is on the + * classpath, the Mongo client driver API is on the classpath, and there is no other + * configured {@link org.springframework.data.mongodb.repository.MongoRepository}. + *

+ * Once in effect, the auto-configuration is the equivalent of enabling Mongo repositories + * using the + * {@link org.springframework.data.mongodb.repository.config.EnableMongoRepositories} + * annotation. + * * @author Dave Syer * @author Oliver Gierke * @author Josh Long diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/MongoTemplateAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/MongoTemplateAutoConfiguration.java index 8ef78cb2c0..74a2709354 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/MongoTemplateAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/MongoTemplateAutoConfiguration.java @@ -31,13 +31,15 @@ import org.springframework.data.mongodb.repository.config.EnableMongoRepositorie import com.mongodb.Mongo; /** - * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's {@link MongoTemplate}. - * - *

Registers a {@link org.springframework.data.mongodb.core.MongoTemplate} bean if no other bean of the same type is configured. - * - *

Honors the {@literal spring.data.mongodb.database} property if set, otherwise connects to - * the {@literal test} database. - * + * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's + * {@link MongoTemplate}. + *

+ * Registers a {@link org.springframework.data.mongodb.core.MongoTemplate} bean if no + * other bean of the same type is configured. + *

+ * Honors the {@literal spring.data.mongodb.database} property if set, otherwise connects + * to the {@literal test} database. + * * @author Dave Syer * @author Oliver Gierke * @author Josh Long