@@ -0,0 +1,3053 @@
+/*%0A * Copyright 2013 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage net.kuujo.vertigo.hooks;%0A%0Aimport net.kuujo.vertigo.component.Component;%0Aimport net.kuujo.vertigo.context.InstanceContext;%0A%0Aimport org.vertx.java.core.eventbus.EventBus;%0Aimport org.vertx.java.core.json.JsonObject;%0A%0A/**%0A * An event bus publishing hook.%0A *%0A * This hook publishes events to the event bus. Messages are published using the%0A * string format %22vertigo.component.%25s.%25s%22 where the first argument is the full%0A * component address and the second argument is the event type (the method name).%0A * If the method argument is a component, the component context will be provided.%0A * If the method argument is a string ID, the ID will be provided.%0A *%0A * @author Jordan Halterman%0A */%0Apublic class EventBusHook implements ComponentHook %7B%0A  private InstanceContext context;%0A  private EventBus eventBus;%0A  private String address;%0A%0A  @Override%0A  public void start(Component%3C?%3E component) %7B%0A    this.eventBus = component.getVertx().eventBus();%0A    this.context = component.getContext();%0A    this.address = component.getContext().getComponent().getAddress();%0A    eventBus.publish(String.format(%22vertigo.component.%25s.start%22, address),%0A        new JsonObject().putObject(%22context%22, context.getState()));%0A  %7D%0A%0A  @Override%0A  public void received(String id) %7B%0A    eventBus.publish(String.format(%22vertigo.component.%25s.received%22, address),%0A        new JsonObject().putString(%22id%22, id));%0A  %7D%0A%0A  @Override%0A  public void ack(String id) %7B%0A    eventBus.publish(String.format(%22vertigo.component.%25s.ack%22, address),%0A        new JsonObject().putString(%22id%22, id));%0A  %7D%0A%0A  @Override%0A  public void fail(String id) %7B%0A    eventBus.publish(String.format(%22vertigo.component.%25s.fail%22, address),%0A        new JsonObject().putString(%22id%22, id));%0A  %7D%0A%0A  @Override%0A  public void emit(String id) %7B%0A    eventBus.publish(String.format(%22vertigo.component.%25s.emit%22, address),%0A        new JsonObject().putString(%22id%22, id));%0A  %7D%0A%0A  @Override%0A  public void acked(String id) %7B%0A    eventBus.publish(String.format(%22vertigo.component.%25s.acked%22, address),%0A        new JsonObject().putString(%22id%22, id));%0A  %7D%0A%0A  @Override%0A  public void failed(String id) %7B%0A    eventBus.publish(String.format(%22vertigo.component.%25s.failed%22, address),%0A        new JsonObject().putString(%22id%22, id));%0A  %7D%0A%0A  @Override%0A  public void stop(Component%3C?%3E subject) %7B%0A    eventBus.publish(String.format(%22vertigo.component.%25s.stop%22, address),%0A        new JsonObject().putObject(%22context%22, context.getState()));%0A  %7D%0A%0A%7D%0A

Add event bus hook implementation.