Search in sources :

Example 41 with PathResourceManager

use of io.undertow.server.handlers.resource.PathResourceManager in project wildfly by wildfly.

the class WebHostService method addWebDeployment.

@Override
public WebDeploymentController addWebDeployment(final WebDeploymentBuilder webDeploymentBuilder) {
    DeploymentInfo d = new DeploymentInfo();
    d.setDeploymentName(webDeploymentBuilder.getContextRoot());
    d.setContextPath(webDeploymentBuilder.getContextRoot());
    d.setClassLoader(webDeploymentBuilder.getClassLoader());
    d.setResourceManager(new PathResourceManager(webDeploymentBuilder.getDocumentRoot().toPath().toAbsolutePath(), 1024L * 1024L));
    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) 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) PathResourceManager(io.undertow.server.handlers.resource.PathResourceManager)

Aggregations

PathResourceManager (io.undertow.server.handlers.resource.PathResourceManager)41 Path (java.nio.file.Path)34 Test (org.junit.Test)30 ResourceHandler (io.undertow.server.handlers.resource.ResourceHandler)28 PathHandler (io.undertow.server.handlers.PathHandler)27 CanonicalPathHandler (io.undertow.server.handlers.CanonicalPathHandler)25 TestHttpClient (io.undertow.testutils.TestHttpClient)24 HttpGet (org.apache.http.client.methods.HttpGet)23 HttpResponse (org.apache.http.HttpResponse)20 Header (org.apache.http.Header)12 HttpHandler (io.undertow.server.HttpHandler)5 UnitTest (io.undertow.testutils.category.UnitTest)5 Undertow (io.undertow.Undertow)4 CachingResourceManager (io.undertow.server.handlers.resource.CachingResourceManager)4 PreCompressedResourceSupplier (io.undertow.server.handlers.resource.PreCompressedResourceSupplier)4 Resource (io.undertow.server.handlers.resource.Resource)3 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)3 ServletInfo (io.undertow.servlet.api.ServletInfo)3 IOException (java.io.IOException)3 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)3