Remove SchemaContextRef 51/90951/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 7 Jul 2020 13:39:52 +0000 (15:39 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 7 Jul 2020 15:20:06 +0000 (17:20 +0200)
Carrying a soft reference is completely superfluous -- it does not
guarantee availability and realistically this is just a brain-dead
wrapper for a local reference. Remove the class along with all
references to it.

Change-Id: I2e6fc3f9720f200e12443e07c490f8d79d04351b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
16 files changed:
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/references/SchemaContextRef.java [deleted file]
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImpl.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImpl.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/CreateStreamUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PatchDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PlainPatchDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PostDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PutDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ReadDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImplTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImplTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/CreateStreamUtilTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PatchDataTransactionUtilTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PlainPatchDataTransactionUtilTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PostDataTransactionUtilTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PutDataTransactionUtilTest.java

diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/references/SchemaContextRef.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/references/SchemaContextRef.java
deleted file mode 100644 (file)
index ba24073..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.restconf.nb.rfc8040.references;
-
-import java.lang.ref.SoftReference;
-import java.net.URI;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Optional;
-import org.opendaylight.mdsal.dom.api.DOMMountPoint;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-/**
- * This class creates {@link SoftReference} of actual {@link EffectiveModelContext}
- * object and even if the {@link SchemaContext} changes, this will be sticks
- * reference to the old {@link SchemaContext} and provides work with the old
- * {@link EffectiveModelContext}.
- *
- */
-public final class SchemaContextRef {
-
-    private final SoftReference<EffectiveModelContext> schemaContextRef;
-
-    /**
-     * Create {@link SoftReference} of actual {@link EffectiveModelContext}.
-     *
-     * @param schemaContext
-     *             actual {@link EffectiveModelContext}
-     */
-    public SchemaContextRef(final EffectiveModelContext schemaContext) {
-        this.schemaContextRef = new SoftReference<>(schemaContext);
-    }
-
-    /**
-     * Get {@link EffectiveModelContext} from reference.
-     *
-     * @return {@link EffectiveModelContext}
-     */
-    public EffectiveModelContext get() {
-        return this.schemaContextRef.get();
-    }
-
-    /**
-     * Get all modules like {@link Collection} of {@link Module} from {@link SchemaContext}.
-     *
-     * @return {@link Collection} of {@link Module}
-     */
-    public Collection<? extends Module> getModules() {
-        return get().getModules();
-    }
-
-    /**
-     * Get {@link Module} by ietf-restconf qname from
-     * {@link Rfc8040.RestconfModule}.
-     *
-     * @return {@link Module}
-     */
-    public Module getRestconfModule() {
-        return this.findModuleByNamespaceAndRevision(Rfc8040.RestconfModule.IETF_RESTCONF_QNAME.getNamespace(),
-                Rfc8040.RestconfModule.IETF_RESTCONF_QNAME.getRevision());
-    }
-
-    /**
-     * Find {@link Module} in {@link SchemaContext} by {@link URI} and
-     * {@link Date}.
-     *
-     * @param namespace
-     *             namespace of module
-     * @param revision
-     *             revision of module
-     * @return {@link Module}
-     */
-    public Module findModuleByNamespaceAndRevision(final URI namespace, final Optional<Revision> revision) {
-        return this.get().findModule(namespace, revision).orElse(null);
-    }
-
-    /**
-     * Find {@link Module} in {@link SchemaContext} of {@link DOMMountPoint} by
-     * {@link QName} of {@link Module}.
-     *
-     * @param mountPoint
-     *             mount point
-     * @param moduleQname
-     *             {@link QName} of module
-     * @return {@link Module}
-     */
-    public Module findModuleInMountPointByQName(final DOMMountPoint mountPoint, final QName moduleQname) {
-        final SchemaContext schemaContext = mountPoint == null ? null : mountPoint.getSchemaContext();
-        return schemaContext == null ? null
-                : schemaContext.findModule(moduleQname.getLocalName(), moduleQname.getRevision()).orElse(null);
-    }
-
-    /**
-     * Find {@link Module} in {@link SchemaContext} by {@link QName}.
-     *
-     * @param moduleQname
-     *             {@link QName} of module
-     * @return {@link Module}
-     */
-    public Module findModuleByQName(final QName moduleQname) {
-        return this.findModuleByNameAndRevision(moduleQname.getLocalName(), moduleQname.getRevision());
-    }
-
-    /**
-     * Find {@link Module} in {@link SchemaContext} by {@link String} localName
-     * and {@link Date} revision.
-     *
-     * @param localName
-     *             local name of module
-     * @param revision
-     *             revision of module
-     * @return {@link Module}
-     */
-    public Module findModuleByNameAndRevision(final String localName, final Optional<Revision> revision) {
-        return this.get().findModule(localName, revision).orElse(null);
-    }
-}
index 93c1457c806672626a41ef4ac51498ec25088236..48019124389d7e8077c4b47ca2c97466a1e0e167 100644 (file)
@@ -43,7 +43,6 @@ import org.opendaylight.restconf.nb.rfc8040.handlers.ActionServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfDataService;
 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfStreamsSubscriptionService;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.TransactionVarsWrapper;
@@ -130,9 +129,9 @@ public class RestconfDataServiceImpl implements RestconfDataService {
 
     @Override
     public Response readData(final String identifier, final UriInfo uriInfo) {
-        final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.get());
+        final EffectiveModelContext schemaContextRef = this.schemaContextHandler.get();
         final InstanceIdentifierContext<?> instanceIdentifier = ParserIdentifier.toInstanceIdentifier(
-                identifier, schemaContextRef.get(), Optional.of(this.mountPointServiceHandler.get()));
+                identifier, schemaContextRef, Optional.of(this.mountPointServiceHandler.get()));
         final WriterParameters parameters = ReadDataTransactionUtil.parseUriParameters(instanceIdentifier, uriInfo);
 
         final DOMMountPoint mountPoint = instanceIdentifier.getMountPoint();
@@ -183,13 +182,13 @@ public class RestconfDataServiceImpl implements RestconfDataService {
 
         final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint();
         final TransactionChainHandler localTransactionChainHandler;
-        final SchemaContextRef ref;
+        final EffectiveModelContext ref;
         if (mountPoint == null) {
             localTransactionChainHandler = this.transactionChainHandler;
-            ref = new SchemaContextRef(this.schemaContextHandler.get());
+            ref = this.schemaContextHandler.get();
         } else {
             localTransactionChainHandler = transactionChainOfMountPoint(mountPoint);
-            ref = new SchemaContextRef(mountPoint.getEffectiveModelContext());
+            ref = mountPoint.getEffectiveModelContext();
         }
 
         final TransactionVarsWrapper transactionNode = new TransactionVarsWrapper(
@@ -310,13 +309,13 @@ public class RestconfDataServiceImpl implements RestconfDataService {
 
         final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint();
         final TransactionChainHandler localTransactionChainHandler;
-        final SchemaContextRef ref;
+        final EffectiveModelContext ref;
         if (mountPoint == null) {
             localTransactionChainHandler = this.transactionChainHandler;
-            ref = new SchemaContextRef(this.schemaContextHandler.get());
+            ref = this.schemaContextHandler.get();
         } else {
             localTransactionChainHandler = transactionChainOfMountPoint(mountPoint);
-            ref = new SchemaContextRef(mountPoint.getEffectiveModelContext());
+            ref = mountPoint.getEffectiveModelContext();
         }
 
         final TransactionVarsWrapper transactionNode = new TransactionVarsWrapper(
@@ -329,9 +328,8 @@ public class RestconfDataServiceImpl implements RestconfDataService {
         return mountPoint == null ? transactionChainHandler : transactionChainOfMountPoint(mountPoint);
     }
 
-    private SchemaContextRef getSchemaContext(final DOMMountPoint mountPoint) {
-        return mountPoint == null ? new SchemaContextRef(schemaContextHandler.get())
-                : new SchemaContextRef(mountPoint.getEffectiveModelContext());
+    private EffectiveModelContext getSchemaContext(final DOMMountPoint mountPoint) {
+        return mountPoint == null ? schemaContextHandler.get() : mountPoint.getEffectiveModelContext();
     }
 
     /**
index 49ba53be0e31a3221dc59659789f7ed66503dcbe..5680d27e5f6b2663627eda9c75ca271f6892817d 100644 (file)
@@ -21,7 +21,6 @@ import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfInvokeOperationsService;
 import org.opendaylight.restconf.nb.rfc8040.rests.utils.CreateStreamUtil;
 import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfInvokeOperationsUtil;
@@ -62,7 +61,7 @@ public class RestconfInvokeOperationsServiceImpl implements RestconfInvokeOperat
     @Override
     public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload,
             final UriInfo uriInfo) {
-        final SchemaContextRef refSchemaCtx = new SchemaContextRef(this.schemaContextHandler.get());
+        final EffectiveModelContext refSchemaCtx = this.schemaContextHandler.get();
         final SchemaPath schemaPath = payload.getInstanceIdentifierContext().getSchemaNode().getPath();
         final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint();
         final URI namespace = payload.getInstanceIdentifierContext().getSchemaNode().getQName().getNamespace();
index a31d0a58113f18ef93611d678b7e968da65343ae..4012c8c62f6c3539f280473dd3d086742f35fcb3 100644 (file)
@@ -18,7 +18,6 @@ import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.common.util.DataChangeScope;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.streams.listeners.ListenersBroker;
 import org.opendaylight.restconf.nb.rfc8040.streams.listeners.NotificationListenerAdapter;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
@@ -32,6 +31,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -64,7 +64,7 @@ public final class CreateStreamUtil {
      *                         }
      *                     }
      *                     </pre>
-     * @param refSchemaCtx Reference to {@link SchemaContext} - {@link SchemaContextRef}.
+     * @param refSchemaCtx Reference to {@link EffectiveModelContext}.
      * @return {@link DOMRpcResult} - Output of RPC - example in JSON:
      *     <pre>
      *     {@code
@@ -77,7 +77,7 @@ public final class CreateStreamUtil {
      *     </pre>
      */
     public static DOMRpcResult createDataChangeNotifiStream(final NormalizedNodeContext payload,
-            final SchemaContextRef refSchemaCtx) {
+            final EffectiveModelContext refSchemaCtx) {
         // parsing out of container with settings and path
         final ContainerNode data = (ContainerNode) requireNonNull(payload).getData();
         final QName qname = payload.getInstanceIdentifierContext().getSchemaNode().getQName();
@@ -85,7 +85,7 @@ public final class CreateStreamUtil {
 
         // building of stream name
         final StringBuilder streamNameBuilder = new StringBuilder(
-                prepareDataChangeNotifiStreamName(path, requireNonNull(refSchemaCtx).get(), data));
+                prepareDataChangeNotifiStreamName(path, requireNonNull(refSchemaCtx), data));
         final NotificationOutputType outputType = prepareOutputType(data);
         if (outputType.equals(NotificationOutputType.JSON)) {
             streamNameBuilder.append('/').append(outputType.getName());
@@ -206,12 +206,12 @@ public final class CreateStreamUtil {
      * Create YANG notification stream using notification definition in YANG schema.
      *
      * @param notificationDefinition YANG notification definition.
-     * @param refSchemaCtx           Reference to {@link SchemaContext} - {@link SchemaContextRef}.
+     * @param refSchemaCtx           Reference to {@link EffectiveModelContext}
      * @param outputType             Output type (XML or JSON).
      * @return {@link NotificationListenerAdapter}
      */
     public static NotificationListenerAdapter createYangNotifiStream(
-            final NotificationDefinition notificationDefinition, final SchemaContextRef refSchemaCtx,
+            final NotificationDefinition notificationDefinition, final EffectiveModelContext refSchemaCtx,
             final NotificationOutputType outputType) {
         final String streamName = parseNotificationStreamName(requireNonNull(notificationDefinition),
                 requireNonNull(refSchemaCtx), requireNonNull(outputType.getName()));
@@ -222,11 +222,11 @@ public final class CreateStreamUtil {
     }
 
     private static String parseNotificationStreamName(final NotificationDefinition notificationDefinition,
-            final SchemaContextRef refSchemaCtx, final String outputType) {
+            final EffectiveModelContext refSchemaCtx, final String outputType) {
         final QName notificationDefinitionQName = notificationDefinition.getQName();
-        final Module module = refSchemaCtx.findModuleByNamespaceAndRevision(
+        final Module module = refSchemaCtx.findModule(
                 notificationDefinitionQName.getModule().getNamespace(),
-                notificationDefinitionQName.getModule().getRevision());
+                notificationDefinitionQName.getModule().getRevision()).orElse(null);
         requireNonNull(module, String.format("Module for namespace %s does not exist.",
                 notificationDefinitionQName.getModule().getNamespace()));
 
index d92f143a1458c20d58731e5f56250185229c8a30..ebfb9964b6357e907b09c35222ca8fc930a7315f 100644 (file)
@@ -27,7 +27,6 @@ import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.common.patch.PatchEntity;
 import org.opendaylight.restconf.common.patch.PatchStatusContext;
 import org.opendaylight.restconf.common.patch.PatchStatusEntity;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.TransactionVarsWrapper;
 import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfDataServiceConstant.PatchData;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -35,7 +34,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -51,11 +50,11 @@ public final class PatchDataTransactionUtil {
      * {@link TransactionVarsWrapper} provided as a parameter.
      * @param context Patch context to be processed
      * @param transactionNode Wrapper for transaction
-     * @param schemaContextRef Soft reference for global schema context
+     * @param schemaContext Global schema context
      * @return {@link PatchStatusContext}
      */
     public static PatchStatusContext patchData(final PatchContext context, final TransactionVarsWrapper transactionNode,
-                                               final SchemaContextRef schemaContextRef) {
+                                               final EffectiveModelContext schemaContext) {
         final List<PatchStatusEntity> editCollection = new ArrayList<>();
         boolean noError = true;
         final DOMTransactionChain transactionChain = transactionNode.getTransactionChain();
@@ -67,7 +66,7 @@ public final class PatchDataTransactionUtil {
                     case CREATE:
                         try {
                             createDataWithinTransaction(LogicalDatastoreType.CONFIGURATION,
-                                    patchEntity.getTargetNode(), patchEntity.getNode(), tx, schemaContextRef);
+                                    patchEntity.getTargetNode(), patchEntity.getNode(), tx, schemaContext);
                             editCollection.add(new PatchStatusEntity(patchEntity.getEditId(), true, null));
                         } catch (final RestconfDocumentedException e) {
                             editCollection.add(new PatchStatusEntity(patchEntity.getEditId(),
@@ -89,7 +88,7 @@ public final class PatchDataTransactionUtil {
                     case MERGE:
                         try {
                             mergeDataWithinTransaction(LogicalDatastoreType.CONFIGURATION,
-                                    patchEntity.getTargetNode(), patchEntity.getNode(), tx, schemaContextRef);
+                                    patchEntity.getTargetNode(), patchEntity.getNode(), tx, schemaContext);
                             editCollection.add(new PatchStatusEntity(patchEntity.getEditId(), true, null));
                         } catch (final RestconfDocumentedException e) {
                             editCollection.add(new PatchStatusEntity(patchEntity.getEditId(),
@@ -100,7 +99,7 @@ public final class PatchDataTransactionUtil {
                     case REPLACE:
                         try {
                             replaceDataWithinTransaction(LogicalDatastoreType.CONFIGURATION,
-                                    patchEntity.getTargetNode(), patchEntity.getNode(), schemaContextRef, tx);
+                                    patchEntity.getTargetNode(), patchEntity.getNode(), schemaContext, tx);
                             editCollection.add(new PatchStatusEntity(patchEntity.getEditId(), true, null));
                         } catch (final RestconfDocumentedException e) {
                             editCollection.add(new PatchStatusEntity(patchEntity.getEditId(),
@@ -160,15 +159,15 @@ public final class PatchDataTransactionUtil {
      * @param path Path for data to be created
      * @param payload Data to be created
      * @param rwTransaction Transaction
-     * @param schemaContextRef Soft reference for global schema context
+     * @param schemaContext Global schema context
      */
     private static void createDataWithinTransaction(final LogicalDatastoreType dataStore,
                                                     final YangInstanceIdentifier path,
                                                     final NormalizedNode<?, ?> payload,
                                                     final DOMDataTreeReadWriteTransaction rwTransaction,
-                                                    final SchemaContextRef schemaContextRef) {
+                                                    final EffectiveModelContext schemaContext) {
         LOG.trace("POST {} within Restconf Patch: {} with payload {}", dataStore.name(), path, payload);
-        createData(payload, schemaContextRef.get(), path, rwTransaction, dataStore, true);
+        createData(payload, schemaContext, path, rwTransaction, dataStore, true);
     }
 
     /**
@@ -191,15 +190,15 @@ public final class PatchDataTransactionUtil {
      * @param path Path for data to be merged
      * @param payload Data to be merged
      * @param writeTransaction Transaction
-     * @param schemaContextRef Soft reference for global schema context
+     * @param schemaContext Global schema context
      */
     private static void mergeDataWithinTransaction(final LogicalDatastoreType dataStore,
                                                    final YangInstanceIdentifier path,
                                                    final NormalizedNode<?, ?> payload,
                                                    final DOMDataTreeWriteTransaction writeTransaction,
-                                                   final SchemaContextRef schemaContextRef) {
+                                                   final EffectiveModelContext schemaContext) {
         LOG.trace("Merge {} within Restconf Patch: {} with payload {}", dataStore.name(), path, payload);
-        TransactionUtil.ensureParentsByMerge(path, schemaContextRef.get(), writeTransaction);
+        TransactionUtil.ensureParentsByMerge(path, schemaContext, writeTransaction);
         writeTransaction.merge(dataStore, path, payload);
     }
 
@@ -221,16 +220,16 @@ public final class PatchDataTransactionUtil {
      * @param dataStore Datastore to write data to
      * @param path Path for data to be created
      * @param payload Data to be created
-     * @param schemaContextRef Soft reference for global schema context
+     * @param path Path for data to be created
      * @param rwTransaction Transaction
      */
     private static void replaceDataWithinTransaction(final LogicalDatastoreType dataStore,
                                                      final YangInstanceIdentifier path,
                                                      final NormalizedNode<?, ?> payload,
-                                                     final SchemaContextRef schemaContextRef,
+                                                     final EffectiveModelContext schemaContext,
                                                      final DOMDataTreeReadWriteTransaction rwTransaction) {
         LOG.trace("PUT {} within Restconf Patch: {} with payload {}", dataStore.name(), path, payload);
-        createData(payload, schemaContextRef.get(), path, rwTransaction, dataStore, false);
+        createData(payload, schemaContext, path, rwTransaction, dataStore, false);
     }
 
     /**
@@ -243,7 +242,7 @@ public final class PatchDataTransactionUtil {
      * @param dataStore Datastore to write data to
      * @param errorIfExists Enable checking for existence of data (throws error if already exists)
      */
-    private static void createData(final NormalizedNode<?, ?> payload, final SchemaContext schemaContext,
+    private static void createData(final NormalizedNode<?, ?> payload, final EffectiveModelContext schemaContext,
                                    final YangInstanceIdentifier path,
                                    final DOMDataTreeReadWriteTransaction rwTransaction,
                                    final LogicalDatastoreType dataStore, final boolean errorIfExists) {
index d1857be0df6943f37c540d2360f7241eb0f29a6b..95e36e59522faa4b706b3f42b22f83d8a2784041 100644 (file)
@@ -18,11 +18,10 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
 import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.TransactionVarsWrapper;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -42,15 +41,15 @@ public final class PlainPatchDataTransactionUtil {
      *
      * @param payload
      *             data to put
-     * @param schemaContextRef
-     *             reference to {@link SchemaContext}
+     * @param schemaContext
+     *             reference to {@link EffectiveModelContext}
      * @param transactionNode
      *             wrapper of variables for transaction
      * @return {@link Response}
      */
     public static Response patchData(final NormalizedNodeContext payload,
                                      final TransactionVarsWrapper transactionNode,
-                                     final SchemaContextRef schemaContextRef) {
+                                     final EffectiveModelContext schemaContext) {
 
         final DOMTransactionChain transactionChain = transactionNode.getTransactionChain();
         final DOMDataTreeReadWriteTransaction tx = transactionChain.newReadWriteTransaction();
@@ -59,8 +58,7 @@ public final class PlainPatchDataTransactionUtil {
         NormalizedNode<?, ?> data = payload.getData();
 
         try {
-            mergeDataWithinTransaction(LogicalDatastoreType.CONFIGURATION,
-                    path, data, tx, schemaContextRef);
+            mergeDataWithinTransaction(LogicalDatastoreType.CONFIGURATION, path, data, tx, schemaContext);
         } catch (final RestconfDocumentedException e) {
             tx.cancel();
             transactionChain.close();
@@ -85,15 +83,15 @@ public final class PlainPatchDataTransactionUtil {
      * @param path Path for data to be merged
      * @param payload Data to be merged
      * @param writeTransaction Transaction
-     * @param schemaContextRef Soft reference for global schema context
+     * @param schemaContext global schema context
      */
     private static void mergeDataWithinTransaction(final LogicalDatastoreType dataStore,
                                                    final YangInstanceIdentifier path,
                                                    final NormalizedNode<?, ?> payload,
                                                    final DOMDataTreeWriteTransaction writeTransaction,
-                                                   final SchemaContextRef schemaContextRef) {
+                                                   final EffectiveModelContext schemaContext) {
         LOG.trace("Merge {} within Restconf Patch: {} with payload {}", dataStore.name(), path, payload);
-        TransactionUtil.ensureParentsByMerge(path, schemaContextRef.get(), writeTransaction);
+        TransactionUtil.ensureParentsByMerge(path, schemaContext, writeTransaction);
         writeTransaction.merge(dataStore, path, payload);
     }
 }
index 5e38fb92723fb8a4876be13e432243d558039506..1e79b9a36f16af144d8c0f45a5cab653d5a307d7 100644 (file)
@@ -22,7 +22,6 @@ import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.TransactionVarsWrapper;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -57,8 +56,8 @@ public final class PostDataTransactionUtil {
      *             data
      * @param transactionNode
      *             wrapper for transaction data
-     * @param schemaContextRef
-     *             reference to actual {@link SchemaContext}
+     * @param schemaContext
+     *             reference to current {@link EffectiveModelContext}
      * @param point
      *             point
      * @param insert
@@ -66,12 +65,12 @@ public final class PostDataTransactionUtil {
      * @return {@link Response}
      */
     public static Response postData(final UriInfo uriInfo, final NormalizedNodeContext payload,
-            final TransactionVarsWrapper transactionNode, final SchemaContextRef schemaContextRef, final String insert,
-            final String point) {
+            final TransactionVarsWrapper transactionNode, final EffectiveModelContext schemaContext,
+            final String insert, final String point) {
         final FluentFuture<? extends CommitInfo> future = submitData(
                 payload.getInstanceIdentifierContext().getInstanceIdentifier(), payload.getData(),
-                transactionNode, schemaContextRef.get(), insert, point);
-        final URI location = resolveLocation(uriInfo, transactionNode, schemaContextRef, payload.getData());
+                transactionNode, schemaContext, insert, point);
+        final URI location = resolveLocation(uriInfo, transactionNode, schemaContext, payload.getData());
         final ResponseFactory dataFactory = new ResponseFactory(Status.CREATED).location(location);
         //This method will close transactionChain
         FutureCallbackTx.addCallback(future, RestconfDataServiceConstant.PostData.POST_TX_TYPE, dataFactory,
@@ -311,12 +310,12 @@ public final class PostDataTransactionUtil {
      *             uri info
      * @param transactionNode
      *             wrapper for data of transaction
-     * @param schemaContextRef
+     * @param schemaContext
      *            reference to {@link SchemaContext}
      * @return {@link URI}
      */
     private static URI resolveLocation(final UriInfo uriInfo, final TransactionVarsWrapper transactionNode,
-            final SchemaContextRef schemaContextRef, final NormalizedNode<?, ?> data) {
+            final EffectiveModelContext schemaContext, final NormalizedNode<?, ?> data) {
         if (uriInfo == null) {
             return null;
         }
@@ -332,7 +331,7 @@ public final class PostDataTransactionUtil {
 
         return uriInfo.getBaseUriBuilder()
                 .path("data")
-                .path(ParserIdentifier.stringFromYangInstanceIdentifier(path, schemaContextRef.get()))
+                .path(ParserIdentifier.stringFromYangInstanceIdentifier(path, schemaContext))
                 .build();
     }
 
index 203d67a97f2f94db7c5b6c03adcdf8e67d0c83a0..c9f7d6379d11bdfe774700d9692c14f11b9761a6 100644 (file)
@@ -26,7 +26,6 @@ import org.opendaylight.restconf.common.errors.RestconfError;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.TransactionVarsWrapper;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -147,8 +146,8 @@ public final class PutDataTransactionUtil {
      *
      * @param payload
      *             data to put
-     * @param schemaCtxRef
-     *             reference to {@link SchemaContext}
+     * @param schemaContext
+     *             reference to {@link EffectiveModelContext}
      * @param transactionNode
      *             wrapper of variables for transaction
      * @param point
@@ -157,10 +156,9 @@ public final class PutDataTransactionUtil {
      *             query parameter
      * @return {@link Response}
      */
-    public static Response putData(final NormalizedNodeContext payload, final SchemaContextRef schemaCtxRef,
+    public static Response putData(final NormalizedNodeContext payload, final EffectiveModelContext schemaContext,
                                final TransactionVarsWrapper transactionNode, final String insert, final String point) {
         final YangInstanceIdentifier path = payload.getInstanceIdentifierContext().getInstanceIdentifier();
-        final EffectiveModelContext schemaContext = schemaCtxRef.get();
 
         final DOMDataTreeReadWriteTransaction readWriteTransaction =
                 transactionNode.getTransactionChain().newReadWriteTransaction();
index 448599b6ad19b27c4e4ad19df0c96d191e39a59d..af1c8eeb2c03f70103a878fb8f4a1d45e47bd865 100644 (file)
@@ -32,7 +32,6 @@ import org.opendaylight.restconf.common.context.WriterParameters;
 import org.opendaylight.restconf.common.context.WriterParameters.WriterParametersBuilder;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.TransactionVarsWrapper;
 import org.opendaylight.restconf.nb.rfc8040.streams.listeners.NotificationListenerAdapter;
 import org.opendaylight.restconf.nb.rfc8040.utils.mapping.RestconfMappingNodeUtil;
@@ -69,6 +68,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNo
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
@@ -212,7 +212,7 @@ public final class ReadDataTransactionUtil {
      * @param transactionNode
      *            {@link TransactionVarsWrapper} - wrapper for variables
      * @param withDefa
-     *            vaule of with-defaults parameter
+     *            value of with-defaults parameter
      * @param ctx
      *            schema context
      * @return {@link NormalizedNode}
@@ -256,7 +256,7 @@ public final class ReadDataTransactionUtil {
      *             {@link TransactionVarsWrapper} - wrapper for variables
      * @param withDefa
      *             vaule of with-defaults parameter
-     * @param schemaContextRef
+     * @param schemaContext
      *             schema context
      * @param uriInfo
      *             uri info
@@ -264,41 +264,40 @@ public final class ReadDataTransactionUtil {
      */
     public static NormalizedNode<?, ?> readData(final String identifier, final String content,
                                                 final TransactionVarsWrapper transactionNode, final String withDefa,
-                                                final SchemaContextRef schemaContextRef, final UriInfo uriInfo) {
-        final SchemaContext schemaContext = schemaContextRef.get();
+                                                final EffectiveModelContext schemaContext, final UriInfo uriInfo) {
         if (identifier != null && identifier.contains(STREAMS_PATH) && !identifier.contains(STREAM_PATH_PART)) {
-            createAllYangNotificationStreams(transactionNode, schemaContextRef, uriInfo);
+            createAllYangNotificationStreams(transactionNode, schemaContext, uriInfo);
         }
         return readData(content, transactionNode, withDefa, schemaContext);
     }
 
     private static void createAllYangNotificationStreams(final TransactionVarsWrapper transactionNode,
-            final SchemaContextRef schemaContextRef, final UriInfo uriInfo) {
+            final EffectiveModelContext schemaContext, final UriInfo uriInfo) {
         final DOMDataTreeReadWriteTransaction wTx = transactionNode.getTransactionChain().newReadWriteTransaction();
-        final boolean exist = SubscribeToStreamUtil.checkExist(schemaContextRef.get(), wTx);
+        final boolean exist = SubscribeToStreamUtil.checkExist(schemaContext, wTx);
 
-        for (final NotificationDefinition notificationDefinition : schemaContextRef.get().getNotifications()) {
+        for (final NotificationDefinition notificationDefinition : schemaContext.getNotifications()) {
             final NotificationListenerAdapter notifiStreamXML =
-                    CreateStreamUtil.createYangNotifiStream(notificationDefinition, schemaContextRef,
+                    CreateStreamUtil.createYangNotifiStream(notificationDefinition, schemaContext,
                             NotificationOutputType.XML);
             final NotificationListenerAdapter notifiStreamJSON =
-                    CreateStreamUtil.createYangNotifiStream(notificationDefinition, schemaContextRef,
+                    CreateStreamUtil.createYangNotifiStream(notificationDefinition, schemaContext,
                             NotificationOutputType.JSON);
-            writeNotificationStreamToDatastore(schemaContextRef, uriInfo, wTx, exist, notifiStreamXML);
-            writeNotificationStreamToDatastore(schemaContextRef, uriInfo, wTx, exist, notifiStreamJSON);
+            writeNotificationStreamToDatastore(schemaContext, uriInfo, wTx, exist, notifiStreamXML);
+            writeNotificationStreamToDatastore(schemaContext, uriInfo, wTx, exist, notifiStreamJSON);
         }
         SubscribeToStreamUtil.submitData(wTx);
     }
 
-    private static void writeNotificationStreamToDatastore(final SchemaContextRef schemaContextRef,
+    private static void writeNotificationStreamToDatastore(final EffectiveModelContext schemaContext,
             final UriInfo uriInfo, final DOMDataTreeReadWriteTransaction readWriteTransaction, final boolean exist,
             final NotificationListenerAdapter listener) {
         final URI uri = SubscribeToStreamUtil.prepareUriByStreamName(uriInfo, listener.getStreamName());
-        final NormalizedNode mapToStreams = RestconfMappingNodeUtil.mapYangNotificationStreamByIetfRestconfMonitoring(
-                listener.getSchemaPath().getLastComponent(), schemaContextRef.get().getNotifications(), null,
-                listener.getOutputType(), uri,
-                SubscribeToStreamUtil.getMonitoringModule(schemaContextRef.get()), exist);
-        SubscribeToStreamUtil.writeDataToDS(schemaContextRef.get(),
+        final NormalizedNode<?, ?> mapToStreams =
+                RestconfMappingNodeUtil.mapYangNotificationStreamByIetfRestconfMonitoring(
+                    listener.getSchemaPath().getLastComponent(), schemaContext.getNotifications(), null,
+                    listener.getOutputType(), uri, SubscribeToStreamUtil.getMonitoringModule(schemaContext), exist);
+        SubscribeToStreamUtil.writeDataToDS(schemaContext,
                 listener.getSchemaPath().getLastComponent().getLocalName(), readWriteTransaction, exist, mapToStreams);
     }
 
index 23ce6437dccb46f6342b62912f952c39dce54f85..66d1890889500b86f0709f8e58e3879986870f6e 100644 (file)
@@ -62,7 +62,6 @@ import org.opendaylight.restconf.nb.rfc8040.handlers.ActionServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfStreamsSubscriptionService;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -79,6 +78,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@@ -90,7 +90,7 @@ public class RestconfDataServiceImplTest {
     private ContainerNode buildBaseCont;
     private ContainerNode buildBaseContConfig;
     private ContainerNode buildBaseContOperational;
-    private SchemaContextRef contextRef;
+    private EffectiveModelContext contextRef;
     private YangInstanceIdentifier iidBase;
     private DataSchemaNode schemaNode;
     private RestconfDataServiceImpl dataService;
@@ -181,9 +181,9 @@ public class RestconfDataServiceImplTest {
                 .node(this.baseQName)
                 .build();
 
-        this.contextRef = new SchemaContextRef(
-                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
-        this.schemaNode = DataSchemaContextTree.from(this.contextRef.get()).getChild(this.iidBase).getDataSchemaNode();
+        this.contextRef =
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT));
+        this.schemaNode = DataSchemaContextTree.from(this.contextRef).getChild(this.iidBase).getDataSchemaNode();
 
         doReturn(CommitInfo.emptyFluentFuture()).when(this.write).commit();
         doReturn(CommitInfo.emptyFluentFuture()).when(this.readWrite).commit();
@@ -200,14 +200,14 @@ public class RestconfDataServiceImplTest {
         final SchemaContextHandler schemaContextHandler = new SchemaContextHandler(transactionChainHandler,
                 Mockito.mock(DOMSchemaService.class));
 
-        schemaContextHandler.onModelContextUpdated(this.contextRef.get());
+        schemaContextHandler.onModelContextUpdated(this.contextRef);
         this.dataService = new RestconfDataServiceImpl(schemaContextHandler, this.transactionChainHandler,
                 new DOMMountPointServiceHandler(mountPointService), this.delegRestconfSubscrService,
                 this.actionServiceHandler);
         doReturn(Optional.of(this.mountPoint)).when(this.mountPointService)
                 .getMountPoint(any(YangInstanceIdentifier.class));
         doCallRealMethod().when(this.mountPoint).getSchemaContext();
-        doReturn(this.contextRef.get()).when(this.mountPoint).getEffectiveModelContext();
+        doReturn(this.contextRef).when(this.mountPoint).getEffectiveModelContext();
         doReturn(Optional.of(this.mountDataBroker)).when(this.mountPoint).getService(DOMDataBroker.class);
         doReturn(this.mountTransactionChain).when(this.mountDataBroker)
                 .createTransactionChain(any(DOMTransactionChainListener.class));
@@ -357,7 +357,7 @@ public class RestconfDataServiceImplTest {
     @Test
     public void testPutData() {
         final InstanceIdentifierContext<DataSchemaNode> iidContext =
-                new InstanceIdentifierContext<>(this.iidBase, this.schemaNode, null, this.contextRef.get());
+                new InstanceIdentifierContext<>(this.iidBase, this.schemaNode, null, this.contextRef);
         final NormalizedNodeContext payload = new NormalizedNodeContext(iidContext, this.buildBaseCont);
 
         doReturn(immediateTrueFluentFuture()).when(this.readWrite)
@@ -375,7 +375,7 @@ public class RestconfDataServiceImplTest {
 //        doReturn(this.transactionChainHandler.get()).when(dataBroker)
 //                .createTransactionChain(RestConnectorProvider.TRANSACTION_CHAIN_LISTENER);
         final InstanceIdentifierContext<DataSchemaNode> iidContext =
-                new InstanceIdentifierContext<>(this.iidBase, this.schemaNode, mountPoint, this.contextRef.get());
+                new InstanceIdentifierContext<>(this.iidBase, this.schemaNode, mountPoint, this.contextRef);
         final NormalizedNodeContext payload = new NormalizedNodeContext(iidContext, this.buildBaseCont);
 
         doReturn(immediateTrueFluentFuture()).when(this.readWrite)
@@ -412,7 +412,7 @@ public class RestconfDataServiceImplTest {
 
         doReturn(new MultivaluedHashMap<String, String>()).when(this.uriInfo).getQueryParameters();
         final InstanceIdentifierContext<? extends SchemaNode> iidContext =
-                new InstanceIdentifierContext<>(this.iidBase, null, null, this.contextRef.get());
+                new InstanceIdentifierContext<>(this.iidBase, null, null, this.contextRef);
         final NormalizedNodeContext payload = new NormalizedNodeContext(iidContext, buildList);
         doReturn(immediateFluentFuture(Optional.empty()))
                 .when(this.read).read(LogicalDatastoreType.CONFIGURATION, this.iidBase);
@@ -457,7 +457,7 @@ public class RestconfDataServiceImplTest {
     @Test
     public void testPatchData() throws Exception {
         final InstanceIdentifierContext<? extends SchemaNode> iidContext =
-                new InstanceIdentifierContext<>(this.iidBase, this.schemaNode, null, this.contextRef.get());
+                new InstanceIdentifierContext<>(this.iidBase, this.schemaNode, null, this.contextRef);
         final List<PatchEntity> entity = new ArrayList<>();
         final YangInstanceIdentifier iidleaf = YangInstanceIdentifier.builder(this.iidBase)
                 .node(this.containerPlayerQname)
@@ -485,7 +485,7 @@ public class RestconfDataServiceImplTest {
     @Test
     public void testPatchDataMountPoint() throws Exception {
         final InstanceIdentifierContext<? extends SchemaNode> iidContext = new InstanceIdentifierContext<>(
-                this.iidBase, this.schemaNode, this.mountPoint, this.contextRef.get());
+                this.iidBase, this.schemaNode, this.mountPoint, this.contextRef);
         final List<PatchEntity> entity = new ArrayList<>();
         final YangInstanceIdentifier iidleaf = YangInstanceIdentifier.builder(this.iidBase)
                 .node(this.containerPlayerQname)
@@ -513,7 +513,7 @@ public class RestconfDataServiceImplTest {
     @Test
     public void testPatchDataDeleteNotExist() throws Exception {
         final InstanceIdentifierContext<? extends SchemaNode> iidContext =
-                new InstanceIdentifierContext<>(this.iidBase, this.schemaNode, null, this.contextRef.get());
+                new InstanceIdentifierContext<>(this.iidBase, this.schemaNode, null, this.contextRef);
         final List<PatchEntity> entity = new ArrayList<>();
         final YangInstanceIdentifier iidleaf = YangInstanceIdentifier.builder(this.iidBase)
                 .node(this.containerPlayerQname)
index 0d792e6479e972621e438bb9aab2070cd5c703ca..37cfb08d2028b3dc56e5f4a9aca31e08897baee5 100644 (file)
@@ -34,11 +34,11 @@ import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@@ -58,8 +58,8 @@ public class RestconfInvokeOperationsServiceImplTest {
     @Before
     public void setup() throws Exception {
         MockitoAnnotations.initMocks(this);
-        final SchemaContextRef contextRef = new SchemaContextRef(
-                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
+        final EffectiveModelContext contextRef =
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT));
         final TransactionChainHandler txHandler = mock(TransactionChainHandler.class);
         final DOMTransactionChain domTx = mock(DOMTransactionChain.class);
         when(txHandler.get()).thenReturn(domTx);
@@ -68,7 +68,7 @@ public class RestconfInvokeOperationsServiceImplTest {
         doReturn(CommitInfo.emptyFluentFuture()).when(wTx).commit();
         final SchemaContextHandler schemaContextHandler = new SchemaContextHandler(txHandler,
             mock(DOMSchemaService.class));
-        schemaContextHandler.onModelContextUpdated(contextRef.get());
+        schemaContextHandler.onModelContextUpdated(contextRef);
         this.invokeOperationsService =
                 new RestconfInvokeOperationsServiceImpl(this.rpcServiceHandler, schemaContextHandler);
         when(this.rpcServiceHandler.get()).thenReturn(this.rpcService);
index 0eaabe0d4fcca99be546085fb519acde0f6501a7..d086d4b47fc5ba0196d7f887cfd8c74c09656b0b 100644 (file)
@@ -21,7 +21,6 @@ import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@@ -43,13 +42,13 @@ public class CreateStreamUtilTest {
     private static final String PATH_FOR_NEW_SCHEMA_CONTEXT = "/streams";
 
     private NormalizedNodeContext payload;
-    private SchemaContextRef refSchemaCtx;
+    private EffectiveModelContext refSchemaCtx;
 
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        this.refSchemaCtx = new SchemaContextRef(
-                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
+        this.refSchemaCtx =
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT));
     }
 
     @Test
@@ -80,7 +79,7 @@ public class CreateStreamUtilTest {
 
     private NormalizedNodeContext prepareDomPayload(final String rpcName, final String inputOutput,
             final String toasterValue, final String inputOutputName) {
-        final EffectiveModelContext schema = this.refSchemaCtx.get();
+        final EffectiveModelContext schema = this.refSchemaCtx;
         final Module rpcModule = schema.findModules("sal-remote").iterator().next();
         final QName rpcQName = QName.create(rpcModule.getQNameModule(), rpcName);
         final QName rpcInputQName = QName.create(rpcModule.getQNameModule(), inputOutput);
index 36cefb644455514f0cdecae103d1d0f43807b08a..2de9591b8bd1c645d404932c17cab69cdcc72fbd 100644 (file)
@@ -39,7 +39,6 @@ import org.opendaylight.restconf.common.patch.PatchStatusContext;
 import org.opendaylight.restconf.common.patch.PatchStatusEntity;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.TransactionVarsWrapper;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -50,6 +49,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
@@ -67,7 +67,7 @@ public class PatchDataTransactionUtilTest {
     private DOMDataBroker mockDataBroker;
 
     private TransactionChainHandler transactionChainHandler;
-    private SchemaContextRef refSchemaCtx;
+    private EffectiveModelContext refSchemaCtx;
     private YangInstanceIdentifier instanceIdContainer;
     private YangInstanceIdentifier instanceIdCreateAndDelete;
     private YangInstanceIdentifier instanceIdMerge;
@@ -83,8 +83,8 @@ public class PatchDataTransactionUtilTest {
         doReturn(transactionChain).when(mockDataBroker).createTransactionChain(any());
         transactionChainHandler = new TransactionChainHandler(mockDataBroker);
 
-        this.refSchemaCtx = new SchemaContextRef(
-                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
+        this.refSchemaCtx = YangParserTestUtils.parseYangFiles(
+            TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT));
         final QName baseQName = QName.create("http://example.com/ns/example-jukebox", "2015-04-04", "jukebox");
         final QName containerPlayerQName = QName.create(baseQName, "player");
         final QName leafGapQName = QName.create(baseQName, "gap");
@@ -183,7 +183,7 @@ public class PatchDataTransactionUtilTest {
         entities.add(entityRemove);
 
         final InstanceIdentifierContext<? extends SchemaNode> iidContext =
-                new InstanceIdentifierContext<>(this.instanceIdMerge, null, null, this.refSchemaCtx.get());
+                new InstanceIdentifierContext<>(this.instanceIdMerge, null, null, this.refSchemaCtx);
         final PatchContext patchContext = new PatchContext(iidContext, entities, "patchRMRm");
         final TransactionVarsWrapper wrapper = new TransactionVarsWrapper(iidContext, null, transactionChainHandler);
         final PatchStatusContext patchStatusContext =
@@ -212,7 +212,7 @@ public class PatchDataTransactionUtilTest {
         entities.add(entityDelete);
 
         final InstanceIdentifierContext<? extends SchemaNode> iidContext =
-                new InstanceIdentifierContext<>(this.instanceIdCreateAndDelete, null, null, this.refSchemaCtx.get());
+                new InstanceIdentifierContext<>(this.instanceIdCreateAndDelete, null, null, this.refSchemaCtx);
         final PatchContext patchContext = new PatchContext(iidContext, entities, "patchCD");
         final TransactionVarsWrapper wrapper = new TransactionVarsWrapper(iidContext, null, transactionChainHandler);
         final PatchStatusContext patchStatusContext =
@@ -235,7 +235,7 @@ public class PatchDataTransactionUtilTest {
         entities.add(entityDelete);
 
         final InstanceIdentifierContext<? extends SchemaNode> iidContext =
-                new InstanceIdentifierContext<>(this.instanceIdCreateAndDelete, null, null, this.refSchemaCtx.get());
+                new InstanceIdentifierContext<>(this.instanceIdCreateAndDelete, null, null, this.refSchemaCtx);
         final PatchContext patchContext = new PatchContext(iidContext, entities, "patchD");
         final TransactionVarsWrapper wrapper = new TransactionVarsWrapper(iidContext, null, transactionChainHandler);
         final PatchStatusContext patchStatusContext =
@@ -260,7 +260,7 @@ public class PatchDataTransactionUtilTest {
         entities.add(entityMerge);
 
         final InstanceIdentifierContext<? extends SchemaNode> iidContext =
-                new InstanceIdentifierContext<>(this.instanceIdCreateAndDelete, null, null, this.refSchemaCtx.get());
+                new InstanceIdentifierContext<>(this.instanceIdCreateAndDelete, null, null, this.refSchemaCtx);
         final PatchContext patchContext = new PatchContext(iidContext, entities, "patchM");
         final TransactionVarsWrapper wrapper = new TransactionVarsWrapper(iidContext, null, transactionChainHandler);
         final PatchStatusContext patchStatusContext =
index f983b0bf526b4d9b34433ee0a0059f5e31fba1fe..fcac79c6932f3c9a38a329e13f3227d109077be2 100644 (file)
@@ -29,7 +29,6 @@ import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.TransactionVarsWrapper;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -61,7 +60,6 @@ public class PlainPatchDataTransactionUtilTest {
     private DOMDataBroker mockDataBroker;
 
     private TransactionChainHandler transactionChainHandler;
-    private SchemaContextRef refSchemaCtx;
     private LeafNode leafGap;
     private ContainerNode jukeboxContainerWithPlayer;
     private ContainerNode jukeboxContainerWithPlaylist;
@@ -74,9 +72,7 @@ public class PlainPatchDataTransactionUtilTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        this.refSchemaCtx = new SchemaContextRef(
-                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
-        this.schema = this.refSchemaCtx.get();
+        this.schema = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT));
 
         final QName qnJukebox = QName.create("http://example.com/ns/example-jukebox", "2015-04-04", "jukebox");
         final QName qnPlayer = QName.create(qnJukebox, "player");
@@ -176,7 +172,7 @@ public class PlainPatchDataTransactionUtilTest {
 
         PlainPatchDataTransactionUtil.patchData(payload,
                 new TransactionVarsWrapper(payload.getInstanceIdentifierContext(), null, transactionChainHandler),
-                this.refSchemaCtx);
+                this.schema);
 
         verify(this.readWrite).merge(LogicalDatastoreType.CONFIGURATION,
                 payload.getInstanceIdentifierContext().getInstanceIdentifier(), payload.getData());
@@ -199,7 +195,7 @@ public class PlainPatchDataTransactionUtilTest {
 
         PlainPatchDataTransactionUtil.patchData(payload,
                 new TransactionVarsWrapper(payload.getInstanceIdentifierContext(), null, transactionChainHandler),
-                this.refSchemaCtx);
+                this.schema);
 
         verify(this.readWrite).merge(LogicalDatastoreType.CONFIGURATION,
                 payload.getInstanceIdentifierContext().getInstanceIdentifier(), payload.getData());
@@ -222,7 +218,7 @@ public class PlainPatchDataTransactionUtilTest {
 
         PlainPatchDataTransactionUtil.patchData(payload,
                 new TransactionVarsWrapper(payload.getInstanceIdentifierContext(), null, transactionChainHandler),
-                this.refSchemaCtx);
+                this.schema);
 
         verify(this.readWrite).merge(LogicalDatastoreType.CONFIGURATION, this.iidJukebox, payload.getData());
     }
index 881216f3ccd73ab00b88f3dcea7d079b5e171499..7bd431caa4c958f83d22cc211476186f9b27aa15 100644 (file)
@@ -41,7 +41,6 @@ import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.TransactionVarsWrapper;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -77,7 +76,6 @@ public class PostDataTransactionUtilTest {
     private DOMDataBroker mockDataBroker;
 
     private TransactionChainHandler transactionChainHandler;
-    private SchemaContextRef refSchemaCtx;
     private ContainerNode buildBaseCont;
     private EffectiveModelContext schema;
     private YangInstanceIdentifier iid2;
@@ -87,9 +85,8 @@ public class PostDataTransactionUtilTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        this.refSchemaCtx = new SchemaContextRef(
-                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
-        this.schema = this.refSchemaCtx.get();
+        this.schema =
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT));
 
         final QName baseQName = QName.create("http://example.com/ns/example-jukebox", "2015-04-04", "jukebox");
         final QName containerQname = QName.create(baseQName, "player");
@@ -163,7 +160,7 @@ public class PostDataTransactionUtilTest {
         final TransactionVarsWrapper wrapper =
                 new TransactionVarsWrapper(payload.getInstanceIdentifierContext(), null, transactionChainHandler);
         final Response response =
-                PostDataTransactionUtil.postData(this.uriInfo, payload, wrapper, this.refSchemaCtx, null, null);
+                PostDataTransactionUtil.postData(this.uriInfo, payload, wrapper, this.schema, null, null);
         assertEquals(201, response.getStatus());
         verify(this.readWrite).exists(LogicalDatastoreType.CONFIGURATION, this.iid2);
         verify(this.readWrite).put(LogicalDatastoreType.CONFIGURATION,
@@ -186,7 +183,7 @@ public class PostDataTransactionUtilTest {
         final TransactionVarsWrapper wrapper =
                 new TransactionVarsWrapper(payload.getInstanceIdentifierContext(), null, transactionChainHandler);
         final Response response =
-                PostDataTransactionUtil.postData(this.uriInfo, payload, wrapper, this.refSchemaCtx, null, null);
+                PostDataTransactionUtil.postData(this.uriInfo, payload, wrapper, this.schema, null, null);
         assertEquals(201, response.getStatus());
         assertThat(URLDecoder.decode(response.getLocation().toString(), "UTF-8"),
             containsString(identifier.getValue(identifier.keySet().iterator().next()).toString()));
@@ -214,7 +211,7 @@ public class PostDataTransactionUtilTest {
                 new TransactionVarsWrapper(payload.getInstanceIdentifierContext(), null, transactionChainHandler);
 
         try {
-            PostDataTransactionUtil.postData(this.uriInfo, payload, wrapper, this.refSchemaCtx, null, null);
+            PostDataTransactionUtil.postData(this.uriInfo, payload, wrapper, this.schema, null, null);
             fail("Expected RestconfDocumentedException");
         } catch (final RestconfDocumentedException e) {
             assertEquals(1, e.getErrors().size());
index 1cc826e9581af805eb217160a582b46d47107105..4b9006fee0aa949ce2e097566ea3941e1671981c 100644 (file)
@@ -29,7 +29,6 @@ import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
-import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.TransactionVarsWrapper;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -61,7 +60,6 @@ public class PutDataTransactionUtilTest {
     private DOMDataBroker mockDataBroker;
 
     private TransactionChainHandler transactionChainHandler;
-    private SchemaContextRef refSchemaCtx;
     private LeafNode buildLeaf;
     private ContainerNode buildBaseCont;
     private ContainerNode buildBaseContWithList;
@@ -77,9 +75,8 @@ public class PutDataTransactionUtilTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        this.refSchemaCtx = new SchemaContextRef(
-                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)));
-        this.schema = this.refSchemaCtx.get();
+        this.schema =
+                YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT));
 
         final QName baseQName = QName.create("http://example.com/ns/example-jukebox", "2015-04-04", "jukebox");
         final QName containerQname = QName.create(baseQName, "player");
@@ -222,7 +219,7 @@ public class PutDataTransactionUtilTest {
                 payload.getInstanceIdentifierContext().getInstanceIdentifier(), payload.getData());
         doReturn(CommitInfo.emptyFluentFuture()).when(this.readWrite).commit();
 
-        PutDataTransactionUtil.putData(payload, this.refSchemaCtx,
+        PutDataTransactionUtil.putData(payload, this.schema,
                 new TransactionVarsWrapper(payload.getInstanceIdentifierContext(), null, transactionChainHandler), null,
                 null);
         verify(this.readWrite).exists(LogicalDatastoreType.CONFIGURATION,
@@ -246,7 +243,7 @@ public class PutDataTransactionUtilTest {
                 payload.getInstanceIdentifierContext().getInstanceIdentifier(), payload.getData());
         doReturn(CommitInfo.emptyFluentFuture()).when(this.readWrite).commit();
 
-        PutDataTransactionUtil.putData(payload, this.refSchemaCtx,
+        PutDataTransactionUtil.putData(payload, this.schema,
                 new TransactionVarsWrapper(payload.getInstanceIdentifierContext(), null, transactionChainHandler), null,
                 null);
         verify(this.readWrite).exists(LogicalDatastoreType.CONFIGURATION,
@@ -269,7 +266,7 @@ public class PutDataTransactionUtilTest {
         doNothing().when(this.readWrite).put(LogicalDatastoreType.CONFIGURATION,
                 payload.getInstanceIdentifierContext().getInstanceIdentifier(), payload.getData());
         doReturn(CommitInfo.emptyFluentFuture()).when(this.readWrite).commit();
-        PutDataTransactionUtil.putData(payload, this.refSchemaCtx,
+        PutDataTransactionUtil.putData(payload, this.schema,
                 new TransactionVarsWrapper(payload.getInstanceIdentifierContext(), null, transactionChainHandler), null,
                 null);
         verify(this.readWrite).exists(LogicalDatastoreType.CONFIGURATION, this.iid2);