+
+ if (isSupported(datastores, org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry.class)) {
+ extBuilder.put(DOMDataTreeCommitCohortRegistry.class, new DOMDataTreeCommitCohortRegistry() {
+ @Override
+ public <T extends DOMDataTreeCommitCohort> DOMDataTreeCommitCohortRegistration<T> registerCommitCohort(
+ org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier path, T cohort) {
+ DOMStore store = getTxFactories().get(toLegacy(path.getDatastoreType()));
+ checkState(store != null, "Requested logical data store is not available.");
+
+ return ((org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry) store)
+ .registerCommitCohort(path, cohort);
+ }
+ });
+ }
+
+ extensions = extBuilder.build();
+ }
+
+ private static LogicalDatastoreType toLegacy(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType) {
+ switch (datastoreType) {
+ case CONFIGURATION:
+ return LogicalDatastoreType.CONFIGURATION;
+ case OPERATIONAL:
+ return LogicalDatastoreType.OPERATIONAL;
+ default:
+ throw new IllegalArgumentException("Unsupported data store type: " + datastoreType);
+ }
+ }
+
+ private static boolean isSupported(Map<LogicalDatastoreType, DOMStore> datastores,
+ Class<?> expDOMStoreInterface) {
+ for (DOMStore ds : datastores.values()) {
+ if (!expDOMStoreInterface.isAssignableFrom(ds.getClass())) {
+ return false;
+ }
+ }
+
+ return true;