// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/Command.java
// public abstract class Command {
// 
//   @Override
//   public boolean equals(Object o) {
//     return EqualsBuilder.reflectionEquals(this, o);
//   }
// 
//   @Override
//   public int hashCode() {
//     return HashCodeBuilder.reflectionHashCode(this);
//   }
// 
//   @Override
//   public String toString() {
//     return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
//   }
// 
// }
// 
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
// 
//   void dispatch(Command command);
// 
//   <T extends CommandHandler> T register(T handler);
// 
// }
// 
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandHandler.java
// public interface CommandHandler {
// }


import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import se.citerus.cqrs.bookstore.command.Command;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.command.CommandHandler;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;



public class GuavaCommandBus implements CommandBus {

  private final EventBus commandBus;

  private GuavaCommandBus(EventBus commandBus) {
    this.commandBus = commandBus;
  }

  public static CommandBus asyncGuavaCommandBus() {
    ExecutorService executorService = Executors.newFixedThreadPool(1);
    return new GuavaCommandBus(new AsyncEventBus("commandbus", executorService));
  }

  public static CommandBus syncGuavaCommandBus() {
    return new GuavaCommandBus(new EventBus("commandbus"));
  }

  @Override
  public <T extends CommandHandler> T register(T handler) {
    commandBus.register(handler);
    return handler;
  }

  @Override
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/Command.java
// public abstract class Command {
// 
//   @Override
//   public boolean equals(Object o) {
//     return EqualsBuilder.reflectionEquals(this, o);
//   }
// 
//   @Override
//   public int hashCode() {
//     return HashCodeBuilder.reflectionHashCode(this);
//   }
// 
//   @Override
//   public String toString() {
//     return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
//   }
// 
// }
// 
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandBus.java
// public interface CommandBus {
// 
//   void dispatch(Command command);
// 
//   <T extends CommandHandler> T register(T handler);
// 
// }
// 
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/command/CommandHandler.java
// public interface CommandHandler {
// }


// Path: order-context-parent/order-application/src/main/java/se/citerus/cqrs/bookstore/ordercontext/application/infrastructure/GuavaCommandBus.java
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import se.citerus.cqrs.bookstore.command.Command;
import se.citerus.cqrs.bookstore.command.CommandBus;
import se.citerus.cqrs.bookstore.command.CommandHandler;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

package se.citerus.cqrs.bookstore.ordercontext.application.infrastructure;



public class GuavaCommandBus implements CommandBus {

  private final EventBus commandBus;

  private GuavaCommandBus(EventBus commandBus) {
    this.commandBus = commandBus;
  }

  public static CommandBus asyncGuavaCommandBus() {
    ExecutorService executorService = Executors.newFixedThreadPool(1);
    return new GuavaCommandBus(new AsyncEventBus("commandbus", executorService));
  }

  public static CommandBus syncGuavaCommandBus() {
    return new GuavaCommandBus(new EventBus("commandbus"));
  }

  @Override
  public <T extends CommandHandler> T register(T handler) {
    commandBus.register(handler);
    return handler;
  }

  @Override
  public void dispatch(Command command) {