本文整理汇总了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();
}
}
示例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());
}
});
}
示例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;
}
示例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());
}
示例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);
}