ref #10089 remove TypedEntityReference from TypeDesignationWorkingSet in vaadin
[cdm-vaadin.git] / src / main / java / eu / etaxonomy / cdm / CdmVaadinWebAppInitializer.java
1 /**
2 * Copyright (C) 2019 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9 package eu.etaxonomy.cdm;
10
11 import javax.servlet.ServletContext;
12 import javax.servlet.ServletException;
13 import javax.servlet.ServletRegistration;
14
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;
19
20 /**
21 * Servlet 3.0+ environment WebApplicationInitializer implementation to replace the WEB-INF/web.xml
22 *
23 * Once this initializer is {@ #ENABLED} you need to delete or rename the WEB-INF/web.xml.
24 *
25 * For end to end integration tests another setup is needed. See {@link eu.etaxonomy.cdm.vaadin.WebAppIntegrationTestContextInitializer
26 * WebAppIntegrationTestContextInitializer}
27 *
28 * @author a.kohlbecker
29 * @since Mar 18, 2019
30 *
31 */
32 public class CdmVaadinWebAppInitializer implements WebApplicationInitializer {
33
34 // Once this initializer is enabled you need to delete or rename the WEB-INF/web.xml.
35 static final boolean ENABLED = false;
36
37 @Override
38 public void onStartup(ServletContext servletContext) throws ServletException {
39
40 if(!ENABLED){
41 return;
42 }
43
44 XmlWebApplicationContext rootContext = new XmlWebApplicationContext();
45 rootContext.setConfigLocation("file:./src/main/webapp/WEB-INF/applicationContext.xml");
46
47 // Manage the lifecycle of the root application context
48 servletContext.addListener(new ContextLoaderListener(rootContext));
49
50 // Register Filters
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, "/*");
57
58 // Register and map the servlets
59 ServletRegistration.Dynamic dispatcher = servletContext.addServlet(
60 "cdm-vaadin",
61 new DispatcherServlet(rootContext)
62 );
63 dispatcher.setLoadOnStartup(1);
64 dispatcher.addMapping("/");
65
66
67 }
68 }