class DataSetDefRegistryCDI extends DataSetDefRegistryImpl implements CSVFileStorage {

    @Override
    public void registerDataSetDef(DataSetDef def,
                                   String subjectId,
                                   String message) {

        if (def.getUUID() == null) {
            final String uuid = uuidGenerator.newUuid();
            def.setUUID(uuid);
        }

        if (subjectId == null || message == null) {
            ioService.startBatch(fileSystem);
        } else {
            ioService.startBatch(fileSystem,
                                 new CommentedOption(subjectId,
                                                     message));
        }

        try {
            String defJson = getDataSetDefJsonMarshaller().toJsonString(def);
            Path defPath = resolveNioPath(def);
            ioService.write(defPath,
                            defJson);

            // CSV specific
            if (def instanceof CSVDataSetDef) {
                saveCSVFile((CSVDataSetDef) def);
            }
            super.registerDataSetDef(def,
                                     subjectId,
                                     message);
        } catch (Exception e) {
            throw exceptionManager.handleException(
                    new Exception("Can't register the data set definition\n" + def,
                                  e));
        } finally {
            ioService.endBatch();
        }
    }

    public  DataSetDefRegistryCDI();
    @Inject public  DataSetDefRegistryCDI(@Config("10485760" /* 10 Mb */) int maxCsvLength,
                                 @Named("ioStrategy") IOService ioService,
                                 DataSetProviderRegistryCDI dataSetProviderRegistry,
                                 SchedulerCDI scheduler,
                                 ExceptionManager exceptionManager,
                                 Event<DataSetDefModifiedEvent> dataSetDefModifiedEvent,
                                 Event<DataSetDefRegisteredEvent> dataSetDefRegisteredEvent,
                                 Event<DataSetDefRemovedEvent> dataSetDefRemovedEvent,
                                 Event<DataSetStaleEvent> dataSetStaleEvent);

}