// we'll store Events on the FileSystem, in the "events" folder
EventStore eventStore = new FileSystemEventStore(new SimpleEventFileResolver(new File("./events")));
// a Simple Event Bus will do
EventBus eventBus = new SimpleEventBus();
// we need to configure the repository
EventSourcingRepository<ToDoItem> repository = new EventSourcingRepository<ToDoItem>(ToDoItem.class, eventStore);
repository.setEventBus(eventBus);
// Register the Command Handlers with the command bus by subscribing to the name of the command
commandBus.subscribe(CreateToDoItemCommand.class.getName(),
new CreateToDoCommandHandler(repository));
commandBus.subscribe(MarkCompletedCommand.class.getName(),
new MarkCompletedCommandHandler(repository));
// We register an event listener to see which events are created
eventBus.subscribe(new ToDoEventListener());
// and let's send some Commands on the CommandBus using the special runner configured with our CommandGateway.
CommandGenerator.sendCommands(commandGateway);
}