From: Robert Varga Date: Mon, 30 Sep 2019 15:46:13 +0000 (+0200) Subject: Make DataTree take EffectiveModelContext X-Git-Tag: v4.0.0~8 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=3b04def6d98ce20e7ced70d347bc994e15dcdadf;p=yangtools.git Make DataTree take EffectiveModelContext This deprecates setSchemaContext() in favor of setEffectiveModelContext(), so that users are encouraged to migrate. JIRA: MDSAL-435 Change-Id: If859130e204a058f89c2fee04d4be69969215399 Signed-off-by: Robert Varga --- diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/DataTree.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/DataTree.java index 9c9b26d5fb..378b980dd9 100644 --- a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/DataTree.java +++ b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/DataTree.java @@ -7,6 +7,7 @@ */ package org.opendaylight.yangtools.yang.data.api.schema.tree; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.SchemaContext; /** @@ -19,9 +20,22 @@ public interface DataTree extends DataTreeTip, ReadOnlyDataTree { * * @param newSchemaContext new SchemaContext * @throws IllegalArgumentException if the new context is incompatible + * @throws NullPointerException if newSchemaContext is null + * @deprecated Prefer {@link #setEffectiveModelContext(EffectiveModelContext)}. */ + @Deprecated void setSchemaContext(SchemaContext newSchemaContext); + /** + * Make the data tree use a new schema context. The context will be used + * only by subsequent operations. + * + * @param newModelContext new EffectiveModelContext + * @throws IllegalArgumentException if the new context is incompatible + * @throws NullPointerException if newModelContext is null + */ + void setEffectiveModelContext(EffectiveModelContext newModelContext); + /** * Commit a data tree candidate. * diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTree.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTree.java index 1990b1590e..2baabdee0f 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTree.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTree.java @@ -26,6 +26,7 @@ import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; @@ -48,7 +49,7 @@ final class InMemoryDataTree extends AbstractDataTreeTip implements DataTree { private volatile DataTreeState state; InMemoryDataTree(final TreeNode rootNode, final DataTreeConfiguration treeConfig, - final SchemaContext schemaContext) { + final SchemaContext schemaContext) { this.treeConfig = requireNonNull(treeConfig, "treeConfig"); maskMandatory = true; state = DataTreeState.createInitial(rootNode); @@ -80,12 +81,22 @@ final class InMemoryDataTree extends AbstractDataTreeTip implements DataTree { return SchemaAwareApplyOperation.from(rootSchemaNode, treeConfig); } + @Deprecated + @Override + public void setSchemaContext(final SchemaContext newSchemaContext) { + internalSetSchemaContext(newSchemaContext); + } + + @Override + public void setEffectiveModelContext(final EffectiveModelContext newModelContext) { + internalSetSchemaContext(newModelContext); + } + /* * This method is synchronized to guard against user attempting to install * multiple contexts. Otherwise it runs in a lock-free manner. */ - @Override - public synchronized void setSchemaContext(final SchemaContext newSchemaContext) { + private synchronized void internalSetSchemaContext(final SchemaContext newSchemaContext) { requireNonNull(newSchemaContext); LOG.debug("Following schema contexts will be attempted {}", newSchemaContext); diff --git a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/StructuralApplyModificationTest.java b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/StructuralApplyModificationTest.java index 4937c03981..e08ff0ccd4 100644 --- a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/StructuralApplyModificationTest.java +++ b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/StructuralApplyModificationTest.java @@ -32,7 +32,7 @@ public final class StructuralApplyModificationTest extends AbstractTestModelTest @Before public void setUp() { inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION); - inMemoryDataTree.setSchemaContext(SCHEMA_CONTEXT); + inMemoryDataTree.setEffectiveModelContext(SCHEMA_CONTEXT); } @Test