2 * Copyright (C) 2019 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
;
11 import javax
.servlet
.ServletContext
;
12 import javax
.servlet
.ServletException
;
13 import javax
.servlet
.ServletRegistration
;
15 import org
.springframework
.web
.WebApplicationInitializer
;
16 import org
.springframework
.web
.context
.ContextLoaderListener
;
17 import org
.springframework
.web
.context
.support
.XmlWebApplicationContext
;
18 import org
.springframework
.web
.servlet
.DispatcherServlet
;
21 * Servlet 3.0+ environment WebApplicationInitializer implementation to replace the WEB-INF/web.xml
23 * Once this initializer is {@ #ENABLED} you need to delete or rename the WEB-INF/web.xml.
25 * For end to end integration tests another setup is needed. See {@link eu.etaxonomy.cdm.vaadin.WebAppIntegrationTestContextInitializer
26 * WebAppIntegrationTestContextInitializer}
28 * @author a.kohlbecker
32 public class CdmVaadinWebAppInitializer
implements WebApplicationInitializer
{
34 // Once this initializer is enabled you need to delete or rename the WEB-INF/web.xml.
35 static final boolean ENABLED
= false;
38 public void onStartup(ServletContext servletContext
) throws ServletException
{
44 XmlWebApplicationContext rootContext
= new XmlWebApplicationContext();
45 rootContext
.setConfigLocation("file:./src/main/webapp/WEB-INF/applicationContext.xml");
47 // Manage the lifecycle of the root application context
48 servletContext
.addListener(new ContextLoaderListener(rootContext
));
51 servletContext
.addFilter("charsetFilter#1",
52 new org
.springframework
.web
.filter
.CharacterEncodingFilter("URF-8", true));
53 // servletContext.addFilter("springSecurityFilterChain#1",
54 // new org.springframework.web.filter.DelegatingFilterProxy());
55 // TODO servletContext.getFilterRegistration("charsetFilter#1").addMappingForUrlPatterns(arg0, arg1, "/*");
56 // TODO servletContext.getFilterRegistration("springSecurityFilterChain#1").addMappingForUrlPatterns(arg0, arg1, "/*");
58 // Register and map the servlets
59 ServletRegistration
.Dynamic dispatcher
= servletContext
.addServlet(
61 new DispatcherServlet(rootContext
)
63 dispatcher
.setLoadOnStartup(1);
64 dispatcher
.addMapping("/");