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.spi.store;
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
12 import org.opendaylight.yangtools.concepts.ListenerRegistration;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 * Interface implemented by DOMStore implementations which allow registration
17 * of {@link DOMDataTreeChangeListener} instances.
19 public interface DOMStoreTreeChangePublisher {
21 * Registers a {@link DOMDataTreeChangeListener} to receive
22 * notifications when data changes under a given path in the conceptual data
26 * You are able to register for notifications for any node or subtree
27 * which can be represented using {@link YangInstanceIdentifier}.
30 * You are able to register for data change notifications for a subtree or leaf
31 * even if it does not exist. You will receive notification once that node is
35 * If there is any pre-existing data in data tree on path for which you are
36 * registering, you will receive initial data change event, which will
37 * contain all pre-existing data, marked as created. If the data at the supplied
38 * path does not exist, you will also receive initial data change event, which will
39 * contain empty data tree modification, marked as unmodified.
42 * This method returns a {@link ListenerRegistration} object. To
43 * "unregister" your listener for changes call the {@link ListenerRegistration#close()}
44 * method on this returned object.
47 * You MUST explicitly unregister your listener when you no longer want to receive
48 * notifications. This is especially true in OSGi environments, where failure to
49 * do so during bundle shutdown can lead to stale listeners being still registered.
51 * @param treeId Data tree identifier of the subtree which should be watched for changes.
52 * @param listener Listener instance which is being registered
53 * @return Listener registration object, which may be used to unregister your listener using
54 * {@link ListenerRegistration#close()} to stop delivery of change events.
56 <L extends DOMDataTreeChangeListener> @NonNull ListenerRegistration<L> registerTreeChangeListener(
57 @NonNull YangInstanceIdentifier treeId, @NonNull L listener);