当前位置: 首页>>代码示例>>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;未经允许,请勿转载。