2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.netconf.sal.connect.netconf.sal.tx;
11 import com.google.common.base.Optional;
12 import com.google.common.util.concurrent.CheckedFuture;
13 import com.google.common.util.concurrent.FluentFuture;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
16 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
17 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
18 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
19 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
20 import org.opendaylight.mdsal.common.api.CommitInfo;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
22 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
24 public class ReadWriteTx implements DOMDataReadWriteTransaction {
26 private final DOMDataReadTransaction delegateReadTx;
27 private final DOMDataWriteTransaction delegateWriteTx;
29 public ReadWriteTx(final DOMDataReadTransaction delegateReadTx, final DOMDataWriteTransaction delegateWriteTx) {
30 this.delegateReadTx = delegateReadTx;
31 this.delegateWriteTx = delegateWriteTx;
35 public boolean cancel() {
36 return delegateWriteTx.cancel();
40 public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
41 final NormalizedNode<?, ?> data) {
42 delegateWriteTx.put(store, path, data);
46 public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
47 final NormalizedNode<?, ?> data) {
48 delegateWriteTx.merge(store, path, data);
52 public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
53 delegateWriteTx.delete(store, path);
57 public @NonNull FluentFuture<? extends @NonNull CommitInfo> commit() {
58 return delegateWriteTx.commit();
62 public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
63 final LogicalDatastoreType store, final YangInstanceIdentifier path) {
64 return delegateReadTx.read(store, path);
67 @Override public CheckedFuture<Boolean, ReadFailedException> exists(
68 final LogicalDatastoreType store,
69 final YangInstanceIdentifier path) {
70 return delegateReadTx.exists(store, path);
74 public Object getIdentifier() {