Skip to content
Snippets Groups Projects
Commit 21bc5988 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

small refactor in WebAppInitializer

parent 0c644141
No related branches found
No related tags found
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!499Spring config update
Pipeline #7447 passed
......@@ -26,7 +26,7 @@ import java.util.HashSet;
public class WebAppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
public void onStartup(ServletContext container) throws ServletException {
/*
============
......@@ -43,23 +43,23 @@ public class WebAppInitializer implements WebApplicationInitializer {
SpringServiceConfig.class
);
servletContext.addListener(new ContextLoaderListener(rootContext));
servletContext.addListener(SessionListener.class);
servletContext.addListener(Log4jConfigListener.class);
servletContext.addListener(HttpSessionEventPublisher.class);
servletContext.addListener(RequestContextListener.class);
container.addListener(new ContextLoaderListener(rootContext));
container.addListener(SessionListener.class);
container.addListener(Log4jConfigListener.class);
container.addListener(HttpSessionEventPublisher.class);
container.addListener(RequestContextListener.class);
servletContext.setSessionTrackingModes(new HashSet<>(Arrays.asList(SessionTrackingMode.COOKIE)));
container.setSessionTrackingModes(new HashSet<>(Arrays.asList(SessionTrackingMode.COOKIE)));
servletContext.setInitParameter("com.sun.faces.enableMissingResourceLibraryDetection", "true");
servletContext.setInitParameter("primefaces.THEME", "home");
servletContext.setInitParameter("javax.faces.FACELETS_BUFFER_SIZE", "65535");
servletContext.setInitParameter("facelets.BUFFER_SIZE", "65535");
servletContext.setInitParameter("javax.faces.FACELETS_LIBRARIES", "/WEB-INF/springsecurity.taglib.xml");
servletContext.setInitParameter("javax.faces.CONFIG_FILES", "/WEB-INF/faces-config.xml");
servletContext.setInitParameter("javax.faces.DEFAULT_SUFFIX", ".xhtml");
servletContext.setInitParameter("javax.faces.FACELETS_SKIP_COMMENTS", "true");
servletContext.setInitParameter("log4jConfigLocation", "/WEB-INF/resources/log4j.properties");
assert container.setInitParameter("com.sun.faces.enableMissingResourceLibraryDetection", "true");
assert container.setInitParameter("primefaces.THEME", "home");
assert container.setInitParameter("javax.faces.FACELETS_BUFFER_SIZE", "65535");
assert container.setInitParameter("facelets.BUFFER_SIZE", "65535");
assert container.setInitParameter("javax.faces.FACELETS_LIBRARIES", "/WEB-INF/springsecurity.taglib.xml");
assert container.setInitParameter("javax.faces.CONFIG_FILES", "/WEB-INF/faces-config.xml");
assert container.setInitParameter("javax.faces.DEFAULT_SUFFIX", ".xhtml");
assert container.setInitParameter("javax.faces.FACELETS_SKIP_COMMENTS", "true");
assert container.setInitParameter("log4jConfigLocation", "/WEB-INF/resources/log4j.properties");
/*
===========
......@@ -70,7 +70,7 @@ public class WebAppInitializer implements WebApplicationInitializer {
AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
appContext.setParent(rootContext);
ServletRegistration.Dynamic appDispatcher =
servletContext.addServlet("App Servlet", new DispatcherServlet(appContext));
container.addServlet("App Servlet", new DispatcherServlet(appContext));
appDispatcher.setLoadOnStartup(1);
appDispatcher.addMapping(
"*.css",
......@@ -97,7 +97,7 @@ public class WebAppInitializer implements WebApplicationInitializer {
AnnotationConfigWebApplicationContext facesContext = new AnnotationConfigWebApplicationContext();
facesContext.setParent(rootContext);
ServletRegistration.Dynamic facesDispatcher =
servletContext.addServlet("Faces Servlet", new FacesServlet());
container.addServlet("Faces Servlet", new FacesServlet());
facesDispatcher.setLoadOnStartup(1);
facesDispatcher.addMapping(
"*.xhtml",
......@@ -115,7 +115,7 @@ public class WebAppInitializer implements WebApplicationInitializer {
restApiContext.setParent(rootContext);
restApiContext.register(SpringWebConfig.class);
ServletRegistration.Dynamic restApiDispatcher =
servletContext.addServlet("REST API Servlet", new DispatcherServlet(restApiContext));
container.addServlet("REST API Servlet", new DispatcherServlet(restApiContext));
restApiDispatcher.setLoadOnStartup(1);
restApiDispatcher.addMapping("/api/*");
......@@ -126,24 +126,24 @@ public class WebAppInitializer implements WebApplicationInitializer {
*/
FileUploadFilter fileUploadFilter = new FileUploadFilter();
FilterRegistration.Dynamic fileUploadFilterReg = servletContext.addFilter("PrimeFaces FileUpload Filter", fileUploadFilter);
FilterRegistration.Dynamic fileUploadFilterReg = container.addFilter("PrimeFaces FileUpload Filter", fileUploadFilter);
fileUploadFilterReg.setInitParameter("thresholdSize", "51200");
fileUploadFilterReg.addMappingForServletNames(null, true, "Faces Servlet");
CssContentTypeFilter cssContentTypeFilter = new CssContentTypeFilter();
FilterRegistration.Dynamic cssContentTypeFilterReg = servletContext.addFilter("cssContentTypeFix", cssContentTypeFilter);
FilterRegistration.Dynamic cssContentTypeFilterReg = container.addFilter("cssContentTypeFix", cssContentTypeFilter);
cssContentTypeFilterReg.addMappingForUrlPatterns(null, true, "/*");
XFrameAccessControlFilter xFrameFilter = new XFrameAccessControlFilter();
FilterRegistration.Dynamic xFrameFilterReg = servletContext.addFilter("xFrameFilter", xFrameFilter);
FilterRegistration.Dynamic xFrameFilterReg = container.addFilter("xFrameFilter", xFrameFilter);
xFrameFilterReg.addMappingForUrlPatterns(null, true, "/*");
JsfAjaxAccessControlAllowFilter jsfAjaxAccessControlAllowFilter = new JsfAjaxAccessControlAllowFilter();
FilterRegistration.Dynamic jsfAjaxAccessControlAllowFilterReg = servletContext.addFilter("allowAjaxCrossSiteQueries", jsfAjaxAccessControlAllowFilter);
FilterRegistration.Dynamic jsfAjaxAccessControlAllowFilterReg = container.addFilter("allowAjaxCrossSiteQueries", jsfAjaxAccessControlAllowFilter);
jsfAjaxAccessControlAllowFilterReg.addMappingForUrlPatterns(null, true, "/*");
DelegatingFilterProxy delegatingFilterProxy = new DelegatingFilterProxy();
FilterRegistration.Dynamic delegatingFilterProxyReg = servletContext.addFilter("springSecurityFilterChain", delegatingFilterProxy);
FilterRegistration.Dynamic delegatingFilterProxyReg = container.addFilter("springSecurityFilterChain", delegatingFilterProxy);
delegatingFilterProxyReg.addMappingForUrlPatterns(EnumSet.of(DispatcherType.FORWARD, DispatcherType.REQUEST), true, "/*");
/*
......@@ -151,7 +151,7 @@ public class WebAppInitializer implements WebApplicationInitializer {
COOKIE SETTINGS
===============
*/
SessionCookieConfig cookieConfig = servletContext.getSessionCookieConfig();
SessionCookieConfig cookieConfig = container.getSessionCookieConfig();
cookieConfig.setName("MINERVA_AUTH_TOKEN");
cookieConfig.setHttpOnly(false);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment