// we register the event handlers
AnnotationEventListenerAdapter.subscribe(new ToDoEventHandler(), eventBus);
// we use default settings for the disruptor command bus
DisruptorCommandBus commandBus = new DisruptorCommandBus(eventStore, eventBus);
// now, we obtain a repository from the command bus
Repository<ToDoItem> repository = commandBus.createRepository(new GenericAggregateFactory<ToDoItem>(ToDoItem.class));
// we use the repository to register the command handler
AggregateAnnotationCommandHandler.subscribe(ToDoItem.class, repository, commandBus);
// the CommandGateway provides a friendlier API to send commands
CommandGateway commandGateway = new DefaultCommandGateway(commandBus);
// and let's send some Commands on the CommandBus.
CommandGenerator.sendCommands(commandGateway);
// we need to stop the disruptor command bus, to make sure we release all resources
commandBus.stop();
}