Merge "Fix typo in match types yang model"
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / impl / DataBrokerImpl.java
index 2f4510d5b4f035e98e9351bcba8775a126f1f8a1..ddf67719dc03f8c9311f565fbf78c98f8ba107cd 100644 (file)
-package org.opendaylight.controller.sal.binding.impl;
-
-import java.util.concurrent.ExecutorService;
+/*
+ * Copyright (c) 2014 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.controller.sal.binding.impl;\r
+\r
+import java.util.Set;
 import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.opendaylight.controller.md.sal.common.api.data.DataReader;
 import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataBroker;
 import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
 import org.opendaylight.controller.sal.binding.impl.util.BindingAwareDataReaderRouter;
 import org.opendaylight.controller.sal.common.DataStoreIdentifier;
-import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.DataRoot;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-
-
-public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier<? extends DataObject>, DataObject, DataChangeListener> implements
-        DataProviderService, AutoCloseable {
-
-    
-    
-    private final AtomicLong nextTransaction = new AtomicLong();
-    
-    public DataBrokerImpl() {
-        setDataReadRouter(new BindingAwareDataReaderRouter());
-    }
-
-    @Override
-    public DataTransactionImpl beginTransaction() {
-        String transactionId = "BA-" + nextTransaction.getAndIncrement();
-        return new DataTransactionImpl(transactionId,this);
-    }
-
-    @Override
-    @Deprecated
-    public <T extends DataRoot> T getData(DataStoreIdentifier store, Class<T> rootType) {
-        throw new UnsupportedOperationException("Deprecated");
-    }
-
-    @Override
-    @Deprecated
-    public <T extends DataRoot> T getData(DataStoreIdentifier store, T filter) {
-        throw new UnsupportedOperationException("Deprecated");
-    }
-
-    @Override
-    @Deprecated
-    public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, Class<T> rootType) {
-        throw new UnsupportedOperationException("Deprecated");
-    }
-
-    @Override
-    @Deprecated
-    public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, T filter) {
-        throw new UnsupportedOperationException("Deprecated");
+\r
+\r
+public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier<? extends DataObject>, DataObject, DataChangeListener> //\r
+       implements DataProviderService, AutoCloseable {\r
+\r
+    private final AtomicLong nextTransaction = new AtomicLong();\r
+    private final AtomicLong createdTransactionsCount = new AtomicLong();\r
+\r
+    public AtomicLong getCreatedTransactionsCount() {\r
+        return createdTransactionsCount;\r
+    }\r
+\r
+    public DataBrokerImpl() {\r
+        setDataReadRouter(new BindingAwareDataReaderRouter());\r
+    }\r
+\r
+    @Override\r
+    public DataTransactionImpl beginTransaction() {\r
+        String transactionId = "BA-" + nextTransaction.getAndIncrement();\r
+        createdTransactionsCount.getAndIncrement();\r
+        return new DataTransactionImpl(transactionId,this);\r
+    }\r
+\r
+    @Override\r
+    @Deprecated\r
+    public <T extends DataRoot> T getData(DataStoreIdentifier store, Class<T> rootType) {\r
+        throw new UnsupportedOperationException("Deprecated");\r
+    }\r
+\r
+    @Override\r
+    @Deprecated\r
+    public <T extends DataRoot> T getData(DataStoreIdentifier store, T filter) {\r
+        throw new UnsupportedOperationException("Deprecated");\r
+    }\r
+\r
+    @Override\r
+    @Deprecated\r
+    public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, Class<T> rootType) {\r
+        throw new UnsupportedOperationException("Deprecated");\r
+    }\r
+\r
+    @Override\r
+    @Deprecated\r
+    public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, T filter) {\r
+        throw new UnsupportedOperationException("Deprecated");\r
+    }\r
+\r
+    @Override\r
+    @Deprecated\r
+    public RpcResult<DataRoot> editCandidateData(DataStoreIdentifier store, DataRoot changeSet) {\r
+        throw new UnsupportedOperationException("Deprecated");\r
+    }\r
+\r
+    @Override\r
+    @Deprecated\r
+    public Future<RpcResult<Void>> commit(DataStoreIdentifier store) {\r
+        throw new UnsupportedOperationException("Deprecated");\r
+    }\r
+\r
+    @Override\r
+    @Deprecated\r
+    public DataObject getData(InstanceIdentifier<? extends DataObject> data) {\r
+        throw new UnsupportedOperationException("Deprecated");\r
+    }\r
+\r
+    @Override\r
+    @Deprecated\r
+    public DataObject getConfigurationData(InstanceIdentifier<?> data) {\r
+        throw new UnsupportedOperationException("Deprecated");\r
+    }\r
+\r
+    @Override\r
+    @Deprecated\r
+    public void registerChangeListener(InstanceIdentifier<? extends DataObject> path, DataChangeListener changeListener) {\r
+        throw new UnsupportedOperationException("Deprecated");\r
+    }\r
+\r
+    @Override\r
+    @Deprecated\r
+    public void unregisterChangeListener(InstanceIdentifier<? extends DataObject> path,\r
+            DataChangeListener changeListener) {\r
+        throw new UnsupportedOperationException("Deprecated");\r
+    }\r
+\r
+    @Override\r
+    public void close() throws Exception {\r
+\r
     }
 
     @Override
-    @Deprecated
-    public RpcResult<DataRoot> editCandidateData(DataStoreIdentifier store, DataRoot changeSet) {
-        throw new UnsupportedOperationException("Deprecated");
-    }
-
-    @Override
-    @Deprecated
-    public Future<RpcResult<Void>> commit(DataStoreIdentifier store) {
-        throw new UnsupportedOperationException("Deprecated");
-    }
-
-    @Override
-    @Deprecated
-    public DataObject getData(InstanceIdentifier<? extends DataObject> data) {
-        throw new UnsupportedOperationException("Deprecated");
-    }
-
-    @Override
-    @Deprecated
-    public DataObject getConfigurationData(InstanceIdentifier<?> data) {
-        throw new UnsupportedOperationException("Deprecated");
-    }
-
-    @Override
-    @Deprecated
-    public void registerChangeListener(InstanceIdentifier<? extends DataObject> path, DataChangeListener changeListener) {
-        throw new UnsupportedOperationException("Deprecated");
-    }
-
-    @Override
-    @Deprecated
-    public void unregisterChangeListener(InstanceIdentifier<? extends DataObject> path,
-            DataChangeListener changeListener) {
-        throw new UnsupportedOperationException("Deprecated");
-    }
-    
-    @Override
-    public void close() throws Exception {
-        
-    }
-}
\ No newline at end of file
+    protected boolean isAffectedBy(InstanceIdentifier<? extends DataObject> key,
+            Set<InstanceIdentifier<? extends DataObject>> paths) {
+        if (paths.contains(key)) {
+            return true;
+        }
+        for (InstanceIdentifier<?> path : paths) {
+            if (key.containsWildcarded(path)) {
+                return true;
+            }
+        }
+        return false;
+    }\r
+}