io.undertow.Undertow.builder()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(237)

本文整理了Java中io.undertow.Undertow.builder()方法的一些代码示例,展示了Undertow.builder()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Undertow.builder()方法的具体详情如下:
包路径:io.undertow.Undertow
类名称:Undertow
方法名:builder

Undertow.builder介绍

暂无

代码示例

代码示例来源:origin: jooby-project/jooby

@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();
}

代码示例来源:origin: openzipkin/brave

@Override protected int initServer() {
 server = (PortExposing) new PortExposing()
   .deploy(App.class)
   .start(Undertow.builder().addHttpListener(8888, "127.0.0.1"));
 return server.getPort();
}

代码示例来源:origin: openzipkin/brave

protected int initServer() throws Exception {
 DeploymentInfo servletBuilder = Servlets.deployment()
   .setClassLoader(getClass().getClassLoader())
   .setContextPath("/")
   .setDeploymentName("test.war");
 init(servletBuilder);
 DeploymentManager manager = Servlets.defaultContainer().addDeployment(servletBuilder);
 manager.deploy();
 server = Undertow.builder()
   .addHttpListener(0, "127.0.0.1")
   .setHandler(manager.start()).build();
 server.start();
 return ((InetSocketAddress) server.getListenerInfo().get(0).getAddress()).getPort();
}

代码示例来源:origin: networknt/light-4j

