This {@link WebServerFactoryCustomizer} adds a {@link ServletContextInitializer} to the embedded servlet-container
which is equivalent to rewrite's own {@code META-INF/web-fragment.xml}.

@return rewrite web server factory customizer
350012
@DependsOn("applicationContextProvider")
	@Bean
	public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> rewriteWebServerFactoryCustomizer() {
		return factory -> factory.addInitializers(servletContext -> {
			servletContext.addListener(new RewriteServletContextListener());
			servletContext.addListener(new RewriteServletRequestListener());

			FilterRegistration.Dynamic rewriteFilterRegistration = servletContext.addFilter("OCPsoft Rewrite Filter", RewriteFilter.class);
			rewriteFilterRegistration.setAsyncSupported(true);
			rewriteFilterRegistration.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*");
		});
	}
140224
@Singleton
    public TemplateEngine templateEngine(ITemplateResolver templateResolver,
            IEngineContextFactory engineContextFactory, ILinkBuilder linkBuilder) {
        TemplateEngine engine = new TemplateEngine();
        engine.setEngineContextFactory(engineContextFactory);
        engine.setLinkBuilder(linkBuilder);
        engine.setTemplateResolver(templateResolver);
        return engine;
    }
324192
static public ContentHandleFactory newFactory() {
    return new ContentHandleFactory() {
      @Override
      public Class<?>[] getHandledClasses() {
        return new Class<?>[]{ Document.class };
      }
      @Override
      public boolean isHandled(Class<?> type) {
        return Document.class.isAssignableFrom(type);
      }
      @Override
      public <C> ContentHandle<C> newHandle(Class<C> type) {
        @SuppressWarnings("unchecked")
        ContentHandle<C> handle = isHandled(type) ?
          (ContentHandle<C>) new DOM4JHandle() : null;
        return handle;
      }
    };
  }
578643
protected ServletWebServerFactory getWebServerFactory() {
		// Use bean names so that we don't consider the hierarchy
		String[] beanNames = getBeanFactory()
				.getBeanNamesForType(ServletWebServerFactory.class);
		if (beanNames.length == 0) {
			throw new ApplicationContextException(
					"Unable to start ServletWebServerApplicationContext due to missing "
							+ "ServletWebServerFactory bean.");
		}
		if (beanNames.length > 1) {
			throw new ApplicationContextException(
					"Unable to start ServletWebServerApplicationContext due to multiple "
							+ "ServletWebServerFactory beans : "
							+ StringUtils.arrayToCommaDelimitedString(beanNames));
		}
		return getBeanFactory().getBean(beanNames[0], ServletWebServerFactory.class);
	}
924836
public PageContextImpl initialize(HttpServlet servlet, HttpServletRequest req, HttpServletResponse rsp, String errorPageURL, boolean needsSession, int bufferSize,
	    boolean autoFlush, boolean isChild, boolean ignoreScopes) {
	parent = null;
	requestId = counter++;

	appListenerType = ApplicationListener.TYPE_NONE;
	this.ignoreScopes = ignoreScopes;

	ReqRspUtil.setContentType(rsp, "text/html; charset=" + config.getWebCharset().name());
	this.isChild = isChild;

	applicationContext = defaultApplicationContext;

	startTime = System.currentTimeMillis();
	thread = Thread.currentThread();

	this.req = new HTTPServletRequestWrap(req);
	this.rsp = rsp;
	this.servlet = servlet;

	// Writers
	if (config.debugLogOutput()) {
	    CFMLWriter w = config.getCFMLWriter(this, req, rsp);
	    w.setAllowCompression(false);
	    DebugCFMLWriter dcw = new DebugCFMLWriter(w);
	    bodyContentStack.init(dcw);
	    debugger.setOutputLog(dcw);
	}
	else {
	    bodyContentStack.init(config.getCFMLWriter(this, req, rsp));
	}

	writer = bodyContentStack.getWriter();
	forceWriter = writer;

	// Scopes
	server = ScopeContext.getServerScope(this, ignoreScopes);
	if (hasFamily) {
	    variablesRoot = new VariablesImpl();
	    variables = variablesRoot;
	    request = new RequestImpl();
	    _url = new URLImpl();
	    _form = new FormImpl();
	    urlForm = new UrlFormImpl(_form, _url);
	    undefined = new UndefinedImpl(this, getScopeCascadingType());

	    hasFamily = false;
	}
	else if (variables == null) {
	    variablesRoot = new VariablesImpl();
	    variables = variablesRoot;
	}
	request.initialize(this);

	if (config.mergeFormAndURL()) {
	    url = urlForm;
	    form = urlForm;
	}
	else {
	    url = _url;
	    form = _form;
	}
	// url.initialize(this);
	// form.initialize(this);
	// undefined.initialize(this);

	psq = config.getPSQL();

	fdEnabled = !config.allowRequestTimeout();

	if (config.getExecutionLogEnabled()) this.execLog = config.getExecutionLogFactory().getInstance(this);
	if (debugger != null) debugger.init(config);

	undefined.initialize(this);
	timeoutStacktrace = null;
	return this;
    }
