// we want to delete the directory that will store our events
final File eventsDir = new File(System.getProperty("java.io.tmpdir"), "Events");
FileUtils.deleteDirectory(eventsDir);
// we create a serializer, so we can ensure the event store and the upcasters use the same configuration
Serializer serializer = new XStreamSerializer();
// initialize a FileSystem Event Store
FileSystemEventStore eventStore = new FileSystemEventStore(serializer, new SimpleEventFileResolver(eventsDir));
// initialize the upcaster chain with our upcaster
eventStore.setUpcasterChain(new LazyUpcasterChain(serializer,
Collections.<Upcaster>singletonList(new ToDoItemUpcaster())));