// we need to store a Saga somewhere. Let's do that in memory for now
InMemorySagaRepository sagaRepository = new InMemorySagaRepository();
// we want to inject resources in our Saga, so we need to tweak the GenericSagaFactory
GenericSagaFactory sagaFactory = new GenericSagaFactory();
// this will allow the eventScheduler and commandGateway to be injected in our Saga
sagaFactory.setResourceInjector(new SimpleResourceInjector(eventScheduler, commandGateway));
// Sagas instances are managed and tracked by a SagaManager.
AnnotatedSagaManager sagaManager = new AnnotatedSagaManager(sagaRepository, sagaFactory,
eventBus, ToDoSaga.class);