691896
protected ServletContext initServletContext(Document webXmlDoc,
			String baseDirPath, String tmpDirPath, String springConfigFiles,
			String servletAPIversion) {

		// Parse the context parameters
		MockServletContext servletContext = new MockServletContext(
				servletAPIversion, baseDirPath, tmpDirPath);
		Map<String, Object> servletContextInitParams = new HashMap<String, Object>();
		NodeList contextParamsNodes = webXmlDoc
				.getElementsByTagName(CONTEXT_TAG_NAME);
		for (int i = 0; i < contextParamsNodes.getLength(); i++) {
			Node node = contextParamsNodes.item(i);
			initializeInitParams(node, servletContextInitParams);
		}

		// Override spring config file if needed
		if (StringUtils.isNotEmpty(springConfigFiles)) {
			servletContextInitParams.put(CONFIG_LOCATION_PARAM,
					springConfigFiles.replace(" ", "%20"));
		}

		servletContext.setInitParameters(servletContextInitParams);
		return servletContext;
	}
627665
public WebServiceTemplateBuilder setWebServiceMessageFactory(
			WebServiceMessageFactory messageFactory) {
		Assert.notNull(messageFactory, "MessageFactory must not be null");
		return new WebServiceTemplateBuilder(this.detectHttpMessageSender,
				this.interceptors, this.internalCustomizers, this.customizers,
				this.messageSenders, this.marshaller, this.unmarshaller,
				this.destinationProvider, this.transformerFactoryClass, messageFactory);
	}
558830
public static ServletContextCache getCache(ServletContext servletContext) {
		ServletContextCache cache = (ServletContextCache)servletContext.getAttribute(ATTRIBUTE_KEY);
		if(cache == null) {
			// It is possible this is called during context initialization before the listener
			cache = new ServletContextCache(servletContext);
			servletContext.setAttribute(ATTRIBUTE_KEY, cache);
			//throw new IllegalStateException("ServletContextCache not active in the provided ServletContext.  Add context listener to web.xml?");
		} else {
			assert cache.servletContext == servletContext;
		}
		return cache;
	}
315196
public JspConfiguration createClonedJspConfiguration() {
        return new JspConfiguration(configManager, this.getServletVersion(), this.jspVersion, this.isXml, this.isXmlSpecified, this.elIgnored, this.scriptingInvalid(), this.isTrimDirectiveWhitespaces(), this.isDeferredSyntaxAllowedAsLiteral(), this.getTrimDirectiveWhitespaces(), this.getDeferredSyntaxAllowedAsLiteral(), this.elIgnoredSetTrueInPropGrp(), this.elIgnoredSetTrueInPage(), this.getDefaultContentType(), this.getBuffer(), this.isErrorOnUndeclaredNamespace());
    }
