當前位置: 首頁>>代碼示例>>Java>>正文


Java Undertow.builder方法代碼示例

本文整理匯總了Java中io.undertow.Undertow.builder方法的典型用法代碼示例。如果您正苦於以下問題:Java Undertow.builder方法的具體用法?Java Undertow.builder怎麽用?Java Undertow.builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.undertow.Undertow的用法示例。


在下文中一共展示了Undertow.builder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例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("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

示例3: start

import io.undertow.Undertow; //導入方法依賴的package包/類
public static void start(String[] args) throws ServletException {
    Map<String, String> commands = Arrays.stream(args)
            .map(cmd -> cmd.split(REGEX_EQ))
            .collect(toMap(cmdArray -> cmdArray[IDX_ZERO], cmdArray -> cmdArray[IDX_ONE]));
    Config undertowConf = Configs.DEFAULT.undertow();
    Config httpConf = undertowConf.getConfig(KEY_HTTP);
    Logger logger = LoggerFactory.getLogger(Server.class);
    logger.debug("Commands to AdeptJ Runtime: {}", commands);
    int httpPort = handlePortAvailability(httpConf, logger);
    logger.info("Starting AdeptJ Runtime @port: [{}]", httpPort);
    printBanner(logger);
    DeploymentManager manager = Servlets.defaultContainer().addDeployment(deploymentInfo(undertowConf));
    manager.deploy();
    Builder builder = Undertow.builder();
    optimizeWorkerOptions(builder, undertowConf, logger);
    ServerOptions.build(builder, undertowConf);
    builder.addHttpListener(httpPort, httpConf.getString(KEY_HOST));
    enableHttp2(undertowConf, builder, logger);
    enableAJP(undertowConf, builder, logger);
    GracefulShutdownHandler rootHandler = rootHandler(headersHandler(manager.start(), undertowConf), undertowConf);
    Undertow server = builder.setHandler(rootHandler).build();
    server.start();
    Runtime.getRuntime().addShutdownHook(new ShutdownHook(server, manager, rootHandler));
    launchBrowser(commands, httpPort, logger);
    if (!Environment.isServerConfFileExists()) {
        createServerConfFile(logger);
    }
}
 
開發者ID:AdeptJ,項目名稱:adeptj-runtime,代碼行數:29,代碼來源:Server.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(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:alikemalocalan,項目名稱:MicroBlog,代碼行數:18,代碼來源:WebConfigurerTest.java

示例5: start

import io.undertow.Undertow; //導入方法依賴的package包/類
public synchronized boolean start(JChannel channel) throws Exception {
    boolean started = false;
    if (server == null) {
        try {
            Undertow.Builder builder = Undertow.builder();
            builder.addHttpListener(port, "0.0.0.0");
            builder.setHandler(new Handler(this));
            server = builder.build();
            server.start();
            started = true;
        } catch (Exception e) {
            server = null;
            throw e;
        }
    }
    addChannel(channel);
    return started;
}
 
開發者ID:jboss-openshift,項目名稱:openshift-ping,代碼行數:19,代碼來源:UndertowServer.java

示例6: start

import io.undertow.Undertow; //導入方法依賴的package包/類
public void start() throws ServletException, IOException {
	DeploymentInfo servletInfo = LuceeServletBuilder.build( libDirs, webroot, webXmlPath, webInfPath );

	deploymentManager = defaultContainer().addDeployment( servletInfo );
	deploymentManager.deploy();

	HttpHandler httpHandler = deploymentManager.start();
	PathHandler pathHandler = Handlers.path( Handlers.redirect( "/" ) ).addPrefixPath( "/", httpHandler );
	Builder     builder     = Undertow.builder();

	builder.addHttpListener( port, host );
	builder.setHandler( pathHandler );

	undertowServer = builder.build();
	undertowServer.start();
}
 
開發者ID:DominicWatson,項目名稱:embedded-lucee-undertow-factory,代碼行數:17,代碼來源:LuceeUndertowServer.java

示例7: createServer

import io.undertow.Undertow; //導入方法依賴的package包/類
/**
 * Create And initialize undertow and handlers stack
 * @param appHandler application handler to use for this server
 * @return
 */
protected Undertow createServer(HttpHandler appHandler) {
	// Fifth Handler Session
	HttpHandler sessionHandler = sessionHandler(appHandler);
	// Fourth Handler crossOrigin
	HttpHandler crossOriginHandler = allowCrossOriginHandler(sessionHandler);
	// Third Handler exception
	HttpHandler exceptionHandler = exceptionHandler(crossOriginHandler);
	// Second Handler log
	HttpHandler logHandler = log(exceptionHandler);
	// First Handler GracefulShutdown
	GracefulShutdownHandler gracefulShutdownHandler = Handlers.gracefulShutdown(logHandler);

	Undertow.Builder builder = Undertow.builder();
	final int port = getPort();
	final String host = getHost();
	builder.addHttpListener(port, host);
	builder.setHandler(gracefulShutdownHandler);

	info("Listens on '" + host + ":" + port + "'");

	return builder.build();
}
 
開發者ID:kawane,項目名稱:songbook,代碼行數:28,代碼來源:Server.java

示例8: 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");

    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:xm-online,項目名稱:xm-uaa,代碼行數:15,代碼來源:WebConfigurerTest.java

示例9: testUndertowHttp2Enabled

import io.undertow.Undertow; //導入方法依賴的package包/類
@Test
public void testUndertowHttp2Enabled() {
    props.getHttp().setVersion(JHipsterProperties.Http.Version.V_2_0);
    UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory();
    webConfigurer.customize(container);
    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)).isTrue();
}
 
