2 * Copyright (c) 2016 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.lispflowmapping.implementation.mdsal;
10 import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
11 import org.opendaylight.mdsal.binding.api.DataBroker;
12 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
13 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
14 import org.opendaylight.yangtools.concepts.ListenerRegistration;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19 * The superclass for the different MD-SAL data change event listeners.
22 public abstract class AbstractDataListener<T extends DataObject> implements ClusteredDataTreeChangeListener<T> {
23 private DataBroker broker;
24 private InstanceIdentifier<T> path;
25 private ListenerRegistration<ClusteredDataTreeChangeListener<T>> configRegistration;
26 private ListenerRegistration<ClusteredDataTreeChangeListener<T>> operRegistration;
28 void registerDataChangeListener() {
29 final DataTreeIdentifier<T> configDataTreeIdentifier = DataTreeIdentifier.create(
30 LogicalDatastoreType.CONFIGURATION, path);
31 final DataTreeIdentifier<T> operDataTreeIdentifier = DataTreeIdentifier.create(
32 LogicalDatastoreType.OPERATIONAL, path);
34 configRegistration = broker.registerDataTreeChangeListener(configDataTreeIdentifier, this);
35 operRegistration = broker.registerDataTreeChangeListener(operDataTreeIdentifier, this);
38 public void closeDataChangeListener() {
39 configRegistration.close();
40 operRegistration.close();
43 void setBroker(DataBroker broker) {
47 void setPath(InstanceIdentifier<T> path) {