Java 类io.vertx.core.http.HttpServerOptions 实例源码

项目:incubator-servicecomb-java-chassis    文件:TestVertxTLSBuilder.java   
@Test
public void testbuildHttpServerOptionsRequest() {
  SSLOption option = SSLOption.buildFromYaml("rest.provider");
  SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
  HttpServerOptions serverOptions = new HttpServerOptions();

  new MockUp<SSLOption>() {

    @Mock
    public boolean isAuthPeer() {
      return false;
    }
  };
  VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
  Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
  Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
项目:incubator-servicecomb-java-chassis    文件:RestServerVerticle.java   
private HttpServerOptions createDefaultHttpServerOptions() {
  HttpServerOptions serverOptions = new HttpServerOptions();
  serverOptions.setUsePooledBuffers(true);
  serverOptions.setIdleTimeout(TransportConfig.getConnectionIdleTimeoutInSeconds());

  if (endpointObject.isSslEnabled()) {
    SSLOptionFactory factory =
        SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null);
    SSLOption sslOption;
    if (factory == null) {
      sslOption = SSLOption.buildFromYaml(SSL_KEY);
    } else {
      sslOption = factory.createSSLOption();
    }
    SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
    VertxTLSBuilder.buildNetServerOptions(sslOption, sslCustom, serverOptions);
  }

  return serverOptions;
}
项目:app-ms    文件:EngineSampleMain.java   
@Override
public void start() throws Exception {

    final Router router = Router.router(vertx);

    final HttpServerOptions httpServerOptions = new HttpServerOptions();
    httpServerOptions.setPort(8900);

    final HttpServer http = vertx.createHttpServer(httpServerOptions);

    SwaggerHandler.registerToRouter(router, MyApp.class);
    final JaxRsRouter jaxRsRouter = new JaxRsRouter();
    final SpringJaxRsHandler handler = new SpringJaxRsHandler(MyApp.class);
    jaxRsRouter.register(MyApp.class, router, handler, handler);
    ManifestHandler.registerToRouter(router);

    http.requestHandler(req -> router.accept(req)).listen(res -> {
        if (res.failed()) {
            res.cause().printStackTrace();
            vertx.close();
        }
    });
}
项目:vertx-zero    文件:ZeroRegistry.java   
public void registryRoute(final String name,
                          final HttpServerOptions options, final Set<String> routes) {
    final String path = MessageFormat.format(ROUTE_TREE, this.etcd.getApplication(),
            EtcdPath.ENDPOINT.toString().toLowerCase(),
            MessageFormat.format("{0}:{1}:{2}", name,
                    Net.getIPv4(), String.valueOf(options.getPort())));
    final String host = Net.getIPv4();
    final String endpoint = MessageFormat.format("http://{0}:{1}",
            host,
            String.valueOf(options.getPort()));
    // Screen Information
    final StringBuilder builder = new StringBuilder();
    for (final String route : routes) {
        builder.append("\n\t[ Up Micro ] \t").append(route);
    }
    this.logger.info(Info.ETCD_ROUTE, this.etcd.getApplication(),
            path, name, endpoint, builder.toString());
    // Build Data
    final JsonArray routeData = new JsonArray();
    Observable.fromIterable(routes)
            .subscribe(routeData::add);
    this.etcd.write(path, routeData, Values.ZERO);
}
项目:vertx-zero    文件:ZeroHttpRegistry.java   
@Override
public void start() {
    final EventBus bus = this.vertx.eventBus();
    bus.<JsonObject>consumer(ID.Addr.REGISTRY_START, result -> {
        final JsonObject data = result.body();
        final String name = data.getString(Registry.NAME);
        final HttpServerOptions options =
                new HttpServerOptions(data.getJsonObject(Registry.OPTIONS));
        final String[] uris =
                data.getString(Registry.URIS).split(Strings.COMMA);
        final Set<String> uriData = new TreeSet<>(Arrays.asList(uris));
        // Write the data to registry.
        this.registry.registryHttp(name, options, Etat.RUNNING);
        this.registry.registryRoute(name, options, uriData);

        LOGGER.info(Info.MICRO_REGISTRY_CONSUME, getClass().getSimpleName(),
                name, ID.Addr.REGISTRY_START);
    });
}
项目:vertx-zero    文件:ZeroRxAgent.java   
private void recordServer(final HttpServerOptions options,
                          final Router router) {
    final Integer port = options.getPort();
    final AtomicInteger out = ZeroAtomic.RX_START_LOGS.get(port);
    if (Values.ZERO == out.getAndIncrement()) {
        // 1. Build logs for current server;
        final String portLiteral = String.valueOf(port);
        LOGGER.info(Info.RX_SERVERS, this.NAME, deploymentID(),
                portLiteral);
        final List<Route> routes = router.getRoutes();
        final Map<String, Route> routeMap = new TreeMap<>();
        for (final Route route : routes) {
            // 2.Route
            final String path = null == route.getPath() ? "/*" : route.getPath();
            routeMap.put(path, route);
        }
        routeMap.forEach((path, route) ->
                LOGGER.info(Info.MAPPED_ROUTE, this.NAME, path,
                        route.toString()));
        // 3. Endpoint Publish
        final String address =
                MessageFormat.format("http://{0}:{1}/",
                        options.getHost(), portLiteral);
        LOGGER.info(Info.RX_LISTEN, this.NAME, address);
    }
}
项目:DMS    文件:DmsVerticle.java   
public void start() throws Exception {
     Router router = Router.router(vertx);

     router.route().handler(BodyHandler.create().setUploadsDirectory("upload-files"));
     router.route().handler(CookieHandler.create());
     router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)).setNagHttps(false));
     router.route().handler(RequestSecurePreprocessor.create());
     RouteRegister.registerRouters(router, "com.dms.secure", "com.dms.api", "com.dms.templates");
     router.route("/js/*").handler(StaticHandler.create().setCachingEnabled(false).setWebRoot("WEB-INF/js/"));

     /*
      * @see com.dms.planb.support .TableDropper
*/
     HttpServerOptions httpOpts = new HttpServerOptions();
     /*System.out.println(SecureConfig.get("SSL_PATH"));
     System.out.println(SecureConfig.get("SSL"));
     httpOpts.setSsl(true)
             .setKeyStoreOptions(new JksOptions().setPath(SecureConfig.get("SSL_PATH")).setPassword(SecureConfig.get("SSL")))
             .setTrustStoreOptions(new JksOptions().setPath(SecureConfig.get("SSL_PATH")).setPassword(SecureConfig.get("SSL")));
     */
     vertx.createHttpServer(httpOpts).requestHandler(router::accept).listen(Integer.parseInt(SecureConfig.get("SERVER_PORT")));
 }