開發者ID:xm-online,項目名稱:xm-uaa,代碼行數:11,代碼來源:WebConfigurerTest.java

示例10: createBuilder

import io.undertow.Undertow; //導入方法依賴的package包/類
private Builder createBuilder(int port) {
	Builder builder = Undertow.builder();
	if (this.bufferSize != null) {
		builder.setBufferSize(this.bufferSize);
	}
	if (this.buffersPerRegion != null) {
		builder.setBuffersPerRegion(this.buffersPerRegion);
	}
	if (this.ioThreads != null) {
		builder.setIoThreads(this.ioThreads);
	}
	if (this.workerThreads != null) {
		builder.setWorkerThreads(this.workerThreads);
	}
	if (this.directBuffers != null) {
		builder.setDirectBuffers(this.directBuffers);
	}
	if (getSsl() != null && getSsl().isEnabled()) {
		configureSsl(getSsl(), port, builder);
	}
	else {
		builder.addHttpListener(port, getListenAddress());
	}
	for (UndertowBuilderCustomizer customizer : this.builderCustomizers) {
		customizer.customize(builder);
	}
	return builder;
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:29,代碼來源:UndertowEmbeddedServletContainerFactory.java

示例11: testUndertowHttp2Enabled

import io.undertow.Undertow; //導入方法依賴的package包/類
@Test
public void testUndertowHttp2Enabled() {
	props.getHttp().setVersion(JHipsterProperties.Http.Version.V_2_0);
	UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory();
	webConfigurer.customize(container);
	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)).isTrue();
}
 
開發者ID:alikemalocalan,項目名稱:MicroBlog,代碼行數:11,代碼來源:WebConfigurerTest.java

示例12: start

import io.undertow.Undertow; //導入方法依賴的package包/類
public void start() {
    if (httpPort == null && httpsPort == null) {
        httpPort = 8080;    // by default start http
    }

    StopWatch watch = new StopWatch();
    try {
        Undertow.Builder builder = Undertow.builder();
        if (httpPort != null) builder.addHttpListener(httpPort, "0.0.0.0");
        if (httpsPort != null) builder.addHttpsListener(httpsPort, "0.0.0.0", new SSLContextBuilder().build());

        int ioThreads = Math.max(Threads.availableProcessors(), 2); // same logic as io.undertow.Undertow.Builder(), but use overridden availableProcessors value
        int workerThreads = ioThreads * 8;

        builder.setHandler(new HTTPServerIOHandler(handler))
               .setServerOption(UndertowOptions.DECODE_URL, false)
               .setServerOption(UndertowOptions.ENABLE_HTTP2, true)
               .setServerOption(UndertowOptions.ENABLE_RFC6265_COOKIE_VALIDATION, true)
               .setIoThreads(ioThreads)
               .setWorkerThreads(workerThreads);

        server = builder.build();
        server.start();
    } finally {
        logger.info("http server started, httpPort={}, httpsPort={}, elapsedTime={}", httpPort, httpsPort, watch.elapsedTime());
    }
}
 
