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


Java VertxRequestHandler类代码示例

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


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

示例1: createSecureServer

import org.jboss.resteasy.plugins.server.vertx.VertxRequestHandler; //导入依赖的package包/类
private void createSecureServer(VertxRequestHandler requestHandler, Future<Void> startPromise) {
    if (new File(certDir).exists()) {
        HttpServerOptions options = new HttpServerOptions();
        File keyFile = new File(certDir, "tls.key");
        File certFile = new File(certDir, "tls.crt");
        log.info("Loading key from " + keyFile.getAbsolutePath() + ", cert from " + certFile.getAbsolutePath());
        options.setKeyCertOptions(new PemKeyCertOptions()
                .setKeyPath(keyFile.getAbsolutePath())
                .setCertPath(certFile.getAbsolutePath()));
        options.setSsl(true);

        httpsServer = vertx.createHttpServer(options)
                .requestHandler(requestHandler)
                .listen(SECURE_PORT, ar -> {
                    if (ar.succeeded()) {
                        log.info("Started HTTPS server. Listening on port " + SECURE_PORT);
                        startPromise.complete();
                    } else {
                        log.info("Error starting HTTPS server");
                        startPromise.fail(ar.cause());
                    }
                });
    } else {
        startPromise.complete();
    }
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:27,代码来源:HTTPServer.java

示例2: createOpenServer

import org.jboss.resteasy.plugins.server.vertx.VertxRequestHandler; //导入依赖的package包/类
private void createOpenServer(VertxRequestHandler requestHandler, Future<Void> startPromise) {
    httpServer = vertx.createHttpServer()
            .requestHandler(requestHandler)
            .listen(PORT, ar -> {
                if (ar.succeeded()) {
                    log.info("Started HTTP server. Listening on port " + PORT);
                    startPromise.complete();
                } else {
                    log.info("Error starting HTTP server");
                    startPromise.fail(ar.cause());
                }
            });
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:14,代码来源:HTTPServer.java

示例3: start

import org.jboss.resteasy.plugins.server.vertx.VertxRequestHandler; //导入依赖的package包/类
@Override
public CompletableFuture<RestService> start() {
  server = vertx.createHttpServer();
  deployment = new VertxResteasyDeployment();
  deployment.start();

  deployment.getDispatcher().getDefaultContextObjects()
      .put(ClusterService.class, atomix.clusterService());
  deployment.getDispatcher().getDefaultContextObjects()
      .put(ClusterMessagingService.class, atomix.messagingService());
  deployment.getDispatcher().getDefaultContextObjects()
      .put(ClusterEventingService.class, atomix.eventingService());
  deployment.getDispatcher().getDefaultContextObjects()
      .put(PrimitivesService.class, atomix.primitivesService());
  deployment.getDispatcher().getDefaultContextObjects()
      .put(PrimitiveCache.class, new PrimitiveCache(atomix.primitivesService(), PRIMITIVE_CACHE_SIZE));
  deployment.getDispatcher().getDefaultContextObjects()
      .put(EventManager.class, new EventManager());

  deployment.getRegistry().addPerInstanceResource(ClusterResource.class);
  deployment.getRegistry().addPerInstanceResource(EventsResource.class);
  deployment.getRegistry().addPerInstanceResource(MessagesResource.class);
  deployment.getRegistry().addPerInstanceResource(PrimitivesResource.class);

  server.requestHandler(new VertxRequestHandler(vertx, deployment));

  CompletableFuture<RestService> future = new CompletableFuture<>();
  server.listen(endpoint.port(), endpoint.host().getHostAddress(), result -> {
    if (result.succeeded()) {
      open.set(true);
      LOGGER.info("Started");
      future.complete(this);
    } else {
      future.completeExceptionally(result.cause());
    }
  });
  return future;
}
 
开发者ID:atomix,项目名称:atomix,代码行数:39,代码来源:VertxRestService.java

示例4: start

import org.jboss.resteasy.plugins.server.vertx.VertxRequestHandler; //导入依赖的package包/类
@Override
public void start(Future<Void> startFuture) {
    Future<Void> superFuture = Future.future();
    Future<HttpServer> listenFuture = Future.future();
    super.start(superFuture);

    CompositeFuture.all(superFuture, listenFuture)
        .setHandler(compositeResult -> {
            if (compositeResult.succeeded()) {
                startFuture.complete(null);
            } else {
                startFuture.fail(compositeResult.cause());
            }
        });

    VertxResteasyDeployment deployment = new VertxResteasyDeployment();
    deployment.start();

    addResources(deployment.getRegistry(),
            new SystemResourceImpl(apimanConfig, engine),
            new ApiResourceImpl(apimanConfig, engine),
            new ClientResourceImpl(apimanConfig, engine),
            new OrgResourceImpl(apimanConfig, engine));

    deployment.getProviderFactory().register(RestExceptionMapper.class);

    VertxRequestHandler resteasyRh = new VertxRequestHandler(vertx, deployment);

    Router router = Router.router(vertx)
                .exceptionHandler(error -> log.error(error.getMessage(), error));

    // Ensure body handler is attached early so that if AuthHandler takes an external action
    // we don't end up losing the body (e.g OAuth2).
    router.route()
        .handler(BodyHandler.create());

    AuthHandler authHandler = AuthFactory.getAuth(vertx, router, apimanConfig);

    router.route("/*")
        .handler(authHandler);

    router.route("/*") // We did the previous stuff, now we call into JaxRS.
        .handler(context -> resteasyRh.handle(new Router2ResteasyRequestAdapter(context)));

    HttpServerOptions httpOptions = new HttpServerOptions();

    if (apimanConfig.isSSL()) {
        httpOptions.setSsl(true)
        .setKeyStoreOptions(
                new JksOptions()
                    .setPath(apimanConfig.getKeyStore())
                    .setPassword(apimanConfig.getKeyStorePassword())
                )
        .setTrustStoreOptions(
                new JksOptions()
                    .setPath(apimanConfig.getTrustStore())
                    .setPassword(apimanConfig.getTrustStorePassword())
                );
    } else {
        log.warn("API is running in plaintext mode. Enable SSL in config for production deployments.");
    }

    vertx.createHttpServer(httpOptions)
        .requestHandler(router::accept)
        .listen(apimanConfig.getPort(VERTICLE_TYPE),
                apimanConfig.getHostname(),
                listenFuture.completer());
}
 
开发者ID:apiman,项目名称:apiman,代码行数:69,代码来源:ApiVerticle.java

示例5: start

import org.jboss.resteasy.plugins.server.vertx.VertxRequestHandler; //导入依赖的package包/类
@Override
public void start(Future<Void> startPromise) {
    VertxResteasyDeployment deployment = new VertxResteasyDeployment();
    deployment.start();

    deployment.getProviderFactory().registerProvider(DefaultExceptionMapper.class);
    deployment.getProviderFactory().registerProvider(JacksonConfig.class);

    if (enableRbac) {
        log.info("Enabling RBAC for REST API");
        deployment.getProviderFactory().registerProviderInstance(new AuthInterceptor(kubernetes));
    } else {
        log.info("Disabling authentication and authorization for REST API");
        deployment.getProviderFactory().registerProviderInstance(new AllowAllAuthInterceptor());
    }

    deployment.getRegistry().addSingletonResource(new SwaggerSpecEndpoint());
    deployment.getRegistry().addSingletonResource(new HttpAddressService(addressSpaceApi));
    deployment.getRegistry().addSingletonResource(new HttpSchemaService());
    deployment.getRegistry().addSingletonResource(new HttpAddressSpaceService(addressSpaceApi, kubernetes.getNamespace()));
    deployment.getRegistry().addSingletonResource(new HttpHealthService());
    deployment.getRegistry().addSingletonResource(new HttpV1RootService());
    deployment.getRegistry().addSingletonResource(new HttpRootService());
    deployment.getRegistry().addSingletonResource(new HttpAddressRootService(addressSpaceApi));

    deployment.getRegistry().addSingletonResource(new OSBCatalogService(addressSpaceApi, kubernetes.getNamespace()));
    deployment.getRegistry().addSingletonResource(new OSBProvisioningService(addressSpaceApi, kubernetes.getNamespace()));
    deployment.getRegistry().addSingletonResource(new OSBBindingService(addressSpaceApi, kubernetes.getNamespace()));
    deployment.getRegistry().addSingletonResource(new OSBLastOperationService(addressSpaceApi, kubernetes.getNamespace()));

    VertxRequestHandler requestHandler = new VertxRequestHandler(vertx, deployment);

    Future<Void> secureReady = Future.future();
    Future<Void> openReady = Future.future();
    CompositeFuture readyFuture = CompositeFuture.all(secureReady, openReady);
    readyFuture.setHandler(result -> {
        if (result.succeeded()) {
            startPromise.complete();
        } else {
            startPromise.fail(result.cause());
        }
    });

    createSecureServer(requestHandler, secureReady);
    createOpenServer(requestHandler, openReady);
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:47,代码来源:HTTPServer.java


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