Add forwarding transactions to binding v2 92/74292/7
authorStephen Kitt <skitt@redhat.com>
Fri, 20 Jul 2018 14:08:17 +0000 (16:08 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 27 Jul 2018 21:19:09 +0000 (21:19 +0000)
This ports the forwarding transactions from controller.
WriteTransaction::delete is removed to allow WriteTransaction to be
implemented outside its package (it conflicts with
AsyncWriteTransaction::delete).

Change-Id: I7b8c0454b788ef1c5857c7f546005dcd0b4c12a6
Signed-off-by: Stephen Kitt <skitt@redhat.com>
12 files changed:
binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/WriteTransaction.java
binding2/mdsal-binding2-spi/pom.xml [new file with mode: 0644]
binding2/mdsal-binding2-spi/src/main/java/org/opendaylight/mdsal/binding/javav2/spi/ForwardingDataBroker.java [new file with mode: 0644]
binding2/mdsal-binding2-spi/src/main/java/org/opendaylight/mdsal/binding/javav2/spi/ForwardingReadTransaction.java [new file with mode: 0644]
binding2/mdsal-binding2-spi/src/main/java/org/opendaylight/mdsal/binding/javav2/spi/ForwardingWriteTransaction.java [new file with mode: 0644]
binding2/pom.xml
common/artifacts/pom.xml
common/features/odl-mdsal-binding2-api/pom.xml
common/features/odl-mdsal-common/pom.xml
common/mdsal-common-util/pom.xml [new file with mode: 0644]
common/mdsal-common-util/src/main/java/org/opendaylight/mdsal/common/util/ForwardingAsyncReadWriteTransaction.java [new file with mode: 0644]
common/pom.xml

index 2dc6a49e31538720742ad0dd2b4fa2b714969b84..dd89c68a426a4211ff9394ddf452ecf228a71eef 100644 (file)
@@ -141,9 +141,6 @@ public interface WriteTransaction extends AsyncWriteTransaction<InstanceIdentifi
     <T extends TreeNode> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
         boolean createMissingParents);
 
-    @Override
-    void delete(LogicalDatastoreType store, InstanceIdentifier<? extends TreeNode> path);
-
     /**
      * Flag value indicating that missing parents should be created.
      */
