2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.dom.api;
10 import javax.annotation.Nonnull;
11 import org.opendaylight.yangtools.concepts.ListenerRegistration;
14 * A {@link DOMServiceExtension} which allows users to register for changes to a
17 public interface DOMDataTreeChangeService extends DOMDataBrokerExtension {
19 * Registers a {@link DOMDataTreeChangeListener} to receive notifications when data changes
20 * under a given path in the conceptual data tree.
22 * You are able to register for notifications for any node or subtree which can be represented
23 * using {@link DOMDataTreeIdentifier}.
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.
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.
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.
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.
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.
47 @Nonnull <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener(@Nonnull DOMDataTreeIdentifier treeId, @Nonnull L listener);