開發者ID:neowu,項目名稱:core-ng-project,代碼行數:28,代碼來源:HTTPServer.java

示例13: testUndertowHttp2Enabled

import io.undertow.Undertow; //導入方法依賴的package包/類
@Test
public void testUndertowHttp2Enabled() {
    props.getHttp().setVersion(JHipsterProperties.Http.Version.V_2_0);
    UndertowServletWebServerFactory container = new UndertowServletWebServerFactory();
    webConfigurer.customize(container);
    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)).isTrue();
}
 
開發者ID:jhipster,項目名稱:generator-jhipster,代碼行數:11,代碼來源:_WebConfigurerTest.java

示例14: runUndertow

import io.undertow.Undertow; //導入方法依賴的package包/類
public Undertow runUndertow(WebApplication application, OptionMap options) {
    Undertow.Builder builder = Undertow.builder();

    builder.setHandler(new HttpHandler() {
        @Override
        public void handleRequest(HttpServerExchange exchange) throws Exception {
            if (exchange.isInIoThread()) {
                exchange.dispatch(this);
                return;
            }
            HttpRequest request = new DefaultHttpRequest();
            request.setRequestMethod(exchange.getRequestMethod().toString());
            request.setUri(exchange.getRequestURI());
            request.setProtocol(exchange.getProtocol().toString());
            request.setQueryString(exchange.getQueryString());
            request.setCharacterEncoding(exchange.getRequestCharset());
            request.setBody(new ChannelInputStream(exchange.getRequestChannel()));
            request.setContentLength(exchange.getRequestContentLength());
            request.setRemoteAddr(exchange.getSourceAddress()
                    .getAddress()
                    .getHostAddress());
            request.setScheme(exchange.getRequestScheme());
            request.setServerName(exchange.getHostName());
            request.setServerPort(exchange.getHostPort());
            Headers headers = Headers.empty();
            exchange.getRequestHeaders().forEach(e -> {
                String headerName = e.getHeaderName().toString();
                e.forEach(v -> headers.put(headerName, v));
            });
            request.setHeaders(headers);

            try {
                HttpResponse response = application.handle(request);
                exchange.setStatusCode(response.getStatus());
                setResponseHeaders(response.getHeaders(), exchange);

                exchange.startBlocking();
                setBody(exchange.getResponseSender(), response.getBody());
            } catch (ServiceUnavailableException ex) {
                exchange.setStatusCode(503);
            } finally {
                exchange.endExchange();
            }
        }
    });

    setOptions(builder, options);
    if (options.getBoolean("http?", true)) {
        builder.addHttpListener(options.getInt("port", 80),
                options.getString("host", "0.0.0.0"));
    }

    if (options.getBoolean("ssl?", false)) {
        builder.addHttpsListener(options.getInt("sslPort", 443),
                options.getString("host", "0.0.0.0"),
                createSslContext(options));
    }
    Undertow undertow = builder.build();
    undertow.start();

    return undertow;
}
 
開發者ID:kawasima,項目名稱:enkan,代碼行數:63,代碼來源:UndertowAdapter.java

示例15: main

import io.undertow.Undertow; //導入方法依賴的package包/類
public static void main(String ... a){
  Undertow.Builder builder = Undertow.builder();
}
 
開發者ID:EsmerilProgramming,項目名稱:overtown,代碼行數:4,代碼來源:MethodLookupTest.java


注:本文中的io.undertow.Undertow.builder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。