605308
protected FaceletFactory createFaceletFactory(FacesContext context, Compiler compiler)
    {
        ExternalContext eContext = context.getExternalContext();

        // refresh period
        long refreshPeriod;
        if (context.isProjectStage(ProjectStage.Production))
        {
            refreshPeriod = WebConfigParamUtils.getLongInitParameter(eContext, PARAMS_REFRESH_PERIOD,
                    DEFAULT_REFRESH_PERIOD_PRODUCTION);
        }
        else
        {
            refreshPeriod = WebConfigParamUtils.getLongInitParameter(eContext, PARAMS_REFRESH_PERIOD,
                    DEFAULT_REFRESH_PERIOD);
        }

        // resource resolver
        ResourceResolver resolver = new DefaultResourceResolver();
        ArrayList<String> classNames = new ArrayList<String>();
        String faceletsResourceResolverClassName = WebConfigParamUtils.getStringInitParameter(eContext,
                PARAMS_RESOURCE_RESOLVER, null);
        List<String> resourceResolversFromAnnotations = RuntimeConfig.getCurrentInstance(
            context.getExternalContext()).getResourceResolvers();
        if (faceletsResourceResolverClassName != null)
        {
            classNames.add(faceletsResourceResolverClassName);
        }
        if (!resourceResolversFromAnnotations.isEmpty())
        {
            classNames.addAll(resourceResolversFromAnnotations);
        }
        if (!classNames.isEmpty())
        {
            resolver = ClassUtils.buildApplicationObject(ResourceResolver.class, classNames, resolver);
        }

        _resourceResolver = resolver;

        return new DefaultFaceletFactory(compiler, resolver, refreshPeriod);
    }
430116
public static ObjectMapper createMapperWithJaxbAnnotationInspector() {
        ObjectMapper mapper = new ObjectMapper();
        AnnotationIntrospector annotationInspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
        mapper.getSerializationConfig().with(annotationInspector);
        return mapper;
    }
1245457
protected IContext makeContext()
	{
		final HttpCallContext http = HttpCallContext.peek();

		if (http != null)
		{
			return new WebContext(http.getRequest(), http.getResponse(), http.getServletContext(), http.getRequest().getLocale());
		}
		else
		{
			return new Context();
		}
	}
1178015
public static FacesBackingBeanFactory get( ServletContext servletContext )
    {
        FacesBackingBeanFactory factory = ( FacesBackingBeanFactory ) servletContext.getAttribute( CONTEXT_ATTR );
        assert factory != null
                : FacesBackingBeanFactory.class.getName() + " was not found in ServletContext attribute " + CONTEXT_ATTR;
        factory.reinit( servletContext );
        return factory;
    }
384587
public static EmbeddedJettyBuilder.ServletContextHandlerBuilder addWicketHandler(EmbeddedJettyBuilder embeddedJettyBuilder,
                                                                                     String contextPath,
                                                                                     EventListener springContextloader,
                                                                                     Class<? extends WebApplication> wicketApplication,
                                                                                     boolean development){
        EmbeddedJettyBuilder.ServletContextHandlerBuilder wicketHandler = embeddedJettyBuilder.createRootServletContextHandler(contextPath)
                .setClassLoader(Thread.currentThread().getContextClassLoader())
                .addEventListener(springContextloader);
        return addWicketHandler(wicketHandler, wicketApplication, development);
    }
308151
static public ContentHandleFactory newFactory() {
    return new ContentHandleFactory() {
      @Override
      public Class<?>[] getHandledClasses() {
        return new Class<?>[]{ JsonElement.class };
      }
      @Override
      public boolean isHandled(Class<?> type) {
        return JsonElement.class.isAssignableFrom(type);
      }
      @Override
      public <C> ContentHandle<C> newHandle(Class<C> type) {
        @SuppressWarnings("unchecked")
        ContentHandle<C> handle = isHandled(type) ?
          (ContentHandle<C>) new GSONHandle() : null;
        return handle;
      }
    };
  }
1055177
private Context createContext() throws Exception
   {
      Properties properties = new Properties();
      properties.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
      properties.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      return new InitialContext(properties);
   }
891553
@Override
	public void addContextCustomizers(
			TomcatContextCustomizer... tomcatContextCustomizers) {
		Assert.notNull(tomcatContextCustomizers,
				"TomcatContextCustomizers must not be null");
		this.tomcatContextCustomizers.addAll(Arrays.asList(tomcatContextCustomizers));
	}