Search in sources :

Example 6 with ImmediateInstanceFactory

use of io.undertow.servlet.util.ImmediateInstanceFactory in project wildfly by wildfly.

the class WebHostService method addWebDeployment.

@Override
public WebDeploymentController addWebDeployment(final WebDeploymentBuilder webDeploymentBuilder) throws Exception {
    DeploymentInfo d = new DeploymentInfo();
    d.setDeploymentName(webDeploymentBuilder.getContextRoot());
    d.setContextPath(webDeploymentBuilder.getContextRoot());
    d.setClassLoader(webDeploymentBuilder.getClassLoader());
    d.setResourceManager(new FileResourceManager(webDeploymentBuilder.getDocumentRoot().getCanonicalFile(), 1024 * 1024));
    d.setIgnoreFlush(false);
    for (ServletBuilder servlet : webDeploymentBuilder.getServlets()) {
        ServletInfo s;
        if (servlet.getServlet() == null) {
            s = new ServletInfo(servlet.getServletName(), (Class<? extends Servlet>) servlet.getServletClass());
        } else {
            s = new ServletInfo(servlet.getServletName(), (Class<? extends Servlet>) servlet.getServletClass(), new ImmediateInstanceFactory<>(servlet.getServlet()));
        }
        if (servlet.isForceInit()) {
            s.setLoadOnStartup(1);
        }
        s.addMappings(servlet.getUrlMappings());
        for (Map.Entry<String, String> param : servlet.getInitParams().entrySet()) {
            s.addInitParam(param.getKey(), param.getValue());
        }
        d.addServlet(s);
    }
    if (controlPoint != null) {
        d.addOuterHandlerChainWrapper(GlobalRequestControllerHandler.wrapper(controlPoint, webDeploymentBuilder.getAllowRequestPredicates()));
    }
    return new WebDeploymentControllerImpl(d);
}
Also used : ServletInfo(io.undertow.servlet.api.ServletInfo) FileResourceManager(io.undertow.server.handlers.resource.FileResourceManager) ServletBuilder(org.jboss.as.web.host.ServletBuilder) Servlet(javax.servlet.Servlet) ImmediateInstanceFactory(io.undertow.servlet.util.ImmediateInstanceFactory) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) Map(java.util.Map)

Aggregations

ImmediateInstanceFactory (io.undertow.servlet.util.ImmediateInstanceFactory)6 ListenerInfo (io.undertow.servlet.api.ListenerInfo)3 FileResourceManager (io.undertow.server.handlers.resource.FileResourceManager)2 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)2 ServletContainerInitializerInfo (io.undertow.servlet.api.ServletContainerInitializerInfo)2 ServletInfo (io.undertow.servlet.api.ServletInfo)2 ManagedListener (io.undertow.servlet.core.ManagedListener)2 Map (java.util.Map)2 Servlet (javax.servlet.Servlet)2 HandlerWrapper (io.undertow.server.HandlerWrapper)1 HttpHandler (io.undertow.server.HttpHandler)1 PredicatedHandler (io.undertow.server.handlers.builder.PredicatedHandler)1 CachingResourceManager (io.undertow.server.handlers.resource.CachingResourceManager)1 ResourceManager (io.undertow.server.handlers.resource.ResourceManager)1 ServletExtension (io.undertow.servlet.ServletExtension)1 AuthMethodConfig (io.undertow.servlet.api.AuthMethodConfig)1 ErrorPage (io.undertow.servlet.api.ErrorPage)1 FilterInfo (io.undertow.servlet.api.FilterInfo)1 HttpMethodSecurityInfo (io.undertow.servlet.api.HttpMethodSecurityInfo)1 LoginConfig (io.undertow.servlet.api.LoginConfig)1