@Override public Vertx getVertx() { return delegateVerticle.getVertx(); }
/** * Creates a Yoke instance. * * This constructor should be called from a verticle and pass a valid Vertx instance. This instance will be shared * with all registered middleware. The reason behind this is to allow middleware to use Vertx features such as file * system and timers. * * <pre> * public class MyVerticle extends AbstractVerticle { * public void start() { * final Yoke yoke = new Yoke(this); * ... * } * } * </pre> * * @param verticle the main verticle */ public Yoke(@NotNull Verticle verticle) { this(verticle.getVertx()); }
@Override public void start(Future<Void> startFuture) throws Exception { // compile TypeScript source when verticle is started delegateVerticle.getVertx().executeBlocking((Future<Void> future) -> { // create a new class loader that automatically compiles sources ClassLoader cl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(new TypeScriptClassLoader( cl, getTypeScriptCompiler(), CACHE)); // start the JavaScript verticle. this will trigger loading and compiling. try { delegateVerticle.start(future); } catch (Exception e) { future.fail(e); } finally { Thread.currentThread().setContextClassLoader(cl); } }, res -> { if (res.succeeded()) { startFuture.complete(); } else { startFuture.fail(res.cause()); } }); }