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 DOMDataBroker.Extension} which allows users to register for changes to a subtree.
16 public interface DOMDataTreeChangeService extends DOMDataBroker.Extension {
18 * Registers a {@link DOMDataTreeChangeListener} to receive notifications when data changes under a given path in
19 * the conceptual data tree.
22 * You are able to register for notifications for any node or subtree which can be represented using
23 * {@link DOMDataTreeIdentifier}.
26 * You are able to register for data change notifications for a subtree or leaf even if it does not exist. You will
27 * receive notification once that node is created.
30 * If there is any pre-existing data in the data tree for the path for which you are registering, you will receive
31 * an initial data change event, which will contain all pre-existing data, marked as created.
34 * This method returns a {@link ListenerRegistration} object. To "unregister" your listener for changes call
35 * the {@link ListenerRegistration#close()} method on the returned object.
38 * You MUST explicitly unregister your listener when you no longer want to receive notifications. This is especially
39 * true in OSGi environments, where failure to do so during bundle shutdown can lead to stale listeners being still
42 * @param treeId Data tree identifier of the subtree which should be watched for changes.
43 * @param listener Listener instance which is being registered
44 * @param <L> Listener type
45 * @return Listener registration object, which may be used to unregister your listener using
46 * {@link ListenerRegistration#close()} to stop delivery of change events.
47 * @throws NullPointerException if any of the arguments is null
49 // FIXME: just Registration
50 <L extends DOMDataTreeChangeListener> @NonNull ListenerRegistration<L> registerDataTreeChangeListener(
51 @NonNull DOMDataTreeIdentifier treeId, @NonNull L listener);