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.ListenableFuture;
14 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
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.common.api.data.TransactionCommitFailedException;
18 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
19 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
20 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
21 import org.opendaylight.yangtools.yang.common.RpcResult;
22 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
23 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
25 public class ReadWriteTx implements DOMDataReadWriteTransaction {
27 private final DOMDataReadTransaction delegateReadTx;
28 private final DOMDataWriteTransaction delegateWriteTx;
30 public ReadWriteTx(final DOMDataReadTransaction delegateReadTx, final DOMDataWriteTransaction delegateWriteTx) {
31 this.delegateReadTx = delegateReadTx;
32 this.delegateWriteTx = delegateWriteTx;
36 public boolean cancel() {
37 return delegateWriteTx.cancel();
41 public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
42 delegateWriteTx.put(store, path, data);
46 public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
47 delegateWriteTx.merge(store, path, data);
51 public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
52 delegateWriteTx.delete(store, path);
56 public CheckedFuture<Void, TransactionCommitFailedException> submit() {
57 return delegateWriteTx.submit();
61 public ListenableFuture<RpcResult<TransactionStatus>> commit() {
62 return delegateWriteTx.commit();
66 public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
67 final LogicalDatastoreType store, final YangInstanceIdentifier path) {
68 return delegateReadTx.read(store, path);
71 @Override public CheckedFuture<Boolean, ReadFailedException> exists(
72 final LogicalDatastoreType store,
73 final YangInstanceIdentifier path) {
74 return delegateReadTx.exists(store, path);
78 public Object getIdentifier() {