当前位置: 首页>>代码示例>>Java>>正文


Java Undertow类代码示例

本文整理汇总了Java中io.undertow.Undertow的典型用法代码示例。如果您正苦于以下问题:Java Undertow类的具体用法?Java Undertow怎么用?Java Undertow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Undertow类属于io.undertow包,在下文中一共展示了Undertow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import io.undertow.Undertow; //导入依赖的package包/类
public static void main(String[] args) throws ParseException {

        Options options = new Options();
        options.addOption("p", "port", true, "port number");
        options.addOption("n", "hostname", true, "hostname, e.g. localhost");

        CommandLine cmd = new DefaultParser().parse(options, args);

        int port = Integer.parseInt(cmd.getOptionValue("p", "8080"));
        String hostname = cmd.getOptionValue("n", "localhost");

        UndertowJaxrsServer ut = new UndertowJaxrsServer();
        ut.deploy(new Application() {
            @Override
            public Set<Class<?>> getClasses() {
                Reflections reflections = new Reflections("org.neo4j.extension.firehose");
                return reflections.getTypesAnnotatedWith(Path.class);
            }
        });

        ut.start(Undertow.builder().addHttpListener(port, hostname));
        System.out.println(String.format("Started server at http://%s:%d/  Hit ^C to stop", hostname, port));
    }
 
开发者ID:sarmbruster,项目名称:neo4j-csv-firehose,代码行数:24,代码来源:Server.java

示例2: testCustomizeServletContainer

import io.undertow.Undertow; //导入依赖的package包/类
@Test
public void testCustomizeServletContainer() {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory();
    webConfigurer.customize(container);
    assertThat(container.getMimeMappings().get("abs")).isEqualTo("audio/x-mpeg");
    assertThat(container.getMimeMappings().get("html")).isEqualTo("text/html;charset=utf-8");
    assertThat(container.getMimeMappings().get("json")).isEqualTo("text/html;charset=utf-8");
    if (container.getDocumentRoot() != null) {
        assertThat(container.getDocumentRoot().getPath()).isEqualTo(FilenameUtils.separatorsToSystem("target/www"));
    }

    Builder builder = Undertow.builder();
    container.getBuilderCustomizers().forEach(c -> c.customize(builder));
    OptionMap.Builder serverOptions = (OptionMap.Builder) ReflectionTestUtils.getField(builder, "serverOptions");
    assertThat(serverOptions.getMap().get(UndertowOptions.ENABLE_HTTP2)).isNull();
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:18,代码来源:WebConfigurerTest.java

示例3: testCustomizeServletContainer

import io.undertow.Undertow; //导入依赖的package包/类
@Test
public void testCustomizeServletContainer() {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory();
    webConfigurer.customize(container);
    assertThat(container.getMimeMappings().get("abs")).isEqualTo("audio/x-mpeg");
    assertThat(container.getMimeMappings().get("html")).isEqualTo("text/html;charset=utf-8");
    assertThat(container.getMimeMappings().get("json")).isEqualTo("text/html;charset=utf-8");
    if (container.getDocumentRoot() != null) {
        assertThat(container.getDocumentRoot().getPath()).isEqualTo(FilenameUtils.separatorsToSystem("build/www"));
    }

    Builder builder = Undertow.builder();
    container.getBuilderCustomizers().forEach(c -> c.customize(builder));
    OptionMap.Builder serverOptions = (OptionMap.Builder) ReflectionTestUtils.getField(builder, "serverOptions");
    assertThat(serverOptions.getMap().get(UndertowOptions.ENABLE_HTTP2)).isNull();
}
 
开发者ID:michaelhoffmantech,项目名称:patient-portal,代码行数:18,代码来源:WebConfigurerTest.java

示例4: testCustomizeServletContainer

import io.undertow.Undertow; //导入依赖的package包/类
@Test
public void testCustomizeServletContainer() {
    env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
    UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory();
    webConfigurer.customize(container);
    assertThat(container.getMimeMappings().get("abs")).isEqualTo("audio/x-mpeg");
    assertThat(container.getMimeMappings().get("html")).isEqualTo("text/html;charset=utf-8");
    assertThat(container.getMimeMappings().get("json")).isEqualTo("text/html;charset=utf-8");
    if (container.getDocumentRoot() != null) {
        assertThat(container.getDocumentRoot().getPath()).isEqualTo("target/www");
    }

    Builder builder = Undertow.builder();
    container.getBuilderCustomizers().forEach(c -> c.customize(builder));
    OptionMap.Builder serverOptions = (OptionMap.Builder) ReflectionTestUtils.getField(builder, "serverOptions");
    assertThat(serverOptions.getMap().get(UndertowOptions.ENABLE_HTTP2)).isNull();
}
 
开发者ID:deepu105,项目名称:spring-io,代码行数:18,代码来源:WebConfigurerTest.java

示例5: setUp

import io.undertow.Undertow; //导入依赖的package包/类
@Before
public void setUp() {
    if(server == null) {
        logger.info("starting server");

        HttpHandler handler = getPetStoreHandler();
        ValidatorHandler validatorHandler = new ValidatorHandler();
        validatorHandler.setNext(handler);
        handler = validatorHandler;

        BodyHandler bodyHandler = new BodyHandler();
        bodyHandler.setNext(handler);
        handler = bodyHandler;

        SwaggerHandler swaggerHandler = new SwaggerHandler();
        swaggerHandler.setNext(handler);
        handler = swaggerHandler;

        server = Undertow.builder()
                .addHttpListener(8080, "localhost")
                .setHandler(handler)
                .build();
        server.start();
    }
}
 
开发者ID:networknt,项目名称:light-rest-4j,代码行数:26,代码来源:ValidatorHandlerTest.java

示例6: setUp

import io.undertow.Undertow; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
    if(server == null) {
        logger.info("starting server");
        HttpHandler handler = getTestHandler();
        JwtVerifyHandler jwtVerifyHandler = new JwtVerifyHandler();
        jwtVerifyHandler.setNext(handler);
        OpenApiHandler openApiHandler = new OpenApiHandler();
        openApiHandler.setNext(jwtVerifyHandler);
        server = Undertow.builder()
                .addHttpListener(8080, "localhost")
                .setHandler(openApiHandler)
                .build();
        server.start();
    }
}
 
