vertx/src/main/java/eu/internetofus/common/vertx/AbstractMain.java
/**
   * Load the configuration, start the VertX and deploy the main verticle.
   *
   * @return the promise of the started Vert.x if it can be started.
   */
Load the configuration, start the VertX and deploy the main verticle.
@return the promise of the started Vert.x if it can be started.
Load the configuration start the VertX and deploy the main verticle . @return the promise of the started Vert . x if it can be started .
public Future<WeNetModuleContext> startVertx() {
    final Promise<WeNetModuleContext> promise = Promise.promise();
    final var vertx = Vertx.vertx();
    final var retriever = ConfigRetriever.create(vertx, this.retrieveOptions);
    retriever.getConfig(confResult -> {
      if (confResult.succeeded()) {
        final var conf = confResult.result();
        vertx.close();
        Logger.info("Loaded configuration: {}", conf);
        if (conf.getBoolean(STORE_EFFECTIVE_CONFIGURATION, Boolean.TRUE)) {
          try {
            final var effectiveConf = FileSystems.getDefault()
                .getPath(conf.getString(EFFECTIVE_CONFIGURATION_PATH, DEFAULT_EFFECTIVE_CONFIGURATION_PATH));
            Files.write(effectiveConf, conf.encodePrettily().getBytes());
            Logger.info("Stored effective configuration at '{}'", effectiveConf);
          } catch (final Throwable throwable) {
            Logger.error(throwable, "Cannot store the effective configuration");
          }
        }
        final var options = new VertxOptions(conf);
        final var newVertx = Vertx.vertx(options);
        final var deployOptions = new DeploymentOptions().setConfig(conf);
        newVertx.deployVerticle(this.createMainVerticle(), deployOptions, deploy -> {
          if (deploy.succeeded()) {
            promise.complete(new WeNetModuleContext(newVertx, conf));
          } else {
            promise.fail(deploy.cause());
            newVertx.close();
          }
        });
      } else {
        promise.fail(confResult.cause());
      }
    });
    return promise.future();
  }
public Future < WeNetModuleContext > startVertx ( ) { final Promise < WeNetModuleContext > promise = Promise . promise ( ) ; final var vertx = Vertx . vertx ( ) ; final var retriever = ConfigRetriever . create ( vertx , this . retrieveOptions ) ; retriever . getConfig ( confResult -> { if ( confResult . succeeded ( ) ) { final var conf = confResult . result ( ) ; vertx . close ( ) ; Logger . info ( "Loaded configuration: {}" , conf ) ; if ( conf . getBoolean ( STORE_EFFECTIVE_CONFIGURATION , Boolean . TRUE ) ) { try { final var effectiveConf = FileSystems . getDefault ( ) . getPath ( conf . getString ( EFFECTIVE_CONFIGURATION_PATH , DEFAULT_EFFECTIVE_CONFIGURATION_PATH ) ) ; Files . write ( effectiveConf , conf . encodePrettily ( ) . getBytes ( ) ) ; Logger . info ( "Stored effective configuration at '{}'" , effectiveConf ) ; } catch ( final Throwable throwable ) { Logger . error ( throwable , "Cannot store the effective configuration" ) ; } } final var options = new VertxOptions ( conf ) ; final var newVertx = Vertx . vertx ( options ) ; final var deployOptions = new DeploymentOptions ( ) . setConfig ( conf ) ; newVertx . deployVerticle ( this . createMainVerticle ( ) , deployOptions , deploy -> { if ( deploy . succeeded ( ) ) { promise . complete ( new WeNetModuleContext ( newVertx , conf ) ) ; } else { promise . fail ( deploy . cause ( ) ) ; newVertx . close ( ) ; } } ) ; } else { promise . fail ( confResult . cause ( ) ) ; } } ) ; return promise . future ( ) ; }
Load the configuration, start the VertX and deploy the main verticle.
Load the configuration start the VertX and deploy the main verticle .
// Create a new Vert.x instance using the retrieve configuration // Deploy the verticles