use of org.jboss.resteasy.plugins.server.vertx.VertxResteasyDeployment in project vertx-examples by vert-x3.
the class Server method start.
@Override
public void start() throws Exception {
// Build the Jax-RS controller deployment
VertxResteasyDeployment deployment = new VertxResteasyDeployment();
deployment.start();
deployment.getRegistry().addPerInstanceResource(Controller.class);
// Start the front end server using the Jax-RS controller
vertx.createHttpServer().requestHandler(new VertxRequestHandler(vertx, deployment)).listen(8080, ar -> {
System.out.println("Server started on port " + ar.result().actualPort());
});
}
use of org.jboss.resteasy.plugins.server.vertx.VertxResteasyDeployment in project vertx-examples by vert-x3.
the class Server method start.
@Override
public void start() throws Exception {
// Build the Jax-RS hello world deployment
VertxResteasyDeployment deployment = new VertxResteasyDeployment();
deployment.start();
deployment.getRegistry().addPerInstanceResource(HelloWorldService.class);
// Start the front end server using the Jax-RS controller
vertx.createHttpServer().requestHandler(new VertxRequestHandler(vertx, deployment)).listen(8080, ar -> {
System.out.println("Server started on port " + ar.result().actualPort());
});
}
use of org.jboss.resteasy.plugins.server.vertx.VertxResteasyDeployment in project atomix by atomix.
the class VertxRestService method start.
@Override
public CompletableFuture<RestService> start() {
server = vertx.createHttpServer();
deployment = new VertxResteasyDeployment();
deployment.start();
deployment.getDispatcher().getDefaultContextObjects().put(ClusterMembershipService.class, atomix.getMembershipService());
deployment.getDispatcher().getDefaultContextObjects().put(ClusterCommunicationService.class, atomix.getCommunicationService());
deployment.getDispatcher().getDefaultContextObjects().put(ClusterEventService.class, atomix.getEventService());
deployment.getDispatcher().getDefaultContextObjects().put(PrimitiveFactory.class, atomix.getPrimitivesService());
deployment.getDispatcher().getDefaultContextObjects().put(PrimitivesService.class, atomix.getPrimitivesService());
deployment.getDispatcher().getDefaultContextObjects().put(EventManager.class, new EventManager());
deployment.getDispatcher().getDefaultContextObjects().put(AtomixRegistry.class, atomix.getRegistry());
final ClassLoader classLoader = atomix.getClass().getClassLoader();
final String[] whitelistPackages = StringUtils.split(System.getProperty("io.atomix.whitelistPackages"), ",");
final ClassGraph classGraph = whitelistPackages != null ? new ClassGraph().enableAnnotationInfo().whitelistPackages(whitelistPackages).addClassLoader(classLoader) : new ClassGraph().enableAnnotationInfo().addClassLoader(classLoader);
try (final ScanResult scanResult = classGraph.scan()) {
scanResult.getClassesWithAnnotation(AtomixResource.class.getName()).forEach(classInfo -> {
deployment.getRegistry().addPerInstanceResource(classInfo.loadClass(), "/v1");
});
}
deployment.getDispatcher().getProviderFactory().register(new JacksonProvider(createObjectMapper()));
server.requestHandler(new VertxRequestHandler(vertx, deployment));
CompletableFuture<RestService> future = new CompletableFuture<>();
server.listen(address.port(), address.address(true).getHostAddress(), result -> {
if (result.succeeded()) {
open.set(true);
LOGGER.info("Started");
future.complete(this);
} else {
future.completeExceptionally(result.cause());
}
});
return future;
}
Aggregations