Bug 1073: Added support to DOMBrokerImpl for Transaction Chaining
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / broker / impl / DOMForwardedReadWriteTransaction.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */package org.opendaylight.controller.md.sal.dom.broker.impl;
8
9 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
10 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
11 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
12 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
13 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
14 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16
17 import com.google.common.base.Optional;
18 import com.google.common.collect.ImmutableMap;
19 import com.google.common.util.concurrent.ListenableFuture;
20
21 /**
22  * 
23  * Read-Write Transaction, which is composed of several
24  * {@link DOMStoreReadTransaction} transactions. Subtransaction is selected by
25  * {@link LogicalDatastoreType} type parameter in:
26  * 
27  * <ul>
28  * <li>{@link #read(LogicalDatastoreType, InstanceIdentifier)}
29  * <li>{@link #put(LogicalDatastoreType, InstanceIdentifier, NormalizedNode)}
30  * <li>{@link #delete(LogicalDatastoreType, InstanceIdentifier)}
31  * <li>{@link #merge(LogicalDatastoreType, InstanceIdentifier, NormalizedNode)}
32  * </ul>
33  * {@link #commit()} will result in invocation of
34  * {@link DOMDataCommitImplementation#commit(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction, Iterable)}
35  * invocation with all {@link DOMStoreThreePhaseCommitCohort} for underlying
36  * transactions.
37  * 
38  */
39 class DOMForwardedReadWriteTransaction extends DOMForwardedWriteTransaction<DOMStoreReadWriteTransaction> implements
40         DOMDataReadWriteTransaction {
41
42     protected DOMForwardedReadWriteTransaction(final Object identifier,
43             final ImmutableMap<LogicalDatastoreType, DOMStoreReadWriteTransaction> backingTxs,
44             final DOMDataCommitImplementation commitImpl) {
45         super(identifier, backingTxs, commitImpl);
46     }
47
48     @Override
49     public ListenableFuture<Optional<NormalizedNode<?, ?>>> read(final LogicalDatastoreType store,
50             final InstanceIdentifier path) {
51         return getSubtransaction(store).read(path);
52     }
53 }