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


Java Builder类代码示例

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


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

示例1: testCustomizeServletContainer

import io.undertow.Undertow.Builder; //导入依赖的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.Builder; //导入依赖的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

示例3: testCustomizeServletContainer

import io.undertow.Undertow.Builder; //导入依赖的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

示例4: start

import io.undertow.Undertow.Builder; //导入依赖的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

示例5: optimizeWorkerOptions

import io.undertow.Undertow.Builder; //导入依赖的package包/类
private static void optimizeWorkerOptions(Builder builder, Config undertowConf, Logger logger) {
    if (Environment.isProd()) {
        Config workerOptions = undertowConf.getConfig(KEY_WORKER_OPTIONS);
        // defaults to 64
        int cfgCoreTaskThreads = workerOptions.getInt(KEY_WORKER_TASK_CORE_THREADS);
        int calcCoreTaskThreads = Runtime.getRuntime().availableProcessors() * WORKER_TASK_THREAD_MULTIPLIER;
        builder.setWorkerOption(Options.WORKER_TASK_CORE_THREADS, calcCoreTaskThreads > cfgCoreTaskThreads
                ? calcCoreTaskThreads : cfgCoreTaskThreads);
        // defaults to double of [worker-task-core-threads] i.e 128
        int cfgMaxTaskThreads = workerOptions.getInt(KEY_WORKER_TASK_MAX_THREADS);
        int calcMaxTaskThreads = calcCoreTaskThreads * SYS_TASK_THREAD_MULTIPLIER;
        builder.setWorkerOption(Options.WORKER_TASK_MAX_THREADS, calcMaxTaskThreads > cfgMaxTaskThreads
                ? calcMaxTaskThreads : cfgMaxTaskThreads);
        // For a 16 core system, number of worker task core and max threads will be.
        // 1. core task thread: 128 (16[cores] * 8)
        // 2. max task thread: 128 * 2 = 256
        // Default settings would have set the following.
        // 1. core task thread: 128 (16[cores] * 8)
        // 2. max task thread: 128 (Same as core task thread)
        logger.info("Undertow Worker Options optimized for AdeptJ Runtime [PROD] mode.");
    }
}
 
开发者ID:AdeptJ,项目名称:adeptj-runtime,代码行数:23,代码来源:Server.java

示例6: testCustomizeServletContainer

import io.undertow.Undertow.Builder; //导入依赖的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

示例7: start

import io.undertow.Undertow.Builder; //导入依赖的package包/类
@Override
public void start(ServerConfig serverConfig) throws Exception {
    shutdownHandler = new GracefulShutdownHandler(createHandler(dispatcher, serverConfig.contextPath()));
    
    final Builder builder = Undertow.builder()
        .setHandler(shutdownHandler)
        .addHttpListener(serverConfig.port(), serverConfig.host())
        
        // from undertow-edge benchmark
        .setServerOption(UndertowOptions.ALWAYS_SET_KEEP_ALIVE, false) //don't send a keep-alive header for HTTP/1.1 requests, as it is not required
        ;
    
    configureServerPerformance(builder, serverConfig);
    
    server = builder.build();
    server.start();
}
 
开发者ID:MTDdk,项目名称:jawn,代码行数:18,代码来源:UndertowServer.java

示例8: start

import io.undertow.Undertow.Builder; //导入依赖的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

示例9: UndertowServer

import io.undertow.Undertow.Builder; //导入依赖的package包/类
@Inject
public UndertowServer(final org.jooby.spi.HttpHandler dispatcher, final Config conf,
    final Provider<SSLContext> sslContext) throws Exception {

  awaitShutdown = conf.getDuration("undertow.awaitShutdown", TimeUnit.MILLISECONDS);
  boolean http2 = conf.getBoolean("server.http2.enabled");
  shutdown = new GracefulShutdownHandler(doHandler(dispatcher, conf));
  Undertow.Builder ubuilder = configure(conf, io.undertow.Undertow.builder())
      .addHttpListener(conf.getInt("application.port"),
          host(conf.getString("application.host")));

  ubuilder.setServerOption(UndertowOptions.ENABLE_HTTP2, http2);

  boolean securePort = conf.hasPath("application.securePort");

  if (securePort) {
    ubuilder.addHttpsListener(conf.getInt("application.securePort"),
        host(conf.getString("application.host")), sslContext.get());
  }

  this.server = ubuilder.setHandler(shutdown)
      .build();
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:24,代码来源:UndertowServer.java

示例10: testCustomizeServletContainer

import io.undertow.Undertow.Builder; //导入依赖的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

示例11: testUndertowHttp2Enabled

import io.undertow.Undertow.Builder; //导入依赖的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

示例12: main

import io.undertow.Undertow.Builder; //导入依赖的package包/类
public static void main(String[] args) {
  final Builder builder = Undertow
      .builder()
      .setDirectBuffers(true)
      .setServerOption(UndertowOptions.ENABLE_HTTP2 , true);

  final Application jaxRsActivator = new Application() {
    @Override
    public Set<Class<?>> getClasses() {
      final Set<Class<?>> classes = new HashSet<>();
      classes.add(ServiceREST.class);
      classes.add(LoginREST.class);
      return classes;
    }
  };

  final String realRestPort = System.getProperty(REST_PORT_PROPERTY , DEFAULT_REST_PORT + "");
  final String realRestHost = System.getProperty(REST_HOST_PROPERTY , MainRest.DEFAULT_HOST);

  System.setProperty(RESTEASY_PORT_PROPERTY , realRestPort);
  System.setProperty(RESTEASY_HOST_PROPERTY , realRestHost);

  builder.addHttpListener(Integer.parseInt(realRestPort) , realRestHost);
  jaxrsServer = new UndertowJaxrsServer().start(builder);
  final ResteasyDeployment deployment = new ResteasyDeployment();
  deployment.setApplication(jaxRsActivator);
  jaxrsServer.deploy(jaxrsServer.undertowDeployment(deployment)
                                .setDeploymentName("Rest")
                                .setContextPath(CONTEXT_PATH_REST)
                                .setClassLoader(MainRest.class.getClassLoader()));
}
 
开发者ID:Java-Publications,项目名称:javamagazin-009-microkernel,代码行数:32,代码来源:MainRest.java


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