Merge "Startup arch - remove artifactId prefix from dir names."
[controller.git] / opendaylight / md-sal / sal-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 DOMService} which allows users to register for changes to a
15  * subtree.
16  */
17 public interface DOMDataTreeChangeService extends DOMService {
18     /**
19      * Registers a {@link DOMDataTreeChangeListener} to receive
20      * notifications when data changes under a given path in the conceptual data
21      * tree.
22      * <p>
23      * You are able to register for notifications  for any node or subtree
24      * which can be represented using {@link DOMDataTreeIdentifier}.
25      * <p>
26      *
27      * You are able to register for data change notifications for a subtree or leaf
28      * even if it does not exist. You will receive notification once that node is
29      * created.
30      * <p>
31      * If there is any pre-existing data in the data tree for the path for which you are
32      * registering, you will receive an initial data change event, which will
33      * contain all pre-existing data, marked as created.
34      *
35      * <p>
36      * This method returns a {@link ListenerRegistration} object. To
37      * "unregister" your listener for changes call the {@link ListenerRegistration#close()}
38      * method on the returned object.
39      * <p>
40      * You MUST explicitly unregister your listener when you no longer want to receive
41      * notifications. This is especially true in OSGi environments, where failure to
42      * do so during bundle shutdown can lead to stale listeners being still registered.
43      *
44      * @param treeId
45      *            Data tree identifier of the subtree which should be watched for
46      *            changes.
47      * @param listener
48      *            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 <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener(@Nonnull DOMDataTreeIdentifier treeId, @Nonnull L listener);
54 }