diff --git a/binding2/mdsal-binding2-spi/pom.xml b/binding2/mdsal-binding2-spi/pom.xml
new file mode 100644 (file)
index 0000000..79e0619
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright © 2018 Red Hat, Inc. and others.
+
+ 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
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.opendaylight.odlparent</groupId>
+        <artifactId>bundle-parent</artifactId>
+        <version>3.1.3</version>
+        <relativePath/>
+    </parent>
+
+    <groupId>org.opendaylight.mdsal</groupId>
+    <artifactId>mdsal-binding2-spi</artifactId>
+    <version>0.13.0-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.opendaylight.mdsal</groupId>
+                <artifactId>mdsal-artifacts</artifactId>
+                <version>2.5.0-SNAPSHOT</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yangtools-artifacts</artifactId>
+                <version>2.0.7</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-binding2-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-binding2-spec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-common-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>concepts</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file
diff --git a/binding2/mdsal-binding2-spi/src/main/java/org/opendaylight/mdsal/binding/javav2/spi/ForwardingDataBroker.java b/binding2/mdsal-binding2-spi/src/main/java/org/opendaylight/mdsal/binding/javav2/spi/ForwardingDataBroker.java
new file mode 100644 (file)
index 0000000..bd83281
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 2017, 2018 Red Hat, Inc. and others.
+ *
+ * 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.mdsal.binding.javav2.spi;
+
+import com.google.common.collect.ForwardingObject;
+import java.util.Collection;
+import javax.annotation.Nonnull;
+import org.opendaylight.mdsal.binding.javav2.api.BindingTransactionChain;
+import org.opendaylight.mdsal.binding.javav2.api.DataBroker;
+import org.opendaylight.mdsal.binding.javav2.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.javav2.api.DataTreeListener;
+import org.opendaylight.mdsal.binding.javav2.api.DataTreeLoopException;
+import org.opendaylight.mdsal.binding.javav2.api.DataTreeProducer;
+import org.opendaylight.mdsal.binding.javav2.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.javav2.api.WriteTransaction;
+import org.opendaylight.mdsal.binding.javav2.spec.base.InstanceIdentifier;
+import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
+import org.opendaylight.mdsal.common.api.AsyncReadWriteTransaction;
+import org.opendaylight.mdsal.common.api.TransactionChainListener;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+
+/**
+ * Utility {@link DataBroker} implementation which forwards all interface method
+ * invocation to a delegate instance.
+ */
+public abstract class ForwardingDataBroker extends ForwardingObject implements DataBroker {
+
+    @Override
+    protected abstract @Nonnull DataBroker delegate();
+
+    @Override
+    public ReadTransaction newReadOnlyTransaction() {
+        return delegate().newReadOnlyTransaction();
+    }
+
+    @Override
+    public AsyncReadWriteTransaction<InstanceIdentifier<?>, TreeNode> newReadWriteTransaction() {
+        return delegate().newReadWriteTransaction();
+    }
+
+    @Override
+    public WriteTransaction newWriteOnlyTransaction() {
+        return delegate().newWriteOnlyTransaction();
+    }
+
+    @Nonnull
+    @Override
+    public <T extends DataTreeListener> ListenerRegistration<T> registerListener(@Nonnull T listener,
+            @Nonnull Collection<DataTreeIdentifier<?>> subtrees, boolean allowRxMerges,
+            @Nonnull Collection<DataTreeProducer> producers) throws DataTreeLoopException {
+        return delegate().registerListener(listener, subtrees, allowRxMerges, producers);
+    }
+
+    @Override
+    public DataTreeProducer createProducer(Collection<DataTreeIdentifier<?>> subtrees) {
+        return delegate().createProducer(subtrees);
+    }
+
+    @Override
+    public BindingTransactionChain createTransactionChain(TransactionChainListener listener) {
+        return delegate().createTransactionChain(listener);
+    }
+
+}
diff --git a/binding2/mdsal-binding2-spi/src/main/java/org/opendaylight/mdsal/binding/javav2/spi/ForwardingReadTransaction.java b/binding2/mdsal-binding2-spi/src/main/java/org/opendaylight/mdsal/binding/javav2/spi/ForwardingReadTransaction.java
new file mode 100644 (file)
index 0000000..7c17bb8
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2017, 2018 Red Hat, Inc. and others.
+ *
+ * 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.mdsal.binding.javav2.spi;
+
+import com.google.common.collect.ForwardingObject;
+import java.util.function.BiConsumer;
+import org.opendaylight.mdsal.binding.javav2.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+
+/**
+ * Utility {@link ReadTransaction} implementation which forwards all interface method
+ * invocation to a delegate instance.
+ */
+public class ForwardingReadTransaction extends ForwardingObject implements ReadTransaction {
+
+    private final ReadTransaction delegate;
+
+    protected ForwardingReadTransaction(ReadTransaction delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    protected ReadTransaction delegate() {
+        return delegate;
+    }
+
+    @Override
+    public <T extends TreeNode> void read(LogicalDatastoreType store,
+            org.opendaylight.mdsal.binding.javav2.spec.base.InstanceIdentifier<T> path,
+            BiConsumer<ReadFailedException, T> callback) {
+        delegate.read(store, path, callback);
+    }
+
+    @Override
+    public Object getIdentifier() {
+        return delegate.getIdentifier();
+    }
+
+    @Override
+    public void close() {
+        delegate.close();
+    }
+}
diff --git a/binding2/mdsal-binding2-spi/src/main/java/org/opendaylight/mdsal/binding/javav2/spi/ForwardingWriteTransaction.java b/binding2/mdsal-binding2-spi/src/main/java/org/opendaylight/mdsal/binding/javav2/spi/ForwardingWriteTransaction.java
new file mode 100644 (file)
index 0000000..19c1459
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright © 2017, 2018 Red Hat, Inc. and others.
+ *
+ * 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.mdsal.binding.javav2.spi;
+
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.FluentFuture;
+import org.opendaylight.mdsal.binding.javav2.api.WriteTransaction;
+import org.opendaylight.mdsal.binding.javav2.spec.base.InstanceIdentifier;
+import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+
+/**
+ * Utility {@link WriteTransaction} implementation which forwards all interface method
+ * invocation to a delegate instance.
+ */
+public class ForwardingWriteTransaction extends ForwardingObject implements WriteTransaction {
+
+    private final WriteTransaction delegate;
+
+    protected ForwardingWriteTransaction(WriteTransaction delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    protected WriteTransaction delegate() {
+        return delegate;
+    }
+
+    @Override
+    public <T extends TreeNode> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
+        delegate.put(store, path, data);
+    }
+
+    @Override
+    public <T extends TreeNode> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
+            boolean createMissingParents) {
+        put(store, path, data, createMissingParents);
+    }
+
+    @Override
+    public <T extends TreeNode> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
+        delegate.merge(store, path, data);
+    }
+
+    @Override
+    public <T extends TreeNode> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
+            boolean createMissingParents) {
+        delegate.merge(store, path, data, createMissingParents);
+    }
+
+    @Override
+    public void delete(LogicalDatastoreType store, InstanceIdentifier<?> path) {
+        delegate.delete(store, path);
+    }
+
+    @Override
+    public boolean cancel() {
+        return delegate.cancel();
+    }
+
+    @Override
+    public FluentFuture<? extends CommitInfo> commit() {
+        return delegate.commit();
+    }
+
+    @Override
+    public Object getIdentifier() {
+        return delegate.getIdentifier();
+    }
+}
index 15c5df0ab4d3de778689cb8b7e580d5bc3f3dd7a..48608e7fb7bb1fe6d54b525df07576e87eb5799a 100644 (file)
@@ -40,6 +40,7 @@
         <module>mdsal-binding2-runtime</module>
         <module>mdsal-binding2-dom-codec</module>
         <module>mdsal-binding2-dom-adapter</module>
