private VerticleHolder getVerticleHolder() { Context context = vertx.getContext(); if (context != null) { VerticleHolder holder = (VerticleHolder) context.getDeploymentHandle(); return holder; } else { return null; } }
// Must be synchronized since called directly from different thread private void addVerticle(Deployment deployment, Verticle verticle, VerticleFactory factory) { String loggerName = "org.vertx.deployments." + deployment.name + "-" + deployment.verticles.size(); Logger logger = LoggerFactory.getLogger(loggerName); Context context = vertx.getContext(); VerticleHolder holder = new VerticleHolder( deployment, context, verticle, loggerName, logger, deployment.config, factory); deployment.verticles.add(holder); context.setDeploymentHandle(holder); }
private Handler<String> wrapDoneHandler(final Handler<String> doneHandler) { if (doneHandler == null) { return null; } final Context context = vertx.getContext(); return new Handler<String>() { @Override public void handle(final String deploymentID) { if (context == null) { doneHandler.handle(deploymentID); } else { context.execute( new Runnable() { public void run() { doneHandler.handle(deploymentID); } }); } } }; }
// We calculate a path adjustment that can be used by the fileSystem object // so that the *effective* working directory can be the module directory // this allows moduleRefs to read and write the file system as if they were // in the module dir, even though the actual working directory will be // wherever vertx run or vertx start was called from private void setPathAdjustment(File modDir) { Path cwd = Paths.get(".").toAbsolutePath().getParent(); Path pmodDir = Paths.get(modDir.getAbsolutePath()); Path relative = cwd.relativize(pmodDir); vertx.getContext().setPathAdjustment(relative); }