Search in sources :

Example 56 with DeploymentInfo

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

the class FilterRegistrationImpl method getServletNameMappings.

@Override
public Collection<String> getServletNameMappings() {
    DeploymentInfo deploymentInfo = deployment.getDeploymentInfo();
    final List<String> ret = new ArrayList<>();
    for (final FilterMappingInfo mapping : deploymentInfo.getFilterMappings()) {
        if (mapping.getMappingType() == FilterMappingInfo.MappingType.SERVLET) {
            if (mapping.getFilterName().equals(filterInfo.getName())) {
                ret.add(mapping.getMapping());
            }
        }
    }
    return ret;
}
Also used : FilterMappingInfo(io.undertow.servlet.api.FilterMappingInfo) ArrayList(java.util.ArrayList) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo)

Example 57 with DeploymentInfo

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

the class JSRWebSocketServer method main.

public static void main(final String[] args) {
    PathHandler path = Handlers.path();
    Undertow server = Undertow.builder().addHttpListener(8080, "localhost").setHandler(path).build();
    server.start();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(JSRWebSocketServer.class.getClassLoader()).setContextPath("/").addWelcomePage("index.html").setResourceManager(new ClassPathResourceManager(JSRWebSocketServer.class.getClassLoader(), JSRWebSocketServer.class.getPackage())).addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo().setBuffers(new DefaultByteBufferPool(true, 100)).addEndpoint(JsrChatWebSocketEndpoint.class)).setDeploymentName("chat.war");
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    try {
        path.addPrefixPath("/", manager.start());
    } catch (ServletException e) {
        throw new RuntimeException(e);
    }
}
Also used : ServletException(javax.servlet.ServletException) DefaultByteBufferPool(io.undertow.server.DefaultByteBufferPool) DeploymentManager(io.undertow.servlet.api.DeploymentManager) ServletContainer(io.undertow.servlet.api.ServletContainer) PathHandler(io.undertow.server.handlers.PathHandler) WebSocketDeploymentInfo(io.undertow.websockets.jsr.WebSocketDeploymentInfo) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) ClassPathResourceManager(io.undertow.server.handlers.resource.ClassPathResourceManager) WebSocketDeploymentInfo(io.undertow.websockets.jsr.WebSocketDeploymentInfo) Undertow(io.undertow.Undertow)

Example 58 with DeploymentInfo

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

the class ServletContainerImpl method addDeployment.

@Override
public DeploymentManager addDeployment(final DeploymentInfo deployment) {
    final DeploymentInfo dep = deployment.clone();
    DeploymentManager deploymentManager = new DeploymentManagerImpl(dep, this);
    deployments.put(dep.getDeploymentName(), deploymentManager);
    deploymentsByPath.put(dep.getContextPath(), deploymentManager);
    return deploymentManager;
}
Also used : DeploymentManager(io.undertow.servlet.api.DeploymentManager) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo)

Example 59 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 60 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)

Aggregations

DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)113 DeploymentManager (io.undertow.servlet.api.DeploymentManager)75 ServletContainer (io.undertow.servlet.api.ServletContainer)69 ServletInfo (io.undertow.servlet.api.ServletInfo)63 PathHandler (io.undertow.server.handlers.PathHandler)59 BeforeClass (org.junit.BeforeClass)55 FilterInfo (io.undertow.servlet.api.FilterInfo)20 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)15 HttpHandler (io.undertow.server.HttpHandler)12 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