/**
   * A Molgenis common web application initializer
   *
   * @param servletContext
   * @param appConfig
   * @param isDasUsed is the molgenis-omx-das module used?
   * @throws ServletException
   */
  protected void onStartup(ServletContext servletContext, Class<?> appConfig, boolean isDasUsed)
      throws ServletException {
    // Create the 'root' Spring application context
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(appConfig);

    // Manage the lifecycle of the root application context
    servletContext.addListener(new ContextLoaderListener(rootContext));

    // Register and map the dispatcher servlet
    ServletRegistration.Dynamic dispatcherServlet =
        servletContext.addServlet("dispatcher", new DispatcherServlet(rootContext));
    if (dispatcherServlet == null) {
      logger.warn(
          "ServletContext already contains a complete ServletRegistration for servlet 'dispatcher'");
    } else {
      final int maxSize = 32 * 1024 * 1024;
      int loadOnStartup = (isDasUsed ? 2 : 1);
      dispatcherServlet.setLoadOnStartup(loadOnStartup);
      dispatcherServlet.addMapping("/");
      dispatcherServlet.setMultipartConfig(
          new MultipartConfigElement(null, maxSize, maxSize, maxSize));
      dispatcherServlet.setInitParameter("dispatchOptionsRequest", "true");
    }

    // add filters
    javax.servlet.FilterRegistration.Dynamic etagFilter =
        servletContext.addFilter("etagFilter", new ShallowEtagHeaderFilter());
    etagFilter.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST), true, "dispatcher");

    // enable use of request scoped beans in FrontController
    servletContext.addListener(new RequestContextListener());
  }
  @Override
  public void onStartup(ServletContext container) throws ServletException {
    XmlWebApplicationContext appContext = new XmlWebApplicationContext();

    appContext.setConfigLocation("/WEB-INF/spring/appServlet/servlet-context.xml");

    ServletRegistration.Dynamic dispatcher =
        container.addServlet("appServlet", new DispatcherServlet(appContext));

    MultipartConfigElement multipartConfigElement =
        new MultipartConfigElement(null, 5000000, 5000000, 0);
    dispatcher.setMultipartConfig(multipartConfigElement);

    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/");
  }
  @Override
  public void onStartup(ServletContext container) throws ServletException {
    container.getServletRegistration("default").addMapping("/resource/*");

    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(RootContextConfiguration.class);
    container.addListener(new ContextLoaderListener(rootContext));

    AnnotationConfigWebApplicationContext servletContext =
        new AnnotationConfigWebApplicationContext();
    servletContext.register(ServletContextConfiguration.class);
    ServletRegistration.Dynamic dispatcher =
        container.addServlet("springDispatcher", new DispatcherServlet(servletContext));
    dispatcher.setLoadOnStartup(1);
    dispatcher.setMultipartConfig(
        new MultipartConfigElement(null, 20_971_520L, 41_943_040L, 512_000));
    dispatcher.addMapping("/");
  }
 @Override
 protected void customizeRegistration(ServletRegistration.Dynamic registration) {
   registration.setMultipartConfig(getMultipartConfigElement());
 }