static private boolean bind(HttpHandler handler, int port) {
  try {
    Undertow.Builder builder = Undertow.builder();
    if (config.enableHttps) {
      port = port < 0 ? config.getHttpsPort() : port;

代码示例来源:origin: spring-projects/spring-framework

@Override
protected void initServer() throws Exception {
  this.server = Undertow.builder().addHttpListener(getPort(), getHost())
      .setHandler(initHttpHandlerAdapter())
      .build();
}

代码示例来源:origin: syncany/syncany

private void createServer() {
  logger.log(Level.FINE, "Locked to build server...");
  OAuthTokenInterceptor extractingHttpHandler = new ExtractingTokenInterceptor(ioQueue);
  IPAddressAccessControlHandler ipAddressAccessControlHandler = new IPAddressAccessControlHandler();
  ipAddressAccessControlHandler.setDefaultAllow(false);
  for (InetAddress inetAddress : allowedClients) {
    ipAddressAccessControlHandler.addAllow(inetAddress.getHostAddress());
  }
  server = Undertow.builder()
          .addHttpListener(port, "localhost")
          .setHandler(ipAddressAccessControlHandler)
          .setHandler(Handlers.path()
                          .addExactPath(createPath(extractingHttpHandler.getPathPrefix()), extractingHttpHandler)
                          .addExactPath(createPath(interceptor.getPathPrefix()), interceptor)
          )
          .build();
  logger.log(Level.INFO, "Starting token web listener...");
  server.start();
}

代码示例来源:origin: openzipkin/brave

@Setup(Level.Trial) public void init() throws Exception {
 server = Undertow.builder()
   .addHttpListener(0, "127.0.0.1")
   .setHandler(exchange -> {
    exchange.getResponseHeaders().put(CONTENT_TYPE, "text/plain; charset=UTF-8");
    exchange.getResponseSender().send("hello world");
   }).build();
 server.start();
 baseUrl = "http://127.0.0.1:" +
   ((InetSocketAddress) server.getListenerInfo().get(0).getAddress()).getPort();
 client = newClient();
 tracedClient = newClient(HttpTracing.create(
   Tracing.newBuilder().spanReporter(Reporter.NOOP).build()
 ));
 unsampledClient = newClient(HttpTracing.create(
   Tracing.newBuilder().sampler(Sampler.NEVER_SAMPLE).spanReporter(Reporter.NOOP).build()
 ));
}

代码示例来源:origin: spring-projects/spring-framework

this.manager.deploy();
HttpHandler httpHandler = this.manager.start();
this.server = Undertow.builder().addHttpListener(0, "localhost").setHandler(httpHandler).build();

代码示例来源:origin: org.springframework.boot/spring-boot

private Undertow.Builder createBuilder(int port) {
  Undertow.Builder builder = Undertow.builder();
  if (this.bufferSize != null) {
    builder.setBufferSize(this.bufferSize);
  }
  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()) {
    customizeSsl(builder);
  }
  else {
    builder.addHttpListener(port, getListenAddress());
  }
  for (UndertowBuilderCustomizer customizer : this.builderCustomizers) {
    customizer.customize(builder);
  }
  return builder;
}

代码示例来源:origin: org.springframework.boot/spring-boot

private Builder createBuilder(int port) {
  Builder builder = Undertow.builder();
  if (this.bufferSize != null) {
    builder.setBufferSize(this.bufferSize);
  }
  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()) {
    customizeSsl(builder);
  }
  else {
    builder.addHttpListener(port, getListenAddress());
  }
  for (UndertowBuilderCustomizer customizer : this.builderCustomizers) {
    customizer.customize(builder);
  }
  return builder;
}

代码示例来源:origin: syncany/syncany

.builder()
.addHttpsListener(bindPort, bindAddress, sslContext)
.setHandler(securityPathHttpHandler)

代码示例来源:origin: resteasy/Resteasy

public UndertowJaxrsServer start()
{
 server = Undertow.builder()
     .addHttpListener(PortProvider.getPort(), "localhost")
     .setHandler(root)
     .build();
 server.start();
 return this;
}

代码示例来源:origin: hantsy/spring-reactive-sample

@Bean
public Undertow undertowServer(ApplicationContext context) {
  HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();  // (2)
  // Undertow
  UndertowHttpHandlerAdapter undertowAdapter = new UndertowHttpHandlerAdapter(handler);
  Undertow server = Undertow.builder()
    .addHttpListener(port, "localhost")
    .setHandler(undertowAdapter)
    .build();
  return server;
}

代码示例来源:origin: org.jboss.arquillian.container/undertow-embedded

private Undertow createUndertow(HttpHandler handler) {
  return Undertow
  .builder()
  .setHandler(handler)
  .addHttpListener(configuration.getBindHttpPort(),
      configuration.getBindAddress()).build();
}

代码示例来源:origin: allegro/hermes

public OAuthTestServer() {
  port = Ports.nextAvailable();
  this.undertow = Undertow.builder()
    .addHttpListener(port, "localhost")
    .setHandler(createPathHandler())
    .build();
}

代码示例来源:origin: pippo-java/pippo

protected Undertow createServer(HttpHandler contextHandler) {
  Builder builder = Undertow.builder();

代码示例来源:origin: io.termd/termd-core

public void bootstrap(final Consumer<Boolean> completionHandler) {
 server = Undertow.builder()
   .addHttpListener(port, host)
   .setHandler(UndertowBootstrap.this::handleWebSocketRequests)
   .build();
 server.start();
 completionHandler.accept(true);
}

代码示例来源:origin: ch.digitalfondue.stampo/stampo

private Undertow prepareServer(Set<WebSocketChannel> activeChannels) {
 HttpHandler handler =
   autoReload ? Handlers.path()
     .addExactPath("/stampo-reload", websocketHandler(activeChannels))
     .addPrefixPath("/", staticResourcesHandler()) : staticResourcesHandler();
 Undertow server =
   Undertow.builder().addHttpListener(port, hostname).setHandler(handler).build();
 return server;
}

代码示例来源:origin: olacabs/fabric

public void startMonitor(final ComputationPipeline pipeline) {
  healthcheckMonitor = Undertow.builder().addHttpListener(8080, "0.0.0.0").setHandler(exchange -> {
    boolean result = pipeline.healthcheck();
    exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
    exchange.setStatusCode(result ? HttpStatus.SC_OK : HttpStatus.SC_INTERNAL_SERVER_ERROR);
    exchange.getResponseSender().send(result ? "alive" : "dead");
  })  .build();
  healthcheckMonitor.start();
}

代码示例来源:origin: de.svenkubiak/mangooio-core

public void startServer() {
  if (!this.error) {
    this.host = this.config.getString(Key.APPLICATION_HOST, Default.APPLICATION_HOST.toString());
    this.port = this.config.getInt(Key.APPLICATION_PORT, Default.APPLICATION_PORT.toInt());
    Undertow server = Undertow.builder()
        .addHttpListener(this.port, this.host)
        .setHandler(Handlers.exceptionHandler(this.pathHandler).addExceptionHandler(Throwable.class, new ExceptionHandler()))
        .build();
    server.start();
    this.undertow = server;
  }
}

相关文章