}); try { verticleHolder.verticle.stop(stopFuture); } catch (Throwable t) { stopFuture.fail(t);
@Override public void init(Vertx vertx, Context context) { delegateVerticle.init(vertx, context); }
@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()); } }); }
/** * Override this method to signify that start is complete sometime _after_ the start() method has returned * This is useful if your verticle deploys other verticles or modules and you don't want this verticle to * be considered started until the other modules and verticles have been started. * * @param startedResult When you are happy your verticle is started set the result * @throws Exception */ @Override public void start(Future<Void> startedResult) throws Exception { // Start the real verticle realVerticle.start(startedResult); }
@Override public Vertx getVertx() { return delegateVerticle.getVertx(); }
private Verticle createVerticle(final Class<?> clazz, ClassLoader classLoader) throws Exception { if (clazz.isAnnotationPresent(SpringVerticle.class)) { return createSpringVerticle(clazz, classLoader); } else if (Verticle.class.isAssignableFrom(clazz)) { // init a non spring verticle, but this should not happen final Verticle verticle = Verticle.class.cast(clazz.newInstance()); verticle.init(vertx, vertx.getOrCreateContext()); return verticle; } return null; }
/** * Override this method to signify that start is complete sometime _after_ the start() method has returned * This is useful if your verticle deploys other verticles or modules and you don't want this verticle to * be considered started until the other modules and verticles have been started. * * @param startedResult When you are happy your verticle is started set the result * @throws Exception */ @Override public void start(Future<Void> startedResult) throws Exception { // Start the real verticle realVerticle.start(startedResult); }
/** * 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()); }
/** * Initialise the verticle.<p> * This is called by Vert.x when the verticle instance is deployed. Don't call it yourself. * * @param vertx the deploying Vert.x instance * @param context the context of the verticle */ @Override public void init(Vertx vertx, Context context) { super.init(vertx, context); try { // Create the real verticle and init realVerticle = createRealVerticle(); realVerticle.init(vertx, context); } catch (Throwable t) { if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new RuntimeException(t); } }
}); try { verticleHolder.verticle.stop(stopFuture); } catch (Throwable t) { stopFuture.fail(t);
/** * Override this method to signify that start is complete sometime _after_ the start() method has returned * This is useful if your verticle deploys other verticles or modules and you don't want this verticle to * be considered started until the other modules and verticles have been started. * * @param startedResult When you are happy your verticle is started set the result * @throws Exception */ @Override public void start(Future<Void> startedResult) throws Exception { // Start the real verticle realVerticle.start(startedResult); }
@DocAnnotation$annotation$(description = " When you add a new route with a regular expression, you can add named capture groups for parameters. <br/>\n However, if you need more complex parameters names (like \"param_name\"), you can add parameters names with\n this function. You have to name capture groups in regex with names: \"p0\", \"p1\", \"p2\", ... <br/>\n <br/>\n For example: If you declare route with regex \\/(?<p0>[a-z]*)\\/(?<p1>[a-z]*) and group names ") @Override public void start(Future<Void> startFuture) throws Exception { ClassLoader loader = module.runner.getModuleClassLoader(); Method introspector = loader.loadClass("io.vertx.ceylon.core.impl.resolveVerticles_").getDeclaredMethod("resolveVerticles", String.class, String.class); Map<String, Callable<?>> moduleFactories = (Map<String, Callable<?>>) introspector.invoke(null, module.name, null); Callable<?> factory = moduleFactories.values().iterator().next(); verticle = (Verticle) factory.call(); verticle.init(vertx, context); verticle.start(startFuture); }
/** * Initialise the verticle.<p> * This is called by Vert.x when the verticle instance is deployed. Don't call it yourself. * * @param vertx the deploying Vert.x instance * @param context the context of the verticle */ @Override public void init(Vertx vertx, Context context) { super.init(vertx, context); try { // Create the real verticle and init realVerticle = createRealVerticle(); realVerticle.init(vertx, context); } catch (Throwable t) { if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new RuntimeException(t); } }
@Override public void stop(Future<Void> stopFuture) throws Exception { delegateVerticle.stop(stopFuture); } }
/** * Initialise the verticle.<p> * This is called by Vert.x when the verticle instance is deployed. Don't call it yourself. * * @param vertx the deploying Vert.x instance * @param context the context of the verticle */ @Override public void init(Vertx vertx, Context context) { super.init(vertx, context); try { // Create the real verticle and init realVerticle = createRealVerticle(); realVerticle.init(vertx, context); } catch (Throwable t) { if (t instanceof RuntimeException) { throw (RuntimeException) t; } throw new RuntimeException(t); } }
/** * Vert.x calls the stop method when the verticle is undeployed. * Put any cleanup code for your verticle in here * * @throws Exception */ @Override public void stop(Future<Void> stopFuture) throws Exception { // Stop the real verticle if (realVerticle != null) { realVerticle.stop(stopFuture); realVerticle = null; } }
/** * Vert.x calls the stop method when the verticle is undeployed. * Put any cleanup code for your verticle in here * * @throws Exception */ @Override public void stop(Future<Void> stopFuture) throws Exception { // Stop the real verticle if (realVerticle != null) { realVerticle.stop(stopFuture); realVerticle = null; } }
@Override public void stop(Future<Void> stopFuture) throws Exception { try { verticle.stop(stopFuture); } finally { module.removeInstance(); } } }