Example usage for io.vertx.core DeploymentOptions DeploymentOptions

List of usage examples for io.vertx.core DeploymentOptions DeploymentOptions

Introduction

In this page you can find the example usage for io.vertx.core DeploymentOptions DeploymentOptions.

Prototype

public DeploymentOptions() 

Source Link

Document

Default constructor

Usage

From source file:co.runrightfast.vertx.demo.modules.OrientDBModule.java

License:Apache License

@Provides(type = Provides.Type.SET)
@Singleton/* w w w .  j  a  v a  2  s  .com*/
public OrientDBRepositoryVerticleDeployment provideEventLogRepositoryDeployment(final AppEventLogger logger) {
    return new OrientDBRepositoryVerticleDeployment(() -> new EventLogRepository(logger),
            EventLogRepository.class, new DeploymentOptions());
}

From source file:co.runrightfast.vertx.demo.modules.RunRightFastVerticleDeploymentModule.java

License:Apache License

@Provides(type = Provides.Type.SET)
@Singleton// w  w  w  .j  av a2 s.c  o  m
public RunRightFastVerticleDeployment provideTestVerticleRunRightFastVerticleDeployment(
        final AppEventLogger logger) {
    return new RunRightFastVerticleDeployment(() -> new TestVerticle(logger), TestVerticle.class,
            new DeploymentOptions().setInstances(2));
}

From source file:co.runrightfast.vertx.demo.modules.RunRightFastVerticleDeploymentModule.java

License:Apache License

@Provides(type = Provides.Type.SET)
@Singleton//  w  ww.j av a2s  .  c o  m
public RunRightFastVerticleDeployment provideTestVerticleParentRunRightFastVerticleDeployment(
        final AppEventLogger logger) {
    return new RunRightFastVerticleDeployment(() -> new TestVerticleParent(logger), TestVerticleParent.class,
            new DeploymentOptions());
}

From source file:co.runrightfast.vertx.orientdb.modules.OrientDBVerticleDeploymentModule.java

License:Apache License

@Provides(type = Provides.Type.SET)
@Singleton/*from  ww  w .j a  va 2  s  .c  o m*/
public RunRightFastVerticleDeployment provideOrientDBVerticleRunRightFastVerticleDeployment(
        final AppEventLogger logger, final EmbeddedOrientDBServiceConfig embeddedOrientDBServiceConfig) {
    return new RunRightFastVerticleDeployment(() -> new OrientDBVerticle(logger, embeddedOrientDBServiceConfig),
            OrientDBVerticle.class, new DeploymentOptions());
}

From source file:co.runrightfast.vertx.orientdb.modules.OrientDBVerticleWithRepositoriesDeploymentModule.java

License:Apache License

@Provides(type = Provides.Type.SET)
@Singleton//from   w  w w. ja  va2s.  c o  m
public RunRightFastVerticleDeployment provideOrientDBVerticleRunRightFastVerticleDeployment(
        final AppEventLogger logger, final EmbeddedOrientDBServiceConfig embeddedOrientDBServiceConfig,
        final Set<OrientDBRepositoryVerticleDeployment> repositoryDeployments) {
    return new RunRightFastVerticleDeployment(
            () -> new OrientDBVerticle(logger, embeddedOrientDBServiceConfig,
                    repositoryDeployments.stream().toArray(OrientDBRepositoryVerticleDeployment[]::new)),
            OrientDBVerticle.class, new DeploymentOptions());
}

From source file:com.ab.main.MainApp.java

/**
 * @param args the command line arguments
 *//*from   w  w w.  j  a va 2  s  .c o m*/
public static void main(String[] args) {

    System.out.println("Vertx webserver started at port 8080");

    Config hazelcastConfig = new Config();

    ClusterManager mgr = new HazelcastClusterManager(hazelcastConfig);

    VertxOptions options = new VertxOptions().setClusterManager(mgr);
    int port = 8081;
    DeploymentOptions depOptions = new DeploymentOptions().setConfig(new JsonObject().put("http.port", port));
    Vertx.clusteredVertx(options, res -> {
        if (res.succeeded()) {
            Vertx vertx = res.result();
            vertx.deployVerticle(new MainVerticle(), depOptions);
            System.out.println("Server started at port " + port + "...");
        } else {
            // failed!
        }
    });
}

From source file:com.chibchasoft.vertx.verticle.deployment.DeploymentConfiguration.java

License:Open Source License

/**
 * Populates this object with the information from the supplied JsonObject
 * @param json The JSON Object/*from w  ww.j  a v  a  2 s  . com*/
 */
