Merge "Fix warnings reported in toaster"
[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
13 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
14 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
15 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
16 import org.opendaylight.yangtools.concepts.ListenerRegistration;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19 import org.opendaylight.yangtools.yang.common.RpcResult;
20
21 public interface DataModificationTransaction extends DataModification<InstanceIdentifier<? extends DataObject>, DataObject> {
22
23     /**
24      * Returns an unique identifier for transaction
25      *
26      */
27     @Override
28     public Object getIdentifier();
29
30     /**
31      * Initiates a two-phase commit of candidate data.
32      *
33      * <p>
34      * The {@link Consumer} could initiate a commit of candidate data
35      *
36      * <p>
37      * The successful commit changes the state of the system and may affect
38      * several components.
39      *
40      * <p>
41      * The effects of successful commit of data are described in the
42      * specifications and YANG models describing the {@link Provider} components
43      * of controller. It is assumed that {@link Consumer} has an understanding
44      * of this changes.
45      *
46      *
47      * @see DataCommitHandler for further information how two-phase commit is
48      *      processed.
49      * @param store
50      *            Identifier of the store, where commit should occur.
51      * @return Result of the commit, containing success information or list of
52      *         encountered errors, if commit was not successful.
53      */
54     @Override
55     public Future<RpcResult<TransactionStatus>> commit();
56
57
58
59     /**
60      * Register a listener for transaction
61      *
62      * @param listener
63      * @return
64      */
65     ListenerRegistration<DataTransactionListener> registerListener(DataTransactionListener listener);
66
67
68
69     /**
70      * Listener for transaction state changes
71      *
72      *
73      */
74     public interface DataTransactionListener extends EventListener {
75         /**
76          * Callback is invoked after each transaction status change.
77          *
78          * @param transaction Transaction
79          * @param status New status
80          */
81         void onStatusUpdated(DataModificationTransaction transaction,TransactionStatus status);
82     }
83 }