586702605ab61bb42018d184838d80939b18f797
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMTransactionFactory.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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  */
8 package org.opendaylight.mdsal.dom.api;
9
10 import org.opendaylight.mdsal.common.api.AsyncDataTransactionFactory;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
12 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
13
14 /**
15  * A factory which allocates new transactions to operate on the data tree.
16  *
17  * <p>
18  * <b>Note:</b> This interface is not intended to be used directly, but rather via subinterfaces
19  * which introduces additional semantics to allocated transactions.
20  * <ul>
21  * <li> {@link DOMDataBroker}
22  * <li> {@link DOMTransactionChain}
23  * </ul>
24  *
25  * <p>
26  * All operations on the data tree are performed via one of the transactions:
27  * <ul>
28  * <li>Read-Only - allocated using {@link #newReadOnlyTransaction()}
29  * <li>Write-Only - allocated using {@link #newWriteOnlyTransaction()}
30  * </ul>
31  *
32  * <p>
33  * These transactions provides a stable isolated view of the data tree, which is guaranteed to be
34  * not affected by other concurrent transactions, until transaction is committed.
35  *
36  * <p>
37  * For a detailed explanation of how transaction are isolated and how transaction-local changes are
38  * committed to global data tree, see {@link DOMDataTreeReadTransaction}, {@link DOMDataTreeWriteTransaction}
39  * and {@link DOMDataTreeWriteTransaction#commit()}.
40  *
41  * <p>
42  * It is strongly recommended to use the type of transaction, which provides only the minimal
43  * capabilities you need. This allows for optimizations at the data broker / data store level. For
44  * example, implementations may optimize the transaction for reading if they know ahead of time that
45  * you only need to read data - such as not keeping additional meta-data, which may be required for
46  * write transactions.
47  *
48  * <p>
49  * <b>Implementation Note:</b> This interface is not intended to be implemented by users of MD-SAL,
50  * but only to be consumed by them.
51  *
52  * @see DOMDataBroker
53  * @see DOMTransactionChain
54  */
55 public interface DOMTransactionFactory
56         extends AsyncDataTransactionFactory<YangInstanceIdentifier, NormalizedNode<?, ?>> {
57
58     @Override
59     DOMDataTreeReadTransaction newReadOnlyTransaction();
60
61     @Override
62     DOMDataTreeWriteTransaction newWriteOnlyTransaction();
63
64     @Override
65     DOMDataTreeReadWriteTransaction newReadWriteTransaction();
66 }