项目:mbed-cloud-sdk-java    文件:TestServer.java   
public void start() {
    sdk = null;
    config = null;
    if (server == null) {
        Vertx vertx = Vertx
                .vertx(new VertxOptions().setWorkerPoolSize(40).setBlockedThreadCheckInterval(1000L * 60L * 10L)
                        .setMaxWorkerExecuteTime(1000L * 1000L * 1000L * 60L * 10L));
        HttpServerOptions options = new HttpServerOptions();
        options.setMaxInitialLineLength(HttpServerOptions.DEFAULT_MAX_INITIAL_LINE_LENGTH * 2);
        server = vertx.createHttpServer(options);
        router = Router.router(vertx);
    }
    retrieveConfig();
    if (config == null || config.isApiKeyEmpty()) {
        logError("Unable to find " + String.valueOf(ENVVAR_MBED_CLOUD_API_KEY) + " environment variable");
        System.exit(1);
    }
    defineInitialisationRoute();
    defineModuleMethodTestRoute();
    logInfo("Starting Java SDK test server on port " + String.valueOf(port) + "...");
    server.requestHandler(router::accept).listen(port);
}
项目:domino    文件:JksServerConfiguratorTest.java   
@Before
public void setUp() throws Exception {

    vertx = Vertx.vertx();
    JsonObject config = vertx.getOrCreateContext().config();
    Router router = Router.router(vertx);
    configuration = new VertxConfiguration(config);
    configuration.put(SSL_CONFIGURATION_KEY, FALSE);
    configuration.put(SSL_JKS_PATH, TEST_JKS_PATH);
    configuration.put(SSL_JKS_SECRET, TEST_JKS_SECRET);
    configuration.put(HTTPS_PORT, DEFAULT_HTTPS_PORT);
    options = new HttpServerOptions();
    context = VertxContext.VertxContextBuilder.vertx(vertx)
            .router(router)
            .serverConfiguration(configuration)
            .vertxServiceDiscovery(new VertxServiceDiscovery(vertx)).build();
}
项目:jspare-vertx-ms-blueprint    文件:GatewayOptions.java   
@Override
protected void init() {

    super.init();

    profile = DEFAULT_PROFILE;
    owner = DEFAULT_OWNER;
    serialKey = UUID.randomUUID().toString();
    gatewayDatabaseOptions = new GatewayDatabaseOptions();
    apiPort = DEFAULT_API_PORT;
    proxyPort = DEFAULT_PROXY_PORT;
    dashboardPort = DEFAULT_DASHBOARD_PORT;
    httpServerOptions = new HttpServerOptions();
    periodicHealthCheck = DEFAULT_PERIOD_HEALTH_CHECK;
    audit = DEFAULT_AUDIT_OPTION;
    libPath = DEFAULT_LIB_PATH;
}
项目:etagate    文件:OutServerVerticle.java   
private HttpServerOptions configSSL(JsonObject conf) {
    String ssl_keystore= conf.getString("ssl.keystore");
    String keystore_pass = conf.getString("ssl.keystore.pass");

    String ssl_client_keystore= conf.getString("ssl.client.keystore");
    String client_keystore_pass = conf.getString("ssl.client.keystore.pass");       

    HttpServerOptions options = new HttpServerOptions();
    options.setCompressionSupported(true);

    if(S.isNotBlank(ssl_keystore) && S.isNotBlank(keystore_pass)){
        options.setSsl(true).setKeyStoreOptions(
                new JksOptions().setPath(ssl_keystore).setPassword(keystore_pass));

        if(S.isNotBlank(ssl_client_keystore) && S.isNotBlank(client_keystore_pass))
            options.setClientAuth(ClientAuth.REQUIRED).setTrustStoreOptions(
                new JksOptions().setPath(ssl_client_keystore).setPassword(client_keystore_pass));
    }
    return options;
}
项目:simulacron    文件:HttpContainer.java   
public HttpContainer(String host, int port, boolean enableLogging) {
  this.host = host;
  this.port = port;
  this.enableLogging = enableLogging;
  vertx = Vertx.vertx();
  HttpServerOptions options = new HttpServerOptions().setLogActivity(this.enableLogging);
  server = vertx.createHttpServer(options);
  router = Router.router(vertx);
}
项目:incubator-servicecomb-java-chassis    文件:TestVertxTLSBuilder.java   
@Test
public void testbuildHttpServerOptions() {
  SSLOption option = SSLOption.buildFromYaml("rest.provider");
  SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
  HttpServerOptions serverOptions = new HttpServerOptions();
  VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
  Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
  Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
项目:irked    文件:Server.java   
@Override
public void start(Future<Void> startFuture) throws Exception {
    Future<HttpServer> async = Future.future();
    (server = vertx.createHttpServer(new HttpServerOptions())).requestHandler(new Irked(vertx).setupRequestHandler(test))
            .listen(config().getInteger("port"), async);
    async.map((Void) null).setHandler(startFuture);
}
项目:dragoman    文件:WebServerVerticle.java   
private HttpServerOptions createOptions() {
  Integer port = applicationConfiguration.getHttpPort();
  logger.info("Starting HTTP server on port: {}", port);

  HttpServerOptions options = new HttpServerOptions();

  options.setLogActivity(true);
  options.setHost("localhost");
  options.setPort(port);
  return options;
}
项目:app-ms    文件:ConfigurationProvider.java   
@Bean
public HttpServerOptions httpServerOptions() {

    return new HttpServerOptions()
        .setCompressionSupported(true)
        .setPort(httpPort);
}
项目:app-ms    文件:SpringTestConfiguration.java   
@Bean
@Primary
public HttpServerOptions httpServerOptions() {

    return new HttpServerOptions()
        .setPort(SocketUtils.findAvailableTcpPort());

}
项目:app-ms    文件:SpringTestConfiguration.java   
@Bean
@Primary
public HttpServerOptions httpServerOptions() {

    return new HttpServerOptions()
        .setPort(SocketUtils.findAvailableTcpPort());

}
项目:moviediary    文件:RestApiRxVerticle.java   
protected final Single<Void> createHttpServer(Router router, String host, int port) {
  return vertx.createHttpServer(new HttpServerOptions()
      .setCompressionSupported(true)
      .setCompressionLevel(3))
              .requestHandler(router::accept)
              .rxListen(port, host)
              .map(server -> null);
}
项目:moviediary    文件:ServerVerticle.java   
/**
 * Creates service for interacting with database.
 * Creates service for interacting with TheMovieDatabase API.
 * Creates service for interacting with bankLink application.
 * Creates service for interacting with mail server.
 * Creates Pac4j security engine configuration.
 * <p>
 * Creates authentication for routes.
 * Creates external API for TheMovieDatabase services.
 * Creates external API for bankLink services.
 * Creates Eventbus (aka Websocket for browsers) addresses for various services.
 * Creates external API for database services.
 * Creates external API for mail services.
 * Creates routes for UI rendering.
 * <p>
 * Starts the HTTP server.
 */
@Override
public void start(Future<Void> future) throws Exception {
  Router router = Router.router(vertx);
  database = createIfMissing(database, () -> DatabaseService.create(vertx, config()));
  tmdb = createIfMissing(tmdb, () -> TmdbService.create(vertx, config(), database));
  omdb = createIfMissing(omdb, () -> OmdbService.create(vertx, config(), database));
  bankLink = createIfMissing(bankLink, () -> BankLinkService.create(vertx, config()));
  mail = createIfMissing(mail, () -> MailService.create(vertx, database));
  recommend = createIfMissing(recommend, () -> RecommendService.create(vertx));
  securityConfig = createIfMissing(securityConfig, () -> new SecurityConfig(vertx, config(), database));
  Arrays.asList(
      new AuthRouter(vertx, config(), securityConfig),
      new TmdbRouter(vertx, tmdb),
      new OmdbRouter(vertx, omdb),
      new BankLinkRouter(vertx, bankLink),
      new DatabaseRouter(vertx, config(), securityConfig, database, mail),
      new MailRouter(vertx, mail),
      new RecommendRouter(recommend),
      new UiRouter(vertx, securityConfig)).forEach(routable -> routable.route(router));
  startEventbus(router, vertx);
  vertx.createHttpServer(new HttpServerOptions()
      .setCompressionSupported(true)
      .setCompressionLevel(3))
      .requestHandler(router::accept)
      .rxListen(config().getInteger(HTTP_PORT, DEFAULT_PORT), config().getString(HTTP_HOST, DEFAULT_HOST))
      .subscribe(res -> future.complete(), future::fail);
}
项目:vertx-zero    文件:DynamicVisitor.java   
@Override
public ConcurrentMap<Integer, HttpServerOptions> visit(final String... key)
        throws ZeroException {
    // 1. Must be the first line, fixed position.
    Ensurer.eqLength(getClass(), 1, (Object[]) key);
    // 2. Visit the node for server
    final JsonObject data = this.NODE.read();

    Fn.flingZero(null == data || !data.containsKey(KEY), LOGGER,
            ServerConfigException.class,
            getClass(), null == data ? null : data.encode());
    // 3. Convert input parameters.
    this.type = ServerType.valueOf(key[Values.IDX]);
    return visit(data.getJsonArray(KEY));
}
项目:vertx-zero    文件:HttpServerVisitor.java   
/**
 * @return Server config to generate HttpServerOptions by port
 * @throws ZeroException ServerConfigException
 */
@Override
public ConcurrentMap<Integer, HttpServerOptions> visit(final String... key)
        throws ZeroException {
    // 1. Must be the first line, fixed position.
    Ensurer.eqLength(getClass(), 0, (Object[]) key);
    // 2. Visit the node for server, http
    final JsonObject data = this.NODE.read();

    Fn.flingZero(null == data || !data.containsKey(KEY), getLogger(),
            ServerConfigException.class,
            getClass(), null == data ? null : data.encode());

    return visit(data.getJsonArray(KEY));
}
项目:vertx-zero    文件:HttpServerVisitor.java   
private ConcurrentMap<Integer, HttpServerOptions> visit(final JsonArray serverData)
        throws ZeroException {
    getLogger().info(Info.INF_B_VERIFY, KEY, getType(), serverData.encode());
    Ruler.verify(KEY, serverData);
    final ConcurrentMap<Integer, HttpServerOptions> map =
            new ConcurrentHashMap<>();
    this.extract(serverData, map);
    getLogger().info(Info.INF_A_VERIFY, KEY, getType(), map.keySet());
    return map;
}
项目:vertx-zero    文件:HttpServerVisitor.java   
protected void extract(final JsonArray serverData, final ConcurrentMap<Integer, HttpServerOptions> map) {
    Fn.itJArray(serverData, JsonObject.class, (item, index) -> {
        if (isServer(item)) {
            // 1. Extract port
            final int port = extractPort(item.getJsonObject(YKEY_CONFIG));
            // 2. Convert JsonObject to HttpServerOptions
            final HttpServerOptions options = this.transformer.transform(item);
            Fn.safeNull(() -> {
                // 3. Add to map;
                map.put(port, options);
            }, port, options);
        }
    });
}
项目:vertx-zero    文件:HttpServerStrada.java   
@Override
public HttpServerOptions transform(final JsonObject input) {
    final JsonObject config = input.getJsonObject(ServerVisitor.YKEY_CONFIG, null);
    return Fn.getSemi(null == config, LOGGER,
            HttpServerOptions::new,
            () -> new HttpServerOptions(config));
}
项目:vertx-zero    文件:ZeroRegistry.java   
public void registryHttp(final String service,
                         final HttpServerOptions options, final Etat etat) {
    final String path = MessageFormat.format(PATH_STATUS, this.etcd.getApplication(),
            EtcdPath.ENDPOINT.toString().toLowerCase(), service,
            Net.getIPv4(), String.valueOf(options.getPort()));
    this.logger.info(Info.ETCD_STATUS, service, etat, path);
    this.etcd.write(path, etat, Values.ZERO);
}
项目:vertx-zero    文件:ZeroApiAgent.java   
private void registryServer(final HttpServerOptions options) {
    final Integer port = options.getPort();
    final AtomicInteger out = API_START_LOGS.get(port);
    if (Values.ZERO == out.getAndIncrement()) {
        final String portLiteral = String.valueOf(port);
        LOGGER.info(Info.API_GATEWAY, getClass().getSimpleName(), deploymentID(),
                portLiteral);
        final String address =
                MessageFormat.format("http://{0}:{1}/",
                        options.getHost(), portLiteral);
        LOGGER.info(Info.API_LISTEN, getClass().getSimpleName(), address);
    }
}
项目:vertx-zero    文件:ZeroHttpAgent.java   
private void registryServer(final HttpServerOptions options,
                            final Router router) {
    final Integer port = options.getPort();
    final AtomicInteger out = ZeroAtomic.HTTP_START_LOGS.get(port);
    if (Values.ZERO == out.getAndIncrement()) {
        // 1. Build logs for current server;
        final String portLiteral = String.valueOf(port);
        LOGGER.info(Info.HTTP_SERVERS, getClass().getSimpleName(), deploymentID(),
                portLiteral);
        final List<Route> routes = router.getRoutes();
        final Map<String, Route> routeMap = new TreeMap<>();

        final Set<String> tree = new TreeSet<>();
        for (final Route route : routes) {
            // 2.Route
            final String path = null == route.getPath() ? "/*" : route.getPath();
            routeMap.put(path, route);
            if (!"/*".equals(path)) {
                tree.add(path);
            }
        }
        routeMap.forEach((path, route) ->
                LOGGER.info(Info.MAPPED_ROUTE, getClass().getSimpleName(), path,
                        route.toString()));
        // 3. Endpoint Publish
        final String address =
                MessageFormat.format("http://{0}:{1}/",
                        Net.getIPv4(), portLiteral);
        LOGGER.info(Info.HTTP_LISTEN, getClass().getSimpleName(), address);
        // 4. Send configuration to Event bus
        final String name = SERVICES.get(port);
        startRegistry(name, options, tree);
    }
}
项目:vertx-zero    文件:ZeroHttpAgent.java   
private void startRegistry(final String name,
                           final HttpServerOptions options,
                           final Set<String> tree) {
    // Enabled micro mode.
    if (EtcdData.enabled()) {
        final JsonObject data = getMessage(name, options, tree);
        // Send Data to Event Bus
        final EventBus bus = this.vertx.eventBus();
        final String address = ID.Addr.REGISTRY_START;
        LOGGER.info(Info.MICRO_REGISTRY_SEND, getClass().getSimpleName(), name, address);
        bus.publish(address, data);
    }
}
项目:vertx-zero    文件:ZeroHttpAgent.java   
private JsonObject getMessage(final String name,
                              final HttpServerOptions options,
                              final Set<String> tree) {
    final JsonObject data = new JsonObject();
    data.put(Registry.NAME, name);
    data.put(Registry.OPTIONS, options.toJson());
    // No Uri
    if (null != tree) {
        data.put(Registry.URIS, StringUtil.join(tree));
    }
    return data;
}
项目:domino    文件:DominoLoader.java   
public void start(Handler<AsyncResult<HttpServer>> serverStartupHandler) {
    ImmutableHttpServerOptions immutableHttpServerOptions = new ImmutableHttpServerOptions();
    VertxContext vertxContext = initializeContext(immutableHttpServerOptions);

    Future<HttpServerOptions> future = Future.future();
    future.setHandler(
            options -> onHttpServerConfigurationCompleted(immutableHttpServerOptions, vertxContext, options,
                    serverStartupHandler));

    configureHttpServer(vertxContext, future);
}
项目:domino    文件:DominoLoader.java   
private void onHttpServerConfigurationCompleted(ImmutableHttpServerOptions immutableHttpServerOptions,
                                                VertxContext vertxContext, AsyncResult<HttpServerOptions> options,
                                                Handler<AsyncResult<HttpServer>> serverStartupHandler) {
    immutableHttpServerOptions.init(options.result(), options.result().getPort(), options.result().getHost());

    new ServerConfigurationLoader(vertxContext).loadModules();

    initStaticResourceHandler();

    if (options.result().isSsl())
        addSecurityHeadersHandler(router);
    vertx.createHttpServer(options.result()).requestHandler(router::accept)
            .listen(options.result().getPort(), serverStartupHandler);
}
项目:domino    文件:DominoLoader.java   
private void configureHttpServer(VertxContext vertxContext, Future<HttpServerOptions> future) {
    HttpServerOptions httpServerOptions = new HttpServerOptions();
    httpServerOptions.setPort(vertxContext.config().getInteger(HTTP_PORT_KEY, DEFAULT_PORT));
    ServiceLoader<HttpServerConfigurator> configurators = ServiceLoader.load(HttpServerConfigurator.class);
    configurators.forEach(c -> c.configureHttpServer(vertxContext, httpServerOptions));
    httpServerOptions.setCompressionSupported(true);

    future.complete(httpServerOptions);
}
项目:domino    文件:JksServerConfigurator.java   
private void enableSsl(ServerConfiguration configuration, HttpServerOptions options) {
    options.setSsl(TRUE);
    options.setHost("localhost");
    options.setKeyStoreOptions(new JksOptions()
            .setPath(getPath(configuration))
            .setPassword(getSecret(configuration)))
            .setPort(getPort(configuration));
}
项目:jTelegramBotAPI    文件:BotMainTest.java   
private BotMainTest(String[] args) throws Exception {
    UpdateProvider provider;

    if (args[1].equalsIgnoreCase("webhooks")) {
        provider = WebhookUpdateProvider.builder()
                .serverOptions(new HttpServerOptions().setSsl(true)
                        .setKeyStoreOptions(new JksOptions().setPath("bot.jks").setPassword("aaaaaa"))
                        .setPort(443)
                        .setHost(args[2]))
                .selfSignedCertificate(new File("bot-certificate.pem"))
                .build();
    } else {
        provider = new PollingUpdateProvider();
    }

    this.registry = TelegramBotRegistry.builder()
            .updateProvider(provider)
            .build();

    registry.registerBot(args[0], (bot, error) -> {
        if (error != null) {
            System.out.println("Could not log in!");
            error.printStackTrace();
            System.exit(-1);
            return;
        }

        this.bot = bot;

        System.out.printf("Logged in as @%s\n", bot.getBotInfo().getUsername());

        registerModules();
        bot.getCommandRegistry().registerCommand(new TextFilter("test", false, this::handleTestCommand));
    });
}
项目:vertx-acme4j    文件:SetupHttpServerOptions.java   
public static HttpServerOptions createHttpServerOptions(DynamicCertOptions dynamicCertOptions, boolean jettyAgentAlreadyLoaded) {
    HttpServerOptions httpOptions = new HttpServerOptions()
            // basic TCP/HTTP options
            .setReuseAddress(true)
            .setCompressionSupported(false) // otherwise it automatically compresses based on response headers even if pre-compressed with e.g. proxy
            .setUsePooledBuffers(true)
            .setSsl(true)
            .setKeyCertOptions(dynamicCertOptions)
            // TLS tuning
            .addEnabledSecureTransportProtocol("TLSv1.2")
            .addEnabledSecureTransportProtocol("TLSv1.3");

    // enable HTTP/2 support if we can..
    if (USE_OPENSSL) {
        // TODO this has not really been tested with SNI yet
        httpOptions
                .setUseAlpn(true)
                .setSslEngineOptions(new OpenSSLEngineOptions());
        cipherSuites.stream().map(SetupHttpServerOptions::javaCipherNameToOpenSSLName)
                .forEach(httpOptions::addEnabledCipherSuite);
    } else {
        httpOptions
                .setUseAlpn(jettyAgentAlreadyLoaded || DynamicAgent.enableJettyAlpn())
                .setJdkSslEngineOptions(new JdkSSLEngineOptions());
        cipherSuites.forEach(httpOptions::addEnabledCipherSuite);
    }

    return httpOptions;
}
项目:etagate    文件:InsideServerVerticle.java   
public void start() throws Exception {

        JsonObject conf = vertx.getOrCreateContext().config();

        HttpServerOptions options =  new HttpServerOptions();
        options.setCompressionSupported(true);      

        HttpServer server = vertx.createHttpServer(options);

        /*
            <property name="inside.host">172.18.7.20</property>
            <property name="inside.port">8999</property>
         */
        String host = conf.getString("inside.host");
        String port = conf.getString("inside.port");        

        if(S.isBlank(host) || S.isBlank(port))
            return;

        // ============初始化======================

        this.upload_dir = conf.getString("upload.dir");

        this.webclient = WebClient.create(vertx);

        this.appContain = gsetting.getAppContain(vertx,this.webclient);

        this.initRoutes();

        server.requestHandler(router::accept);
        server.listen(Integer.parseInt(port), host,ar -> {
            if (ar.succeeded()) {
                log.info("InsideServer listen on " + port);
            } else {
                log.error("InsideServer Failed to start!", ar.cause());
            }
        });     

    }
项目:kiqr    文件:ScalarQueryHttpServerTest.java   
@Before
public void setUp(TestContext context) throws Exception{
    rule.vertx().eventBus().registerDefaultCodec(KeyBasedQuery.class, new KiqrCodec(KeyBasedQuery.class));
    rule.vertx().eventBus().registerDefaultCodec(ScalarKeyValueQueryResponse.class, new KiqrCodec(ScalarKeyValueQueryResponse.class));


    rule.vertx().deployVerticle(new RestKiqrServerVerticle(new HttpServerOptions().setPort(5762), new DummySuccessfulVerticle()), context.asyncAssertSuccess());
}
项目:kiqr    文件:SessionWindowQueryHttpServerTest.java   
@Before
public void setUp(TestContext context) throws Exception{
    rule.vertx().eventBus().registerDefaultCodec(KeyBasedQuery.class, new KiqrCodec(KeyBasedQuery.class));
    rule.vertx().eventBus().registerDefaultCodec(SessionQueryResponse.class, new KiqrCodec<>(SessionQueryResponse.class));

    rule.vertx().deployVerticle(new RestKiqrServerVerticle(new HttpServerOptions().setPort(5762), new DummySuccessfulVerticle()), context.asyncAssertSuccess());
}
项目:kiqr    文件:MultiValuedQueryHttpServerTest.java   
@Before
public void setUp(TestContext context) throws Exception{
    rule.vertx().eventBus().registerDefaultCodec(StoreWideQuery.class, new KiqrCodec(StoreWideQuery.class));
    rule.vertx().eventBus().registerDefaultCodec(RangeKeyValueQuery.class, new KiqrCodec<>(RangeKeyValueQuery.class));
    rule.vertx().eventBus().registerDefaultCodec(MultiValuedKeyValueQueryResponse.class, new KiqrCodec(MultiValuedKeyValueQueryResponse.class));


    rule.vertx().deployVerticle(new RestKiqrServerVerticle(new HttpServerOptions().setPort(5762), new DummySuccessfulVerticle()), context.asyncAssertSuccess());
}