开发者ID:networknt,项目名称:light-rest-4j,代码行数:17,代码来源:JwtVerifyHandlerTest.java

示例7: setUp

import io.undertow.Undertow; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
    if(server == null) {
        logger.info("starting server");
        HttpHandler handler = getTestHandler();
        JwtVerifyHandler jwtVerifyHandler = new JwtVerifyHandler();
        jwtVerifyHandler.setNext(handler);
        SwaggerHandler swaggerHandler = new SwaggerHandler();
        swaggerHandler.setNext(jwtVerifyHandler);
        server = Undertow.builder()
                .addHttpListener(8080, "localhost")
                .setHandler(swaggerHandler)
                .build();
        server.start();
    }
}
 
开发者ID:networknt,项目名称:light-rest-4j,代码行数:17,代码来源:JwtVerifyHandlerTest.java

示例8: setUp

import io.undertow.Undertow; //导入依赖的package包/类
@Before
public void setUp() {
    if(server == null) {
        logger.info("starting server");

        HttpHandler handler = getPetStoreHandler();
        ValidatorHandler validatorHandler = new ValidatorHandler();
        validatorHandler.setNext(handler);
        handler = validatorHandler;

        BodyHandler bodyHandler = new BodyHandler();
        bodyHandler.setNext(handler);
        handler = bodyHandler;

        OpenApiHandler openApiHandler = new OpenApiHandler();
        openApiHandler.setNext(handler);
        handler = openApiHandler;

        server = Undertow.builder()
                .addHttpListener(8080, "localhost")
                .setHandler(handler)
                .build();
        server.start();
    }
}
 
开发者ID:networknt,项目名称:light-rest-4j,代码行数:26,代码来源:ValidatorHandlerTest.java

示例9: main

