當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。