Example usage for io.vertx.core.spi VerticleFactory prefix

List of usage examples for io.vertx.core.spi VerticleFactory prefix

Introduction

In this page you can find the example usage for io.vertx.core.spi VerticleFactory prefix.

Prototype

String prefix();

Source Link

Usage

From source file:org.wisdom.framework.vertx.WisdomVertxServer.java

License:Apache License

/**
 * Starts the servers (HTTP and HTTPS).//from  w  ww  .  ja v  a 2  s.c  o m
 * The actual start is asynchronous.
 */
@Validate
public synchronized void start() {

    LOGGER.info("Starting the vert.x server");

    // Check whether we have a specific vertx configuration, if not try the global one, and if not use default.
    int httpPort = accessor.getConfiguration().getIntegerWithDefault("vertx.http.port",
            accessor.getConfiguration().getIntegerWithDefault(ApplicationConfiguration.HTTP_PORT, 9000));
    int httpsPort = accessor.getConfiguration().getIntegerWithDefault("vertx.https.port",
            accessor.getConfiguration().getIntegerWithDefault(ApplicationConfiguration.HTTPS_PORT, -1));

    initializeInetAddress();

    // Parse server configuration if any
    Configuration servers = configuration.getConfiguration("vertx.servers");
    if (servers == null) {
        if (httpPort != -1) {
            LOGGER.info("Configuring default HTTP Server");
            this.servers.add(Server.defaultHttp(accessor, vertx));
        }
        if (httpsPort != -1) {
            LOGGER.info("Configuring default HTTPS Server");
            this.servers.add(Server.defaultHttps(accessor, vertx));
        }
    } else {
        // Custom configuration
        for (String name : servers.asMap().keySet()) {
            LOGGER.info("Configuring server {}", name);
            this.servers.add(Server.from(accessor, vertx, name, servers.getConfiguration(name)));
        }
    }

    // Check whether or not the wisdom-internal verticle factory is already registered
    boolean found = false;
    for (VerticleFactory factory : vertx.verticleFactories()) {
        if (factory.prefix().equalsIgnoreCase("wisdom-internal")) {
            found = true;
        }
    }

    if (!found) {
        vertx.registerVerticleFactory(new WisdomInternalVerticleFactory(accessor, this.servers));
    }

    vertx.runOnContext(v -> vertx.deployVerticle("wisdom-internal:wisdom", ar -> {
        LOGGER.info("Wisdom verticle deployed : " + ar.result());
        deploymentId = ar.result();
    }));
}