X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-spi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcore%2Fspi%2Fdata%2FSnapshotBackedTransactions.java;h=7a775e8341902c286a6055d04c5c53422c068d52;hp=3368c8aee101ad58b2eabd8d0b106613cf387d69;hb=a885056d2fddd17e3879aca9b75fe597e3be7953;hpb=2b2517144e4eb9c17d9b41e9d9ec20d0264f5e12 diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedTransactions.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedTransactions.java index 3368c8aee1..7a775e8341 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedTransactions.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/SnapshotBackedTransactions.java @@ -7,7 +7,10 @@ */ package org.opendaylight.controller.sal.core.spi.data; +import static java.util.Objects.requireNonNull; + import com.google.common.annotations.Beta; +import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedReadTransaction.TransactionClosePrototype; import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction.TransactionReadyPrototype; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; @@ -26,9 +29,25 @@ public final class SnapshotBackedTransactions { * @param identifier Transaction Identifier * @param debug Enable transaction debugging * @param snapshot Snapshot which will be modified. + * @return A new read-only transaction */ - public static SnapshotBackedReadTransaction newReadTransaction(final T identifier, final boolean debug, final DataTreeSnapshot snapshot) { - return new SnapshotBackedReadTransaction(identifier, debug, snapshot); + public static SnapshotBackedReadTransaction newReadTransaction(final T identifier, final boolean debug, + final DataTreeSnapshot snapshot) { + return new SnapshotBackedReadTransaction<>(identifier, debug, snapshot, null); + } + + /** + * Creates a new read-only transaction. + * + * @param identifier Transaction Identifier + * @param debug Enable transaction debugging + * @param snapshot Snapshot which will be modified. + * @param closeImpl Implementation of close method + * @return A new read-only transaction + */ + public static SnapshotBackedReadTransaction newReadTransaction(final T identifier, + final boolean debug, final DataTreeSnapshot snapshot, final TransactionClosePrototype closeImpl) { + return new SnapshotBackedReadTransaction<>(identifier, debug, snapshot, requireNonNull(closeImpl)); } /** @@ -38,10 +57,11 @@ public final class SnapshotBackedTransactions { * @param debug Enable transaction debugging * @param snapshot Snapshot which will be modified. * @param readyImpl Implementation of ready method. + * @return A new read-write transaction */ - public static SnapshotBackedReadWriteTransaction newReadWriteTransaction(final T identifier, final boolean debug, - final DataTreeSnapshot snapshot, final TransactionReadyPrototype readyImpl) { - return new SnapshotBackedReadWriteTransaction(identifier, debug, snapshot, readyImpl); + public static SnapshotBackedReadWriteTransaction newReadWriteTransaction(final T identifier, + final boolean debug, final DataTreeSnapshot snapshot, final TransactionReadyPrototype readyImpl) { + return new SnapshotBackedReadWriteTransaction<>(identifier, debug, snapshot, readyImpl); } /** @@ -51,9 +71,10 @@ public final class SnapshotBackedTransactions { * @param debug Enable transaction debugging * @param snapshot Snapshot which will be modified. * @param readyImpl Implementation of ready method. + * @return A new write transaction */ public static SnapshotBackedWriteTransaction newWriteTransaction(final T identifier, final boolean debug, final DataTreeSnapshot snapshot, final TransactionReadyPrototype readyImpl) { - return new SnapshotBackedWriteTransaction(identifier, debug, snapshot, readyImpl); + return new SnapshotBackedWriteTransaction<>(identifier, debug, snapshot, readyImpl); } }