7e72bd488fdc9789037b351e29c6204211fe93ec
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / sal / binding / api / data / DataModificationTransaction.java
1 /*
2  * Copyright (c) 2013 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.controller.sal.binding.api.data;
9
10 import java.util.EventListener;
11 import java.util.concurrent.Future;
12 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
13 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
14 import org.opendaylight.yangtools.concepts.ListenerRegistration;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 import org.opendaylight.yangtools.yang.common.RpcResult;
18
19 /**
20  * @deprecated Replaced by more specific transaction types. Please use
21  *          {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newReadOnlyTransaction()},
22  *          {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newReadWriteTransaction()}
23  *          or
24  *          {@link org.opendaylight.controller.md.sal.binding.api.DataBroker#newWriteOnlyTransaction()}.
25  */
26 @Deprecated
27 public interface DataModificationTransaction extends
28         DataModification<InstanceIdentifier<? extends DataObject>, DataObject> {
29     /**
30      * Returns an unique identifier for transaction
31      *
32      */
33     @Override
34     Object getIdentifier();
35
36     /**
37      * Initiates a two-phase commit of candidate data.
38      *
39      * <p>
40      * The Consumer could initiate a commit of candidate data
41      *
42      * <p>
43      * The successful commit changes the state of the system and may affect
44      * several components.
45      *
46      * <p>
47      * The effects of successful commit of data are described in the
48      * specifications and YANG models describing the Provider components
49      * of controller. It is assumed that the Consumer has an understanding
50      * of this changes.
51      *
52      *
53      * @return Result of the commit, containing success information or list of
54      *         encountered errors, if commit was not successful.
55      */
56     @Override
57     Future<RpcResult<TransactionStatus>> commit();
58
59     /**
60      * Register a listener for transaction
61      *
62      * @param listener
63      * @return
64      */
65     ListenerRegistration<DataTransactionListener> registerListener(DataTransactionListener listener);
66
67     /**
68      * Listener for transaction state changes
69      */
70     interface DataTransactionListener extends EventListener {
71         /**
72          * Callback is invoked after each transaction status change.
73          *
74          * @param transaction Transaction
75          * @param status New status
76          */
77         void onStatusUpdated(DataModificationTransaction transaction,TransactionStatus status);
78     }
79 }