@Override public void start(Future<Void> startFuture) throws Exception { Weld weld = this.weld != null ? this.weld : createDefaultWeld(); if (weld.getContainerId() == null) { weld.containerId(deploymentID()); } weld.addExtension(new VertxExtension(vertx, context)); configureWeld(weld); // Bootstrap can take some time to complete vertx.executeBlocking(future -> { try { this.weldContainer = weld.initialize(); future.complete(); } catch (Exception e) { future.fail(e); } }, result -> { if (result.succeeded()) { LOGGER.info("Weld verticle started for deployment {0}", deploymentID()); startFuture.complete(); } else { startFuture.fail(result.cause()); } }); }
@Override public void start(Future<Void> startFuture) throws Exception { Weld weld = this.weld != null ? this.weld : createDefaultWeld(); if (weld.getContainerId() == null) { weld.containerId(deploymentID()); } weld.addExtension(new VertxExtension(vertx, context)); configureWeld(weld); // Bootstrap can take some time to complete vertx.executeBlocking(future -> { try { this.weldContainer = weld.initialize(); future.complete(); } catch (Exception e) { future.fail(e); } }, result -> { if (result.succeeded()) { LOGGER.info("Weld verticle started for deployment {0}", deploymentID()); startFuture.complete(); } else { startFuture.fail(result.cause()); } }); }
weld.addExtension(new VertxExtension()); weld.initialize();
@Test public void testConsumers() throws InterruptedException { try (WeldContainer weld = new Weld().disableDiscovery().addExtension(new VertxExtension()).addPackage(false, RegisterConsumersAfterBootstrapTest.class) .initialize()) { Vertx vertx = Vertx.vertx(); try { weld.select(VertxExtension.class).get().registerConsumers(vertx, weld.event()); vertx.eventBus().send(HelloObserver.HELLO_ADDRESS, "hello"); assertEquals("hello", SYNCHRONIZER.poll(Timeouts.DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS)); } finally { vertx.close(); } } }