Fix AbstractDOMShardTreeChangePublisher's initial data change event
[mdsal.git] / dom / mdsal-dom-spi / src / main / java / org / opendaylight / mdsal / dom / spi / store / DOMStoreTreeChangePublisher.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.spi.store;
9
10 import javax.annotation.Nonnull;
11 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
12 import org.opendaylight.yangtools.concepts.ListenerRegistration;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14
15 /**
16  * Interface implemented by DOMStore implementations which allow registration
17  * of {@link DOMDataTreeChangeListener} instances.
18  */
19 public interface DOMStoreTreeChangePublisher {
20     /**
21      * Registers a {@link DOMDataTreeChangeListener} to receive
22      * notifications when data changes under a given path in the conceptual data
23      * tree.
24      * <p>
25      * You are able to register for notifications  for any node or subtree
26      * which can be represented using {@link YangInstanceIdentifier}.
27      * <p>
28      * You are able to register for data change notifications for a subtree or leaf
29      * even if it does not exist. You will receive notification once that node is
30      * created.
31      * <p>
32      * If there is any pre-existing data in data tree on path for which you are
33      * registering, you will receive initial data change event, which will
34      * contain all pre-existing data, marked as created. If the data at the supplied
35      * path does not exist, you will also receive initial data change event, which will
36      * contain empty data tree modification, marked as unmodified.
37      * <p>
38      * This method returns a {@link ListenerRegistration} object. To
39      * "unregister" your listener for changes call the {@link ListenerRegistration#close()}
40      * method on this returned object.
41      * <p>
42      * You MUST explicitly unregister your listener when you no longer want to receive
43      * notifications. This is especially true in OSGi environments, where failure to
44      * do so during bundle shutdown can lead to stale listeners being still registered.
45      *
46      * @param treeId   Data tree identifier of the subtree which should be watched for
47      *                 changes.
48      * @param listener Listener instance which is being registered
49      * @return Listener registration object, which may be used to unregister
50      * your listener using {@link ListenerRegistration#close()} to stop
51      * delivery of change events.
52      */
53     @Nonnull
54     <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(@Nonnull YangInstanceIdentifier treeId, @Nonnull L listener);
55 }