+        <module>mdsal-binding2-spi</module>
 
         <!-- binding2 utils and testing models -->
         <module>mdsal-binding2-util</module>
index 627656646b59a0913d2b9ed8cae282267151153e..4e8bde0e58dd1badfc48c74af69cea97add3c1e1 100644 (file)
                 <artifactId>mdsal-common-api</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.opendaylight.mdsal</groupId>
+                <artifactId>mdsal-common-util</artifactId>
+                <version>${project.version}</version>
+            </dependency>
 
             <dependency>
                 <groupId>org.opendaylight.mdsal</groupId>
                 <artifactId>mdsal-binding2-dom-adapter</artifactId>
                 <version>0.13.0-SNAPSHOT</version>
             </dependency>
+            <dependency>
+                <groupId>org.opendaylight.mdsal</groupId>
+                <artifactId>mdsal-binding2-spi</artifactId>
+                <version>0.13.0-SNAPSHOT</version>
+            </dependency>
             <dependency>
                 <groupId>org.opendaylight.mdsal</groupId>
                 <artifactId>mdsal-binding2-test-model</artifactId>
index fca631c9a14e767534f0bf536e202f26167548c4..a477bbf781740ab0f695c3455de9b88df969cc97 100644 (file)
             <groupId>${project.groupId}</groupId>
             <artifactId>mdsal-binding2-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>mdsal-binding2-spi</artifactId>
+        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>mdsal-binding2-util</artifactId>
index 77713a8b46fa3150a110076ac1f4d7a94247ac45..0e1d7c385cbaec95e6710b299e092d98d3571889 100644 (file)
@@ -53,5 +53,9 @@
             <groupId>${project.groupId}</groupId>
             <artifactId>mdsal-common-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>mdsal-common-util</artifactId>
+        </dependency>
     </dependencies>
 </project>
diff --git a/common/mdsal-common-util/pom.xml b/common/mdsal-common-util/pom.xml
new file mode 100644 (file)
index 0000000..d73a0c5
--- /dev/null
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright © 2018 Red Hat, Inc. and others.
+
+ 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
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.opendaylight.odlparent</groupId>
+        <artifactId>bundle-parent</artifactId>
+        <version>3.1.3</version>
+        <relativePath/>
+    </parent>
+
+    <groupId>org.opendaylight.mdsal</groupId>
+    <artifactId>mdsal-common-util</artifactId>
+    <version>2.5.0-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.opendaylight.mdsal</groupId>
+                <artifactId>mdsal-artifacts</artifactId>
+                <version>2.5.0-SNAPSHOT</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yangtools-artifacts</artifactId>
+                <version>2.0.7</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-common-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>concepts</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file
diff --git a/common/mdsal-common-util/src/main/java/org/opendaylight/mdsal/common/util/ForwardingAsyncReadWriteTransaction.java b/common/mdsal-common-util/src/main/java/org/opendaylight/mdsal/common/util/ForwardingAsyncReadWriteTransaction.java
new file mode 100644 (file)
index 0000000..c39aa0c
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright © 2017, 2018 Red Hat, Inc. and others.
+ *
+ * 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.mdsal.common.util;
+
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.FluentFuture;
+import org.opendaylight.mdsal.common.api.AsyncReadWriteTransaction;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yangtools.concepts.Path;
+
+/**
+ * Utility {@link AsyncReadWriteTransaction} implementation which forwards all interface method
+ * invocation to a delegate instance.
+ */
+public class ForwardingAsyncReadWriteTransaction<P extends Path<P>, D> extends ForwardingObject
+        implements AsyncReadWriteTransaction<P, D> {
+
+    private final AsyncReadWriteTransaction<P, D> delegate;
+
+    protected ForwardingAsyncReadWriteTransaction(AsyncReadWriteTransaction<P, D> delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    protected AsyncReadWriteTransaction<P, D> delegate() {
+        return delegate;
+    }
+
+    @Override
+    public Object getIdentifier() {
+        return delegate.getIdentifier();
+    }
+
+    @Override
+    public boolean cancel() {
+        return delegate.cancel();
+    }
+
+    @Override
+    public FluentFuture<? extends CommitInfo> commit() {
+        return delegate.commit();
+    }
+
+    @Override
+    public void delete(LogicalDatastoreType store, P path) {
+        delegate.delete(store, path);
+    }
+
+    @Override
+    public void close() {
+        delegate.close();
+    }
+}
index a3c1e37f6860d20b7fd43c4835e7778d6f6d4625..fac6bdc88a7112cb800b800cbbb81d1e9cf27015 100644 (file)
@@ -35,5 +35,6 @@
       <module>artifacts</module>
       <module>features</module>
       <module>mdsal-common-api</module>
+      <module>mdsal-common-util</module>
     </modules>
 </project>