Commit 07b88630 authored by Dave Syer's avatar Dave Syer

Be defensive with auto-config of Servlet 3.0 features

There's no explicit support for older Servlet specs in Spring Boot,
but we can at least make it easy for others to provide such
support by not adding stuff to the context when in an older container.
parent 8ff9e677
...@@ -22,6 +22,7 @@ import javax.servlet.Filter; ...@@ -22,6 +22,7 @@ import javax.servlet.Filter;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
import javax.servlet.Servlet; import javax.servlet.Servlet;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -49,7 +50,7 @@ import org.springframework.web.util.UrlPathHelper; ...@@ -49,7 +50,7 @@ import org.springframework.web.util.UrlPathHelper;
*/ */
@Configuration @Configuration
@ConditionalOnBean({ CounterService.class, GaugeService.class }) @ConditionalOnBean({ CounterService.class, GaugeService.class })
@ConditionalOnClass({ Servlet.class }) @ConditionalOnClass({ Servlet.class, ServletRegistration.class })
@AutoConfigureAfter(MetricRepositoryAutoConfiguration.class) @AutoConfigureAfter(MetricRepositoryAutoConfiguration.class)
public class MetricFilterAutoConfiguration { public class MetricFilterAutoConfiguration {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.springframework.boot.actuate.autoconfigure; package org.springframework.boot.actuate.autoconfigure;
import javax.servlet.Servlet; import javax.servlet.Servlet;
import javax.servlet.ServletRegistration;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -36,7 +37,7 @@ import org.springframework.web.servlet.DispatcherServlet; ...@@ -36,7 +37,7 @@ import org.springframework.web.servlet.DispatcherServlet;
* *
* @author Dave Syer * @author Dave Syer
*/ */
@ConditionalOnClass({ Servlet.class, DispatcherServlet.class }) @ConditionalOnClass({ Servlet.class, DispatcherServlet.class, ServletRegistration.class })
@AutoConfigureAfter(TraceRepositoryAutoConfiguration.class) @AutoConfigureAfter(TraceRepositoryAutoConfiguration.class)
public class TraceWebFilterAutoConfiguration { public class TraceWebFilterAutoConfiguration {
......
...@@ -19,6 +19,8 @@ package org.springframework.boot.autoconfigure.web; ...@@ -19,6 +19,8 @@ package org.springframework.boot.autoconfigure.web;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.servlet.ServletRegistration;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
...@@ -61,6 +63,7 @@ public class DispatcherServletAutoConfiguration { ...@@ -61,6 +63,7 @@ public class DispatcherServletAutoConfiguration {
@Configuration @Configuration
@Conditional(DefaultDispatcherServletCondition.class) @Conditional(DefaultDispatcherServletCondition.class)
@ConditionalOnClass(ServletRegistration.class)
protected static class DispatcherServletConfiguration { protected static class DispatcherServletConfiguration {
@Autowired @Autowired
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment