From e0ed2a6dc6996ee601a7db4c0372ff93a3d5e2c0 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 25 Feb 2014 21:29:44 -0500 Subject: [PATCH] Replace web.xml with Java configuration in booking-mvc --- booking-mvc/pom.xml | 4 +- .../config/DispatcherServletInitializer.java | 35 +++++++++++ .../SecurityWebApplicationInitializer.java | 10 ++++ booking-mvc/src/main/webapp/WEB-INF/web.xml | 60 ------------------- 4 files changed, 47 insertions(+), 62 deletions(-) create mode 100644 booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DispatcherServletInitializer.java create mode 100644 booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityWebApplicationInitializer.java delete mode 100755 booking-mvc/src/main/webapp/WEB-INF/web.xml diff --git a/booking-mvc/pom.xml b/booking-mvc/pom.xml index c9f9448..e899a48 100644 --- a/booking-mvc/pom.xml +++ b/booking-mvc/pom.xml @@ -178,8 +178,8 @@ javax.servlet - servlet-api - 2.5 + javax.servlet-api + 3.0.1 provided diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DispatcherServletInitializer.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DispatcherServletInitializer.java new file mode 100644 index 0000000..c86c1e0 --- /dev/null +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DispatcherServletInitializer.java @@ -0,0 +1,35 @@ +package org.springframework.webflow.samples.booking.config; + +import javax.servlet.Filter; + +import org.springframework.web.filter.HiddenHttpMethodFilter; +import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; + +public class DispatcherServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { + + @Override + protected Class[] getRootConfigClasses() { + return new Class[] { + SecurityConfig.class, + DataAccessConfig.class, + WebMvcConfig.class, + WebFlowConfig.class + }; + } + + @Override + protected Class[] getServletConfigClasses() { + return null; + } + + @Override + protected String[] getServletMappings() { + return new String[] { "/" }; + } + + @Override + protected Filter[] getServletFilters() { + return new Filter[] { new HiddenHttpMethodFilter() }; + } + +} diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityWebApplicationInitializer.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityWebApplicationInitializer.java new file mode 100644 index 0000000..df49deb --- /dev/null +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityWebApplicationInitializer.java @@ -0,0 +1,10 @@ +package org.springframework.webflow.samples.booking.config; + +import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; + +/** + * ServletContext initializer for Spring Security specific configuration such as + * the chain of Spring Security filters. + */ +public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer { +} diff --git a/booking-mvc/src/main/webapp/WEB-INF/web.xml b/booking-mvc/src/main/webapp/WEB-INF/web.xml deleted file mode 100755 index 0371362..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - contextClass - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - contextConfigLocation - org.springframework.webflow.samples.booking.config - - - - org.springframework.web.context.ContextLoaderListener - - - - - httpMethodFilter - org.springframework.web.filter.HiddenHttpMethodFilter - - - - httpMethodFilter - Spring MVC Dispatcher Servlet - - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - - springSecurityFilterChain - Spring MVC Dispatcher Servlet - - - - - Spring MVC Dispatcher Servlet - org.springframework.web.servlet.DispatcherServlet - - contextConfigLocation - - - 1 - - - - - Spring MVC Dispatcher Servlet - / - - - \ No newline at end of file