Skip to content

Commit

Permalink
More verticle base
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Nov 7, 2024
1 parent a037521 commit babc75d
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class DeployShell extends AbstractVerticle {
public class DeployShell extends VerticleBase {

public static void main(String[] args) {
Launcher launcher = new Launcher() {
Expand All @@ -20,7 +20,7 @@ public void beforeStartingVertx(VertxOptions options) {
}

@Override
public void start(Promise<Void> startPromise) {
public Future<?> start() {
JsonObject options = new JsonObject().put("httpOptions",
new JsonObject().
put("host", "localhost").
Expand All @@ -30,12 +30,6 @@ public void start(Promise<Void> startPromise) {
.put("config", new JsonObject()
.put("file", "io/vertx/example/shell/deploy_service_http/auth.properties"))));

vertx.deployVerticle("service:io.vertx.ext.shell", new DeploymentOptions().setConfig(options)).onComplete(ar -> {
if (ar.succeeded()) {
startPromise.complete();
} else {
startPromise.fail(ar.cause());
}
});
return vertx.deployVerticle("service:io.vertx.ext.shell", new DeploymentOptions().setConfig(options));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class DeployShell extends AbstractVerticle {
public class DeployShell extends VerticleBase {

public static void main(String[] args) {
Launcher launcher = new Launcher() {
Expand All @@ -20,7 +20,7 @@ public void beforeStartingVertx(VertxOptions options) {
}

@Override
public void start(Promise<Void> startPromise) {
public Future<?> start() {
JsonObject options = new JsonObject().put("sshOptions",
new JsonObject().
put("host", "localhost").
Expand All @@ -35,12 +35,6 @@ public void start(Promise<Void> startPromise) {

)
);
vertx.deployVerticle("service:io.vertx.ext.shell", new DeploymentOptions().setConfig(options)).onComplete(ar -> {
if (ar.succeeded()) {
startPromise.complete();
} else {
startPromise.fail(ar.cause());
}
});
return vertx.deployVerticle("service:io.vertx.ext.shell", new DeploymentOptions().setConfig(options));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class DeployShell extends AbstractVerticle {
public class DeployShell extends VerticleBase {

public static void main(String[] args) {
Launcher launcher = new Launcher() {
Expand All @@ -20,18 +20,12 @@ public void beforeStartingVertx(VertxOptions options) {
}

@Override
public void start(Promise<Void> startPromise) {
public Future<?> start() {
JsonObject options = new JsonObject().put("telnetOptions",
new JsonObject().
put("host", "localhost").
put("port", 3000)
);
vertx.deployVerticle("service:io.vertx.ext.shell", new DeploymentOptions().setConfig(options)).onComplete(ar -> {
if (ar.succeeded()) {
startPromise.complete();
} else {
startPromise.fail(ar.cause());
}
});
return vertx.deployVerticle("service:io.vertx.ext.shell", new DeploymentOptions().setConfig(options));
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.vertx.example.shell.echokeyboard;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Launcher;
import io.vertx.core.VertxOptions;
import io.vertx.core.*;
import io.vertx.ext.dropwizard.DropwizardMetricsOptions;
import io.vertx.ext.shell.ShellService;
import io.vertx.ext.shell.ShellServiceOptions;
Expand All @@ -14,7 +12,7 @@
/**
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class EchoKeyboardCommand extends AbstractVerticle {
public class EchoKeyboardCommand extends VerticleBase {

public static void main(String[] args) {
Launcher launcher = new Launcher() {
Expand All @@ -27,7 +25,7 @@ public void beforeStartingVertx(VertxOptions options) {
}

@Override
public void start() throws Exception {
public Future<?> start() throws Exception {

Command starwars = CommandBuilder.command("echokeyboard").
processHandler(process -> {
Expand All @@ -48,10 +46,6 @@ public void start() throws Exception {
new TelnetTermOptions().setHost("localhost").setPort(3000)
));
CommandRegistry.getShared(vertx).registerCommand(starwars);
service.start().onComplete(ar -> {
if (!ar.succeeded()) {
ar.cause().printStackTrace();
}
});
return service.start();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.vertx.example.shell.helloworld;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Launcher;
import io.vertx.core.VertxOptions;
import io.vertx.core.*;
import io.vertx.ext.dropwizard.DropwizardMetricsOptions;
import io.vertx.ext.shell.ShellService;
import io.vertx.ext.shell.ShellServiceOptions;
Expand All @@ -14,7 +12,7 @@
/*
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class HelloWorldCommand extends AbstractVerticle {
public class HelloWorldCommand extends VerticleBase {

public static void main(String[] args) {
Launcher launcher = new Launcher() {
Expand All @@ -27,7 +25,7 @@ public void beforeStartingVertx(VertxOptions options) {
}

@Override
public void start() throws Exception {
public Future<?> start() {

Command helloWorld = CommandBuilder.command("hello-world").
processHandler(process -> {
Expand All @@ -39,10 +37,6 @@ public void start() throws Exception {
new TelnetTermOptions().setHost("localhost").setPort(3000)
));
CommandRegistry.getShared(vertx).registerCommand(helloWorld);
service.start().onComplete(ar -> {
if (!ar.succeeded()) {
ar.cause().printStackTrace();
}
});
return service.start();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.vertx.example.shell.prompt;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Launcher;
import io.vertx.core.VertxOptions;
import io.vertx.core.*;
import io.vertx.ext.dropwizard.DropwizardMetricsOptions;
import io.vertx.ext.shell.ShellServer;
import io.vertx.ext.shell.command.CommandResolver;
Expand All @@ -11,7 +9,7 @@

import java.util.concurrent.atomic.AtomicInteger;

public class PromptCommand extends AbstractVerticle {
public class PromptCommand extends VerticleBase {
public static void main(String[] args) {
Launcher launcher = new Launcher() {
@Override
Expand All @@ -23,7 +21,7 @@ public void beforeStartingVertx(VertxOptions options) {
}

@Override
public void start() throws Exception {
public Future<?> start() throws Exception {

ShellServer server = ShellServer.create(vertx);
AtomicInteger ai = new AtomicInteger(0);
Expand All @@ -44,12 +42,6 @@ public void start() throws Exception {

server.registerCommandResolver(CommandResolver.baseCommands(vertx));

server.listen().onComplete(ar -> {
if (!ar.succeeded()) {
ar.cause().printStackTrace();
}
});


return server.listen();
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package io.vertx.example.shell.run_service_http;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Launcher;
import io.vertx.core.Promise;
import io.vertx.core.VertxOptions;
import io.vertx.core.*;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.dropwizard.DropwizardMetricsOptions;
import io.vertx.ext.shell.ShellService;
Expand All @@ -13,7 +10,7 @@
/**
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class RunShell extends AbstractVerticle {
public class RunShell extends VerticleBase {

public static void main(String[] args) {
Launcher launcher = new Launcher() {
Expand All @@ -26,7 +23,7 @@ public void beforeStartingVertx(VertxOptions options) {
}

@Override
public void start(Promise<Void> startPromise) {
public Future<?> start() {
ShellService service = ShellService.create(vertx, new ShellServiceOptions().
setHttpOptions(
new HttpTermOptions().
Expand All @@ -36,6 +33,6 @@ public void start(Promise<Void> startPromise) {
.put("provider", "properties")
.put("config", new JsonObject()
.put("file", "io/vertx/example/shell/run_service_http/auth.properties")))));
service.start().onComplete(startPromise);
return service.start();
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package io.vertx.example.shell.run_service_ssh;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Launcher;
import io.vertx.core.Promise;
import io.vertx.core.VertxOptions;
import io.vertx.core.*;
import io.vertx.core.json.JsonObject;
import io.vertx.core.net.JksOptions;
import io.vertx.ext.dropwizard.DropwizardMetricsOptions;
Expand All @@ -14,7 +11,7 @@
/**
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class RunShell extends AbstractVerticle {
public class RunShell extends VerticleBase {

public static void main(String[] args) {
Launcher launcher = new Launcher() {
Expand All @@ -27,7 +24,7 @@ public void beforeStartingVertx(VertxOptions options) {
}

@Override
public void start(Promise<Void> startPromise) {
public Future<?> start() {
ShellService service = ShellService.create(vertx, new ShellServiceOptions().
setSSHOptions(
new SSHTermOptions().
Expand All @@ -40,8 +37,6 @@ public void start(Promise<Void> startPromise) {
.put("provider", "properties")
.put("config", new JsonObject()
.put("file", "io/vertx/example/shell/run_service_ssh/auth.properties")))));
service
.start()
.onComplete(startPromise);
return service.start();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.vertx.example.shell.run_service_telnet;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Launcher;
import io.vertx.core.VertxOptions;
import io.vertx.core.*;
import io.vertx.ext.dropwizard.DropwizardMetricsOptions;
import io.vertx.ext.shell.ShellService;
import io.vertx.ext.shell.ShellServiceOptions;
Expand All @@ -11,7 +9,7 @@
/**
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class RunShell extends AbstractVerticle {
public class RunShell extends VerticleBase {

public static void main(String[] args) {
Launcher launcher = new Launcher() {
Expand All @@ -24,10 +22,10 @@ public void beforeStartingVertx(VertxOptions options) {
}

@Override
public void start() throws Exception {
public Future<?> start() throws Exception {
ShellService service = ShellService.create(vertx, new ShellServiceOptions().setTelnetOptions(
new TelnetTermOptions().setHost("localhost").setPort(3000)
));
service.start();
return service.start();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.vertx.example.shell.starwars;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Launcher;
import io.vertx.core.VertxOptions;
import io.vertx.core.*;
import io.vertx.core.net.NetClient;
import io.vertx.core.net.NetSocket;
import io.vertx.ext.dropwizard.DropwizardMetricsOptions;
Expand All @@ -16,7 +14,7 @@
/**
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class StarwarsCommand extends AbstractVerticle {
public class StarwarsCommand extends VerticleBase {

public static void main(String[] args) {
Launcher launcher = new Launcher() {
Expand All @@ -29,7 +27,7 @@ public void beforeStartingVertx(VertxOptions options) {
}

@Override
public void start() throws Exception {
public Future<?> start() throws Exception {

Command starwars = CommandBuilder.command("starwars").
processHandler(process -> {
Expand Down Expand Up @@ -68,10 +66,6 @@ public void start() throws Exception {
new TelnetTermOptions().setHost("localhost").setPort(3000)
));
CommandRegistry.getShared(vertx).registerCommand(starwars);
service.start().onComplete(ar -> {
if (!ar.succeeded()) {
ar.cause().printStackTrace();
}
});
return service.start();
}
}
Loading

0 comments on commit babc75d

Please sign in to comment.