Eliminate LockChangeListener
[netconf.git] / netconf / sal-netconf-connector / src / main / java / org / opendaylight / netconf / sal / connect / netconf / sal / NetconfDeviceDataBroker.java
index 84b383292ff74932353c8f08c1a8a7c4292d94eb..69d2c858b0702a10f1a86bbe83c8df6def3b3083 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.netconf.sal.connect.netconf.sal;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
 import com.google.common.collect.ClassToInstanceMap;
 import com.google.common.collect.ImmutableClassToInstanceMap;
 import org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension;
@@ -37,19 +38,16 @@ import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.yangtools.rfc8528.data.api.MountPointContext;
 
 public final class NetconfDeviceDataBroker implements PingPongMergingDOMDataBroker {
-
     private final NetconfDOMDataBrokerFieldsExtension fieldsExtension = new NetconfDOMDataBrokerFieldsExtensionImpl();
-
     private final RemoteDeviceId id;
     private final NetconfBaseOps netconfOps;
     private final boolean rollbackSupport;
     private final boolean candidateSupported;
     private final boolean runningWritable;
-
-    private boolean isLockAllowed = true;
+    private final boolean lockDatastore;
 
     public NetconfDeviceDataBroker(final RemoteDeviceId id, final MountPointContext mountContext, final Rpcs rpcs,
-            final NetconfSessionPreferences netconfSessionPreferences) {
+            final NetconfSessionPreferences netconfSessionPreferences, final boolean lockDatastore) {
         this.id = id;
         netconfOps = new NetconfBaseOps(rpcs, mountContext);
         // get specific attributes from netconf preferences and get rid of it
@@ -57,9 +55,10 @@ public final class NetconfDeviceDataBroker implements PingPongMergingDOMDataBrok
         candidateSupported = netconfSessionPreferences.isCandidateSupported();
         runningWritable = netconfSessionPreferences.isRunningWritable();
         rollbackSupport = netconfSessionPreferences.isRollbackSupported();
-        Preconditions.checkArgument(candidateSupported || runningWritable,
-            "Device %s has advertised neither :writable-running nor :candidate capability."
-                    + "At least one of these should be advertised. Failed to establish a session.", id.getName());
+        checkArgument(candidateSupported || runningWritable,
+            "Device %s has advertised neither :writable-running nor :candidate capability. At least one of these "
+                + "should be advertised. Failed to establish a session.", id.getName());
+        this.lockDatastore = lockDatastore;
     }
 
     @Override
@@ -76,12 +75,12 @@ public final class NetconfDeviceDataBroker implements PingPongMergingDOMDataBrok
     public DOMDataTreeWriteTransaction newWriteOnlyTransaction() {
         if (candidateSupported) {
             if (runningWritable) {
-                return new WriteCandidateRunningTx(id, netconfOps, rollbackSupport, isLockAllowed);
+                return new WriteCandidateRunningTx(id, netconfOps, rollbackSupport, lockDatastore);
             } else {
-                return new WriteCandidateTx(id, netconfOps, rollbackSupport, isLockAllowed);
+                return new WriteCandidateTx(id, netconfOps, rollbackSupport, lockDatastore);
             }
         } else {
-            return new WriteRunningTx(id, netconfOps, rollbackSupport, isLockAllowed);
+            return new WriteRunningTx(id, netconfOps, rollbackSupport, lockDatastore);
         }
     }
 
@@ -95,10 +94,6 @@ public final class NetconfDeviceDataBroker implements PingPongMergingDOMDataBrok
         return ImmutableClassToInstanceMap.of(NetconfDOMDataBrokerFieldsExtension.class, fieldsExtension);
     }
 
-    void setLockAllowed(final boolean isLockAllowedOrig) {
-        isLockAllowed = isLockAllowedOrig;
-    }
-
     private final class NetconfDOMDataBrokerFieldsExtensionImpl implements NetconfDOMDataBrokerFieldsExtension {
         @Override
         public NetconfDOMFieldsReadTransaction newReadOnlyTransaction() {