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