Do not generate 'isFoo()' methods
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMDataTreeProducer.java
1 /*
2  * Copyright (c) 2015 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  */
8 package org.opendaylight.mdsal.dom.api;
9
10 import java.util.Collection;
11 import org.eclipse.jdt.annotation.NonNull;
12
13 /**
14  * A data producer context. It allows transactions to be submitted to the subtrees
15  * specified at instantiation time. At any given time there may be a single transaction
16  * open. It needs to be either submitted or cancelled before another one can be open.
17  * Once a transaction is submitted, it will proceed to be committed asynchronously.
18  *
19  * <p>
20  * Each instance has an upper bound on the number of transactions which can be in-flight,
21  * once that capacity is exceeded, an attempt to create a new transaction will block
22  * until some transactions complete.
23  *
24  * <p>
25  * Each {@link DOMDataTreeProducer} can be in two logical states, bound and unbound,
26  * which define the lifecycle rules for when is it legal to create and submit transactions
27  * in relationship with {@link DOMDataTreeListener} callbacks.
28  *
29  * <p>
30  * When a producer is first created, it is unbound. In this state the producer can be
31  * accessed by any application thread to allocate or submit transactions, as long as
32  * the 'single open transaction' rule is maintained. The producer and any transaction
33  * object MUST NOT be accessed, directly or indirectly, from a {@link DOMDataTreeListener}
34  * callback.
35  *
36  * <p>
37  * When a producer is referenced in a call to {@link DOMDataTreeService#registerListener(DOMDataTreeListener,
38  * Collection, boolean, Collection)},
39  * an attempt will be made to bind the producer to the specified {@link DOMDataTreeListener}.
40  * Such an attempt will fail the producer is already bound, or it has an open transaction.
41  * Once bound, the producer can only be accessed from within the {@link DOMDataTreeListener}
42  * callback on that particular instance. Any transaction which is not submitted by the
43  * time the callback returns will be implicitly cancelled. A producer becomes unbound
44  * when the listener it is bound to becomes unregistered.
45  *
46  * @deprecated This interface is scheduled for removal in the next major release.
47  */
48 @Deprecated(forRemoval = true)
49 public interface DOMDataTreeProducer extends DOMDataTreeProducerFactory, AutoCloseable {
50     /**
51      * Allocate a new open transaction on this producer. Any and all transactions previously
52      * allocated must have been either submitted or cancelled by the time this method is invoked.
53      *
54      * @param isolated Indicates whether this transaction should be a barrier. A barrier transaction
55      *        is processed separately from any preceding transactions. Non-barrier transactions may
56      *        be merged and processed in a batch, such that any observers see the modifications
57      *        contained in them as if the modifications were made in a single transaction.
58      * @return A new {@link DOMDataTreeCursorAwareTransaction}
59      * @throws IllegalStateException if a previous transaction was not closed.
60      * @throws IllegalThreadStateException if the calling thread context does not match the
61      *         lifecycle rules enforced by the producer state (e.g. bound or unbound). This
62      *         exception is thrown on a best effort basis and programs should not rely on it for
63      *         correct operation.
64      */
65     @NonNull DOMDataTreeCursorAwareTransaction createTransaction(boolean isolated);
66
67     /**
68      * {@inheritDoc}.
69      *
70      * <p>
71      * When invoked on a {@link DOMDataTreeProducer}, this method has additional restrictions. There
72      * may not be an open transaction from this producer. The method needs to be invoked in
73      * appropriate context, e.g. bound or unbound.
74      *
75      * <p>
76      * Specified subtrees must be accessible by this producer. Accessible means they are a subset of
77      * the subtrees specified when the producer is instantiated. The set is further reduced as child
78      * producers are instantiated -- if you create a producer for /a and then a child for /a/b, /a/b
79      * is not accessible from the first producer.
80      * Once this method returns successfully, this (parent) producer loses the ability to access the
81      * specified paths until the resulting (child) producer is shut down.
82      *
83      * @throws IllegalStateException if there is an open transaction
84      * @throws IllegalArgumentException if subtrees contains a subtree which is not accessible by
85      *         this producer
86      * @throws IllegalThreadStateException if the calling thread context does not match the
87      *         lifecycle rules enforced by the producer state (e.g. bound or unbound). This
88      *         exception is thrown on a best effort basis and programs should not rely on it for
89      *         correct operation.
90      */
91     @Override
92     DOMDataTreeProducer createProducer(Collection<DOMDataTreeIdentifier> subtrees);
93
94     /**
95      * {@inheritDoc}.
96      *
97      * @throws DOMDataTreeProducerBusyException when there is an open transaction.
98      */
99     @Override
100     void close() throws DOMDataTreeProducerException;
101 }