Ensure only supported listeners are instantiated

Previously all EventListeners were eagerly instantiated
but that can cause problems because it happens quite early
in the lifecycle. Better to be explicit about the
supported types.
This commit is contained in:
Dave Syer
2013-11-27 15:03:58 +00:00
parent aefec4c16a
commit d1dcb015b6
4 changed files with 39 additions and 9 deletions

View File

@@ -47,6 +47,7 @@ import org.springframework.core.io.ResourceLoader;
import org.springframework.format.Formatter;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.accept.ContentNegotiationManager;
import org.springframework.web.context.request.RequestContextListener;
import org.springframework.web.filter.HiddenHttpMethodFilter;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.View;
@@ -134,6 +135,12 @@ public class WebMvcAutoConfiguration {
return resolver;
}
@Bean
@ConditionalOnMissingBean(RequestContextListener.class)
public RequestContextListener requestContextListener() {
return new RequestContextListener();
}
@Bean
@ConditionalOnBean(View.class)
public BeanNameViewResolver beanNameViewResolver() {