Search in sources :

Example 1 with DeploymentManager

use of io.undertow.servlet.api.DeploymentManager in project spring-boot by spring-projects.

the class UndertowServletWebServerFactory method createDeploymentManager.

private DeploymentManager createDeploymentManager(ServletContextInitializer... initializers) {
    DeploymentInfo deployment = Servlets.deployment();
    registerServletContainerInitializerToDriveServletContextInitializers(deployment, initializers);
    deployment.setClassLoader(getServletClassLoader());
    deployment.setContextPath(getContextPath());
    deployment.setDisplayName(getDisplayName());
    deployment.setDeploymentName("spring-boot");
    if (isRegisterDefaultServlet()) {
        deployment.addServlet(Servlets.servlet("default", DefaultServlet.class));
    }
    configureErrorPages(deployment);
    deployment.setServletStackTraces(ServletStackTraces.NONE);
    deployment.setResourceManager(getDocumentRootResourceManager());
    configureMimeMappings(deployment);
    for (UndertowDeploymentInfoCustomizer customizer : this.deploymentInfoCustomizers) {
        customizer.customize(deployment);
    }
    if (isAccessLogEnabled()) {
        configureAccessLog(deployment);
    }
    if (isPersistSession()) {
        File dir = getValidSessionStoreDir();
        deployment.setSessionPersistenceManager(new FileSessionPersistence(dir));
    }
    addLocaleMappings(deployment);
    DeploymentManager manager = Servlets.newContainer().addDeployment(deployment);
    manager.deploy();
    SessionManager sessionManager = manager.getDeployment().getSessionManager();
    int sessionTimeout = (getSessionTimeout() > 0 ? getSessionTimeout() : -1);
    sessionManager.setDefaultSessionTimeout(sessionTimeout);
    return manager;
}
Also used : DeploymentManager(io.undertow.servlet.api.DeploymentManager) SessionManager(io.undertow.server.session.SessionManager) DefaultServlet(io.undertow.servlet.handlers.DefaultServlet) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) File(java.io.File)

Example 2 with DeploymentManager

use of io.undertow.servlet.api.DeploymentManager in project spring-boot by spring-projects.

the class UndertowServletWebServerFactory method getWebServer.

@Override
public WebServer getWebServer(ServletContextInitializer... initializers) {
    DeploymentManager manager = createDeploymentManager(initializers);
    int port = getPort();
    Builder builder = createBuilder(port);
    return getUndertowWebServer(builder, manager, port);
}
Also used : DeploymentManager(io.undertow.servlet.api.DeploymentManager) Builder(io.undertow.Undertow.Builder)

Example 3 with DeploymentManager

use of io.undertow.servlet.api.DeploymentManager in project wildfly by wildfly.

the class AbstractRTSService method deployServlet.

protected void deployServlet(final DeploymentInfo deploymentInfo) {
    DeploymentManager manager = ServletContainer.Factory.newInstance().addDeployment(deploymentInfo);
    manager.deploy();
    deployment = manager.getDeployment();
    try {
        injectedHost.getValue().registerDeployment(deployment, manager.start());
    } catch (ServletException e) {
        RTSLogger.ROOT_LOGGER.warn(e.getMessage(), e);
        deployment = null;
    }
}
Also used : ServletException(javax.servlet.ServletException) DeploymentManager(io.undertow.servlet.api.DeploymentManager)

Example 4 with DeploymentManager

use of io.undertow.servlet.api.DeploymentManager in project undertow by undertow-io.

the class SessionIdHandlingTestCase method setup.

@BeforeClass
public static void setup() throws ServletException {
    final PathHandler pathHandler = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(SimpleServletTestCase.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").addServlets(new ServletInfo("servlet", RequestedSessionIdServlet.class).addMapping("/session"));
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    try {
        pathHandler.addPrefixPath(builder.getContextPath(), manager.start());
    } catch (ServletException e) {
        throw new RuntimeException(e);
    }
    DefaultServer.setRootHandler(pathHandler);
}
Also used : ServletInfo(io.undertow.servlet.api.ServletInfo) ServletException(javax.servlet.ServletException) DeploymentManager(io.undertow.servlet.api.DeploymentManager) ServletContainer(io.undertow.servlet.api.ServletContainer) PathHandler(io.undertow.server.handlers.PathHandler) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) SimpleServletTestCase(io.undertow.servlet.test.SimpleServletTestCase) BeforeClass(org.junit.BeforeClass)

Example 5 with DeploymentManager

use of io.undertow.servlet.api.DeploymentManager in project undertow by undertow-io.

the class ParameterEchoTestCase method setup.

@BeforeClass
public static void setup() throws ServletException {
    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    ServletInfo s = new ServletInfo("servlet", ParameterEchoServlet.class).addMapping("/aaa");
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(ParameterEchoTestCase.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").addServlet(s);
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    root.addPrefixPath(builder.getContextPath(), manager.start());
    DefaultServer.setRootHandler(root);
}
Also used : ServletInfo(io.undertow.servlet.api.ServletInfo) ParameterEchoServlet(io.undertow.servlet.test.util.ParameterEchoServlet) DeploymentManager(io.undertow.servlet.api.DeploymentManager) ServletContainer(io.undertow.servlet.api.ServletContainer) PathHandler(io.undertow.server.handlers.PathHandler) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) BeforeClass(org.junit.BeforeClass)

Aggregations

DeploymentManager (io.undertow.servlet.api.DeploymentManager)78 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)72 ServletContainer (io.undertow.servlet.api.ServletContainer)68 PathHandler (io.undertow.server.handlers.PathHandler)57 BeforeClass (org.junit.BeforeClass)53 ServletInfo (io.undertow.servlet.api.ServletInfo)50 TestResourceLoader (io.undertow.servlet.test.util.TestResourceLoader)17 FilterInfo (io.undertow.servlet.api.FilterInfo)16 SimpleServletTestCase (io.undertow.servlet.test.SimpleServletTestCase)16 WebSocketDeploymentInfo (io.undertow.websockets.jsr.WebSocketDeploymentInfo)13 LoginConfig (io.undertow.servlet.api.LoginConfig)12 ServletException (javax.servlet.ServletException)12 ServletIdentityManager (io.undertow.servlet.test.security.constraint.ServletIdentityManager)10 ListenerInfo (io.undertow.servlet.api.ListenerInfo)8 SecurityConstraint (io.undertow.servlet.api.SecurityConstraint)8 WebResourceCollection (io.undertow.servlet.api.WebResourceCollection)8 ServerWebSocketContainer (io.undertow.websockets.jsr.ServerWebSocketContainer)8 Test (org.junit.Test)8 TestHttpClient (io.undertow.testutils.TestHttpClient)7 ServletSecurityInfo (io.undertow.servlet.api.ServletSecurityInfo)5