public void fromJson(JsonObject json) {
    Objects.requireNonNull(json, "json is required");
    if (json.getValue("name") instanceof String)
        setName((String) json.getValue("name"));
    if (json.getValue("deploymentOptions") instanceof JsonObject) {
        setDeploymentOptions(new DeploymentOptions());
        DeploymentOptionsConverter.fromJson((JsonObject) json.getValue("deploymentOptions"),
                this.getDeploymentOptions());
    }
    if (json.getValue("dependents") instanceof JsonArray) {
        json.getJsonArray("dependents").forEach(item -> {
            if (item instanceof JsonObject) {
                DependentsDeployment deps = new DependentsDeployment();
                deps.fromJson((JsonObject) item);
                getDependents().add(deps);
            }
        });
    }
}

From source file:com.cisco.ef.VertxMain.java

@Override
public void start() throws Exception {

    /* Vertx HTTP Server. */
    final io.vertx.core.http.HttpServer vertxHttpServer = this.getVertx().createHttpServer();

    /* Route one call to a vertx handler. */
    final Router router = createRouterAndVertxOnlyRoute();

    final HttpServer httpServer = getHttpServerAndRoutes(vertxHttpServer, router);

    systemManager = managedServiceBuilder.getSystemManager();

    managedServiceBuilder.addEndpointService(new EventHandleService());
    //        managedServiceBuilder.addEndpointService(new OauthService(vertx));

    /*/*from  w w w.j  a v  a  2 s . c  om*/
    * Create and start new service endpointServer.
    */
    managedServiceBuilder.getEndpointServerBuilder().setHttpServer(httpServer).build().startServer();

    /*
     * Associate the router as a request handler for the vertxHttpServer.
     */
    vertxHttpServer.requestHandler(router::accept).listen(managedServiceBuilder.getPort());

    logger.info("[Client Credential flow] started...");

    OAuth2Auth oauth2 = OAuth2Auth.create(vertx, OAuth2FlowType.CLIENT,
            new JsonObject().put("clientID", "f4f9ea5a8e2fe081f337")
                    .put("clientSecret", "df8aadec3990f219b9326b67a0c7506356d14215")
                    .put("site", "https://github.com/login").put("tokenPath", "/oauth/access_token")
                    .put("authorizationPath", "/oauth/authorize")

    );

    JsonObject tokenConfig = new JsonObject();

    // Callbacks
    // Save the access token
    oauth2.getToken(tokenConfig, res -> {
        if (res.failed()) {
            logger.info("[Access Token Error]: " + res.cause().getMessage());
        } else {
            // Get the access token object (the authorization code is given from the previous step).
            AccessToken token = res.result();
            logger.info("[Access Token SUCCESS]: principal => " + token.principal().encodePrettily());
            logger.info("[Access Token SUCCESS]: expired => " + token.expired());
        }
    });

    //        vertx.deployVerticle("com.cisco.ef.service.OauthService");
    vertx.deployVerticle("com.cisco.ef.service.ConsulService", new DeploymentOptions().setWorker(true));
    //        DsaService dsaService = new DsaService();
    //        dsaService.start();

}

From source file:com.ddp.SimpleREST.java

License:Open Source License

public static void main(String argv[]) {

    VertxOptions options = new VertxOptions().setBlockedThreadCheckInterval(200000000);
    options.setClustered(true);//  w  ww  .j  a v  a  2  s .c o  m

    Vertx.clusteredVertx(options, res -> {
        if (res.succeeded()) {
            Vertx vertx = res.result();
            final JsonObject js = new JsonObject();
            vertx.fileSystem().readFile("app-conf.json", result -> {
                if (result.succeeded()) {
                    Buffer buff = result.result();
                    js.mergeIn(new JsonObject(buff.toString()));
                    initConfig(js);
                    DeploymentOptions deploymentOptions = new DeploymentOptions().setConfig(js)
                            .setMaxWorkerExecuteTime(5000).setWorker(true).setWorkerPoolSize(5);
                    vertx.deployVerticle(SimpleREST.class.getName(), deploymentOptions);
                } else {
                    System.err.println("Oh oh ..." + result.cause());
                }
            });

        }
    });
}

From source file:com.dinstone.vertx.starter.config.VertxManageAutoConfiguration.java

License:Apache License

@EventListener
public void deployVerticles(ApplicationReadyEvent event) throws Exception {
    DeploymentOptions deployOptions = new DeploymentOptions();
    deployOptions.setInstances(restProperties.getInstances());
    String verticleName = verticleFactory.verticleName(HttpRestVerticle.class);
    VertxHelper.deployVerticle(vertx, deployOptions, verticleFactory, verticleName);
}