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 org.eclipse.jdt.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.
23 * You are able to register for notifications for any node or subtree which can be represented
24 * using {@link DOMDataTreeIdentifier}.
27 * You are able to register for data change notifications for a subtree or leaf even if it does
28 * not exist. You will receive notification once that node is created.
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 contain all
33 * pre-existing data, marked as created.
36 * This method returns a {@link ListenerRegistration} object. To "unregister" your listener for
37 * changes call the {@link ListenerRegistration#close()} method on the returned object.
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 do so during
42 * bundle shutdown can lead to stale listeners being still registered.
44 * @param treeId Data tree identifier of the subtree which should be watched for changes.
45 * @param listener Listener instance which is being registered
46 * @param <L> Listener type
47 * @return Listener registration object, which may be used to unregister your listener using
48 * {@link ListenerRegistration#close()} to stop delivery of change events.
49 * @throws NullPointerException if any of the arguments is null
51 <L extends DOMDataTreeChangeListener> @NonNull ListenerRegistration<L> registerDataTreeChangeListener(
52 @NonNull DOMDataTreeIdentifier treeId, @NonNull L listener);