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