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