Skip to content

Instantly share code, notes, and snippets.

@darylteo
Last active December 24, 2015 04:19
Show Gist options
  • Select an option

  • Save darylteo/6743600 to your computer and use it in GitHub Desktop.

Select an option

Save darylteo/6743600 to your computer and use it in GitHub Desktop.
My Crazy Idea?
public class Verticle {
public static void main(String[] args) throws Exception {
StackTraceElement[] stack = Thread.currentThread ().getStackTrace ();
for(StackTraceElement e : stack) {
System.out.println(e);
}
StackTraceElement main = stack[stack.length - 1];
String mainClass = main.getClassName ();
System.out.println("I am a: " + mainClass);
Vertx vertx = new Vertx();
Container container = new Container();
Verticle verticle = (Verticle) Class.forName(mainClass).newInstance();
verticle.setVertx(vertx);
verticle.setContainer(container);
verticle.start();
}
public void setVertx(Vertx vertx) {}
public void setContainer(Container container){}
public void start() {}
public void stop() {}
}
class MyVerticle extends Verticle {
public static void main(String[] args) throws Exception {
Verticle.main(args);
}
public void start() {
System.out.println("My Verticle Started!");
}
}
// blah
class Vertx { }
class Container { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment