Search in sources :

Example 1 with PredicatesHandler

use of io.undertow.predicate.PredicatesHandler in project ice by JBEI.

the class DevelopmentServer method main.

public static void main(String[] args) throws Exception {
    DeploymentInfo servletBuilder = Servlets.deployment().setClassLoader(ClassLoader.getSystemClassLoader()).addListener(Servlets.listener(IceServletContextListener.class)).setContextPath("/").setDeploymentName("Inventory for Composable Elements").setResourceManager(new FileResourceManager(new File("src/main/webapp"), 10)).addWelcomePage("index.htm").addServlets(Servlets.servlet("Jersey REST Servlet", ServletContainer.class).addInitParam("jersey.config.server.provider.packages", "org.jbei.ice.services.rest").addInitParam("jersey.config.server.provider.scanning.recursive", "false").addInitParam("javax.ws.rs.Application", "org.jbei.ice.services.rest.multipart.IceApplication").setAsyncSupported(true).setEnabled(true).addMapping("/rest/*"));
    // deploy servlet
    DeploymentManager manager = Servlets.defaultContainer().addDeployment(servletBuilder);
    manager.deploy();
    HttpHandler servletHandler = manager.start();
    PredicatesHandler handler = Handlers.predicates(PredicatedHandlersParser.parse("path-prefix('search') or " + "path-prefix('folders') or " + "path-prefix('upload') or " + "path-prefix('download') or " + "path-prefix('entry') or path-prefix('admin') and regex('/.+') -> rewrite('/')", ClassLoader.getSystemClassLoader()), servletHandler);
    PathHandler path = Handlers.path(Handlers.redirect("/")).addPrefixPath("/", handler);
    Undertow server = Undertow.builder().addHttpListener(8080, "localhost").setHandler(path).build();
    server.start();
}
Also used : HttpHandler(io.undertow.server.HttpHandler) FileResourceManager(io.undertow.server.handlers.resource.FileResourceManager) DeploymentManager(io.undertow.servlet.api.DeploymentManager) PredicatesHandler(io.undertow.predicate.PredicatesHandler) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) PathHandler(io.undertow.server.handlers.PathHandler) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) File(java.io.File) Undertow(io.undertow.Undertow)

Aggregations

Undertow (io.undertow.Undertow)1 PredicatesHandler (io.undertow.predicate.PredicatesHandler)1 HttpHandler (io.undertow.server.HttpHandler)1 PathHandler (io.undertow.server.handlers.PathHandler)1 FileResourceManager (io.undertow.server.handlers.resource.FileResourceManager)1 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)1 DeploymentManager (io.undertow.servlet.api.DeploymentManager)1 File (java.io.File)1 ServletContainer (org.glassfish.jersey.servlet.ServletContainer)1