7ddfcf7ab9db432c9272c4b136c094acbdae57b1
[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.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
12 import org.opendaylight.yangtools.concepts.Registration;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14
15 /**
16  * Interface implemented by DOMStore implementations which allow registration of {@link DOMDataTreeChangeListener}
17  * instances.
18  */
19 public interface DOMStoreTreeChangePublisher {
20     /**
21      * Registers a {@link DOMDataTreeChangeListener} to receive notifications when data changes under a given path in
22      * the conceptual data tree.
23      *
24      * <p>
25      * You are able to register for notifications  for any node or subtree which can be represented using
26      * {@link YangInstanceIdentifier}.
27      *
28      * <p>
29      * You are able to register for data change notifications for a subtree or leaf even if it does not exist. You will
30      * receive notification once that node is created.
31      *
32      * <p>
33      * If there is any pre-existing data in data tree on path for which you are registering, you will receive initial
34      * data change event, which will contain all pre-existing data, marked as created. If the data at the supplied path
35      * does not exist, you will also receive initial data change event, which will contain empty data tree modification,
36      * marked as unmodified.
37      *
38      * <p>
39      * This method returns a {@link Registration} object. To "unregister" your listener for changes call the
40      * {@link Registration#close()} method on this returned object.
41      *
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 Data tree identifier of the subtree which should be watched for changes.
48      * @param listener Listener instance which is being registered
49      * @return A {@link Registration} registration object, which may be used to unregister your listener using
50      *         {@link Registration#close()} to stop delivery of change events.
51      */
52     @NonNull Registration registerTreeChangeListener(@NonNull YangInstanceIdentifier treeId,
53         @NonNull DOMDataTreeChangeListener listener);
54 }