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
9 package org.opendaylight.groupbasedpolicy.ne.location.provider;
11 import java.util.Collection;
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
15 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
16 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
17 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.Endpoints;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.AddressEndpoints;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.address.endpoints.AddressEndpoint;
21 import org.opendaylight.yangtools.concepts.ListenerRegistration;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 public class EndpointsListener implements DataTreeChangeListener<AddressEndpoint>{
28 private static final Logger LOG = LoggerFactory.getLogger(EndpointsListener.class);
30 private NeLocationProvider listener;
31 private ListenerRegistration<EndpointsListener> listenerRegistration;
33 public EndpointsListener (DataBroker dataBroker, NeLocationProvider listener) {
34 this.listener = listener;
35 this.listenerRegistration = dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
36 InstanceIdentifier.builder(Endpoints.class)
37 .child(AddressEndpoints.class).child(AddressEndpoint.class).build()), this);
38 LOG.info("NE location provider registered for Endpoints listening");
42 public void onDataTreeChanged(Collection<DataTreeModification<AddressEndpoint>> changes) {
43 listener.onEndpointsChange(changes);
47 this.listenerRegistration.close();