import io.undertow.Undertow; //导入依赖的package包/类
public static void main(String[] args) {
    int port = 8080;
    /*
     *  "localhost" will ONLY listen on local host.
     *  If you want the server reachable from the outside you need to set "0.0.0.0"
     */
    String host = "localhost";

    /*
     * This web server has a single handler with no routing.
     * ALL urls are handled by the helloWorldHandler.
     */
    Undertow server = Undertow.builder()
        // Add the helloWorldHandler as a method reference.
        .addHttpListener(port, host, HelloWorldServer::helloWorldHandler)
        .build();
    logger.debug("starting on http://" + host + ":" + port);
    server.start();
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:20,代码来源:HelloWorldServer.java

示例10: main

import io.undertow.Undertow; //导入依赖的package包/类
public static void main(String[] args) {
    Base64.Decoder b64decoder = Base64.getUrlDecoder();
    final Undertow server = Undertow.builder()
            .addHttpListener(8083, "localhost")
            .setHandler(exchange -> {
                exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
                String credential = exchange.getRequestHeaders().getFirst("X-Bouncr-Credential");
                String[] tokens = credential.split("\\.", 3);
                String json = new String(b64decoder.decode(tokens[1]));


                exchange.getResponseSender().send("Server1\n"
                        + "profile=" + json + "\n"
                );
            })
            .build();
    Runtime.getRuntime().addShutdownHook(new Thread(server::stop));
    server.start();
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:20,代码来源:ForTestBackendApp.java

示例11: setUp

import io.undertow.Undertow; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
    // inject in memory constructed info.json to homeDir as classpath
    Config.getInstance().clear();
    Map<String, Object> map = new HashMap<>();
    map.put("enableServerInfo", false);
    Config.getInstance().getYaml().dump(map, new PrintWriter(new File(homeDir + "/info.yml")));
    // Add home directory to the classpath of the system class loader.
    addURL(new File(homeDir).toURI().toURL());

    if(server == null) {
        logger.info("starting server");
        HttpHandler handler = getTestHandler();
        server = Undertow.builder()
                .addHttpListener(8080, "localhost")
                .setHandler(handler)
                .build();
        server.start();
    }
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:21,代码来源:ServerInfoDisabledTest.java

示例12: setUp

import io.undertow.Undertow; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
    if(server == null) {
        logger.info("starting server");
        HttpHandler handler = getTestHandler();
        LimitHandler limitHandler = new LimitHandler();
        limitHandler.setNext(handler);
        handler = limitHandler;
        server = Undertow.builder()
                .setServerOption(UndertowOptions.ENABLE_HTTP2, true)
                .addHttpListener(8080, "localhost")
                .setHandler(handler)
                .build();
        server.start();
    }
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:17,代码来源:LimitHandlerTest.java

示例13: setUp

import io.undertow.Undertow; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
    if(server == null) {
        logger.info("starting server");
        HttpHandler handler = getTestHandler();

        MetricsHandler metricsHandler = new MetricsHandler();
        metricsHandler.setNext(handler);
        handler = metricsHandler;

        server = Undertow.builder()
                .addHttpListener(8080, "localhost")
                .setHandler(handler)
                .build();
        server.start();
    }
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:18,代码来源:MetricsHandlerTest.java

示例14: setUp

import io.undertow.Undertow; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
    if(server == null) {
        logger.info("starting server");
        HttpHandler handler = getTestHandler();

        AuditHandler auditHandler = new AuditHandler();
        auditHandler.setNext(handler);
        handler = auditHandler;

        CorrelationHandler correlationHandler = new CorrelationHandler();
        correlationHandler.setNext(handler);
        handler = correlationHandler;

        server = Undertow.builder()
                .addHttpListener(8080, "localhost")
                .setHandler(handler)
                .build();
        server.start();
    }
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:22,代码来源:AuditHandlerTest.java

示例15: setUp

import io.undertow.Undertow; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
    if(server == null) {
        logger.info("starting server");
        HttpHandler handler = getTestHandler();

        SanitizerHandler sanitizerHandler = new SanitizerHandler();
        sanitizerHandler.setNext(handler);
        handler = sanitizerHandler;

        BodyHandler bodyHandler = new BodyHandler();
        bodyHandler.setNext(handler);
        handler = bodyHandler;

        server = Undertow.builder()
                .addHttpListener(8080, "localhost")
                .setHandler(handler)
                .build();
        server.start();
    }
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:22,代码来源:SanitizerHandlerTest.java


注:本文中的io.undertow.Undertow类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。