From db05637e064bca4248f18a5a63662936b85e718b Mon Sep 17 00:00:00 2001 From: Greg Turnquist Date: Thu, 20 Jun 2013 14:32:49 -0400 Subject: [PATCH] Add MultipartAutoConfigure to spring.factories Update META-INF/spring.factories to include MultipartAutoConfigure. Also tweaked the class @Conditionals and Javadoc. Issue: BS-157 --- .../web/MultipartAutoConfiguration.java | 13 +++++++++---- .../src/main/resources/META-INF/spring.factories | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/spring-bootstrap/src/main/java/org/springframework/bootstrap/autoconfigure/web/MultipartAutoConfiguration.java b/spring-bootstrap/src/main/java/org/springframework/bootstrap/autoconfigure/web/MultipartAutoConfiguration.java index b8b14ee2a2..4bdab4dc57 100644 --- a/spring-bootstrap/src/main/java/org/springframework/bootstrap/autoconfigure/web/MultipartAutoConfiguration.java +++ b/spring-bootstrap/src/main/java/org/springframework/bootstrap/autoconfigure/web/MultipartAutoConfiguration.java @@ -17,25 +17,30 @@ package org.springframework.bootstrap.autoconfigure.web; import javax.servlet.MultipartConfigElement; +import javax.servlet.Servlet; import org.springframework.bootstrap.context.annotation.ConditionalOnBean; +import org.springframework.bootstrap.context.annotation.ConditionalOnClass; import org.springframework.bootstrap.context.annotation.EnableAutoConfiguration; +import org.springframework.bootstrap.context.embedded.EmbeddedWebApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.multipart.support.StandardServletMultipartResolver; /** - * {@link EnableAutoConfiguration Auto-configuration} for multi-part uploads. It detects - * the existence of a {@link MultipartConfigElement} in the app context and then adds - * critical beans while also autowiring it into the Jetty/Tomcat embedded containers. + * {@link EnableAutoConfiguration Auto-configuration} for multi-part uploads. Adds a + * {@link StandardServletMultipartResolver} when a {@link MultipartConfigElement} bean is + * defined. The {@link EmbeddedWebApplicationContext} will associated the + * {@link MultipartConfigElement} bean to any {@link Servlet} beans. * * @author Greg Turnquist */ @Configuration +@ConditionalOnClass({ Servlet.class, StandardServletMultipartResolver.class }) +@ConditionalOnBean(MultipartConfigElement.class) public class MultipartAutoConfiguration { @Bean - @ConditionalOnBean(MultipartConfigElement.class) public StandardServletMultipartResolver multipartResolver() { return new StandardServletMultipartResolver(); } diff --git a/spring-bootstrap/src/main/resources/META-INF/spring.factories b/spring-bootstrap/src/main/resources/META-INF/spring.factories index 4381606018..7836cb266b 100644 --- a/spring-bootstrap/src/main/resources/META-INF/spring.factories +++ b/spring-bootstrap/src/main/resources/META-INF/spring.factories @@ -10,6 +10,7 @@ org.springframework.bootstrap.autoconfigure.orm.jpa.HibernateJpaAutoConfiguratio org.springframework.bootstrap.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\ org.springframework.bootstrap.autoconfigure.web.EmbeddedServletContainerAutoConfiguration,\ org.springframework.bootstrap.autoconfigure.web.ServerPropertiesAutoConfiguration,\ +org.springframework.bootstrap.autoconfigure.web.MultipartAutoConfiguration,\ org.springframework.bootstrap.autoconfigure.web.WebMvcAutoConfiguration # Application Context Initializers