X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fcluster%2Fdatastore%2Fmodel%2FSchemaContextHelper.java;fp=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fcluster%2Fdatastore%2Fmodel%2FSchemaContextHelper.java;h=0e421b1bc6065225622ad088afb96e8c8f1f419e;hb=da1c4f4a024472c0e8c340ba78d104a72f39785f;hp=c98044af329416a365c50cf14f09dbdb0dbd968e;hpb=d19cf96d390ffcdba8b1f64a6dd3f3749ecc5872;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SchemaContextHelper.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SchemaContextHelper.java index c98044af32..0e421b1bc6 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SchemaContextHelper.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SchemaContextHelper.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.cluster.datastore.model; import java.io.InputStream; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; public final class SchemaContextHelper { @@ -17,6 +17,8 @@ public final class SchemaContextHelper { public static final String PEOPLE_YANG = "/people.yang"; public static final String CARS_YANG = "/cars.yang"; + private static volatile EffectiveModelContext FULL; + private SchemaContextHelper() { } @@ -25,15 +27,25 @@ public final class SchemaContextHelper { return SchemaContextHelper.class.getResourceAsStream(yangFileName); } - public static SchemaContext full() { - return select(ODL_DATASTORE_TEST_YANG, PEOPLE_YANG, CARS_YANG); + public static EffectiveModelContext full() { + EffectiveModelContext ret = FULL; + if (ret == null) { + synchronized (SchemaContextHelper.class) { + ret = FULL; + if (ret == null) { + ret = FULL = select(ODL_DATASTORE_TEST_YANG, PEOPLE_YANG, CARS_YANG); + } + } + } + + return ret; } - public static SchemaContext select(final String... schemaFiles) { + public static EffectiveModelContext select(final String... schemaFiles) { return YangParserTestUtils.parseYangResources(SchemaContextHelper.class, schemaFiles); } - public static SchemaContext distributedShardedDOMDataTreeSchemaContext() { + public static EffectiveModelContext distributedShardedDOMDataTreeSchemaContext() { // we need prefix-shard-configuration and odl-datastore-test models // for DistributedShardedDOMDataTree tests return YangParserTestUtils.parseYangResources(SchemaContextHelper.class, ODL_DATASTORE_TEST_YANG,