edubkendo
12/19/2012 - 2:48 PM

simple vertx class, testing the testrunner

simple vertx class, testing the testrunner

import org.vertx.java.core.Handler;
import org.vertx.java.core.eventbus.EventBus;
import org.vertx.java.core.eventbus.Message;
import org.vertx.java.deploy.Verticle;

public class RSpecGreeter extends Verticle {

  public void start() {
    EventBus eb = vertx.eventBus();

    Handler<Message<String>> greetingHandler = new Handler<Message<String>>() {
      public void handle(Message<String> message) {

        if (message.body == "greet") {
          String replyGreeting = greet();
          message.reply("This is a reply");
        }
      }
    };

    eb.registerHandler("rspecgreeter.greet", greetingHandler);
  }

  public String greet() {
    String greeting = "Hello RSpec!";
    return greeting;
  }
}