Search in sources :

Example 1 with DeploymentInfo

use of io.undertow.servlet.api.DeploymentInfo 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 DeploymentInfo

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

the class UndertowContextTestCase method getPath.

@Test
public void getPath() {
    DeploymentInfo info = new DeploymentInfo();
    String expected = "";
    info.setContextPath(expected);
    when(this.deployment.getDeploymentInfo()).thenReturn(info);
    String result = this.context.getPath();
    assertSame(expected, result);
}
Also used : DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) Test(org.junit.Test)

Example 3 with DeploymentInfo

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

the class UndertowHostTestCase method findContext.

@Test
public void findContext() {
    Deployment deployment = mock(Deployment.class);
    DeploymentInfo info = new DeploymentInfo();
    String expectedPath = "";
    info.setContextPath(expectedPath);
    HttpHandler handler = mock(HttpHandler.class);
    when(deployment.getDeploymentInfo()).thenReturn(info);
    this.undertowHost.registerDeployment(deployment, handler);
    Context result = this.host.findContext(expectedPath);
    assertSame(this.host, result.getHost());
    assertSame(expectedPath, result.getPath());
    result = this.host.findContext("unknown");
    assertNull(result);
}
Also used : Context(org.jboss.modcluster.container.Context) HttpHandler(io.undertow.server.HttpHandler) Deployment(io.undertow.servlet.api.Deployment) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) Test(org.junit.Test)

Example 4 with DeploymentInfo

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

the class UndertowHostTestCase method getContexts.

@Test
public void getContexts() {
    Deployment deployment = mock(Deployment.class);
    DeploymentInfo info = new DeploymentInfo();
    String expectedPath = "";
    info.setContextPath(expectedPath);
    HttpHandler handler = mock(HttpHandler.class);
    when(deployment.getDeploymentInfo()).thenReturn(info);
    this.undertowHost.registerDeployment(deployment, handler);
    Iterator<Context> result = this.host.getContexts().iterator();
    assertTrue(result.hasNext());
    Context context = result.next();
    assertSame(this.host, context.getHost());
    assertSame(expectedPath, context.getPath());
    assertFalse(result.hasNext());
}
Also used : Context(org.jboss.modcluster.container.Context) HttpHandler(io.undertow.server.HttpHandler) Deployment(io.undertow.servlet.api.Deployment) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) Test(org.junit.Test)

Example 5 with DeploymentInfo

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

the class VolatileParticipantService method deployParticipant.

private void deployParticipant() {
    undeployServlet();
    final Map<String, String> initialParameters = new HashMap<String, String>();
    initialParameters.put("javax.ws.rs.Application", VolatileParticipantApplication.class.getName());
    final DeploymentInfo participantDeploymentInfo = getDeploymentInfo(DEPLOYMENT_NAME, CONTEXT_PATH, initialParameters);
    deployServlet(participantDeploymentInfo);
}
Also used : HashMap(java.util.HashMap) VolatileParticipantApplication(org.wildfly.extension.rts.jaxrs.VolatileParticipantApplication) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo)

Aggregations

DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)105 DeploymentManager (io.undertow.servlet.api.DeploymentManager)72 ServletContainer (io.undertow.servlet.api.ServletContainer)68 PathHandler (io.undertow.server.handlers.PathHandler)58 ServletInfo (io.undertow.servlet.api.ServletInfo)58 BeforeClass (org.junit.BeforeClass)55 FilterInfo (io.undertow.servlet.api.FilterInfo)19 SimpleServletTestCase (io.undertow.servlet.test.SimpleServletTestCase)17 TestResourceLoader (io.undertow.servlet.test.util.TestResourceLoader)17 WebSocketDeploymentInfo (io.undertow.websockets.jsr.WebSocketDeploymentInfo)16 LoginConfig (io.undertow.servlet.api.LoginConfig)15 ServletException (javax.servlet.ServletException)14 HttpHandler (io.undertow.server.HttpHandler)11 SecurityConstraint (io.undertow.servlet.api.SecurityConstraint)11 WebResourceCollection (io.undertow.servlet.api.WebResourceCollection)11 Test (org.junit.Test)11 ListenerInfo (io.undertow.servlet.api.ListenerInfo)10 ServletIdentityManager (io.undertow.servlet.test.security.constraint.ServletIdentityManager)10 ServerWebSocketContainer (io.undertow.websockets.jsr.ServerWebSocketContainer)8 HashMap (java.util.HashMap)8