diff --git a/pom.xml b/pom.xml index 150c6732a6..df6813dbc4 100644 --- a/pom.xml +++ b/pom.xml @@ -219,6 +219,10 @@ maven-exec-plugin 1.2.1 + + maven-war-plugin + 2.3 + diff --git a/spring-bootstrap/src/main/java/org/springframework/bootstrap/properties/ServerProperties.java b/spring-bootstrap/src/main/java/org/springframework/bootstrap/properties/ServerProperties.java index 5efa8fd58e..5a26e7c2f4 100644 --- a/spring-bootstrap/src/main/java/org/springframework/bootstrap/properties/ServerProperties.java +++ b/spring-bootstrap/src/main/java/org/springframework/bootstrap/properties/ServerProperties.java @@ -68,6 +68,10 @@ public class ServerProperties { this.address = address; } + public void setLoader(String value) { + // no op + } + public static class Tomcat { private String accessLogPattern; diff --git a/spring-bootstrap/src/main/java/org/springframework/bootstrap/web/BootstrapServletInitializer.java b/spring-bootstrap/src/main/java/org/springframework/bootstrap/web/BootstrapServletInitializer.java new file mode 100644 index 0000000000..0731385610 --- /dev/null +++ b/spring-bootstrap/src/main/java/org/springframework/bootstrap/web/BootstrapServletInitializer.java @@ -0,0 +1,55 @@ +package org.springframework.bootstrap.web; + +import javax.servlet.Filter; + +import org.springframework.util.ClassUtils; +import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.filter.DelegatingFilterProxy; +import org.springframework.web.servlet.FrameworkServlet; +import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; + +/** + *

+ * A handy opinionated {@link WebApplicationInitializer} for applications that only have + * one Spring servlet, and no more than a single filter (which itself is only enabled when + * Spring Security is detected). If your application is more complicated consider using + * one of the other WebApplicationInitializers. + *

+ * + *

+ * Note that a WebApplicationInitializer is only needed if you are building a war file and + * deploying it. If you prefer to run an embedded container (we do) then you won't need + * this at all. + *

+ * + * @author Dave Syer + * + */ +public abstract class BootstrapServletInitializer extends + AbstractAnnotationConfigDispatcherServletInitializer { + + @Override + protected Class[] getRootConfigClasses() { + return null; + } + + @Override + protected String[] getServletMappings() { + return new String[] { "/" }; + } + + @Override + protected Filter[] getServletFilters() { + if (ClassUtils.isPresent( + "org.springframework.security.config.annotation.web.EnableWebSecurity", + null)) { + DelegatingFilterProxy filter = new DelegatingFilterProxy( + "springSecurityFilterChain"); + filter.setContextAttribute(FrameworkServlet.SERVLET_CONTEXT_PREFIX + + "dispatcher"); + return new Filter[] { filter }; + } + return new Filter[0]; + } + +}