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.renderer.vpp.listener;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
13 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.groupbasedpolicy.renderer.vpp.event.VppEndpointConfEvent;
16 import org.opendaylight.groupbasedpolicy.util.DataTreeChangeHandler;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.Config;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.VppEndpoint;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 import com.google.common.base.Preconditions;
24 import com.google.common.eventbus.EventBus;
26 public class VppEndpointListener extends DataTreeChangeHandler<VppEndpoint> {
28 private static final Logger LOG = LoggerFactory.getLogger(VppEndpointListener.class);
29 private EventBus eventBus;
31 public VppEndpointListener(DataBroker dataProvider, EventBus eventBus) {
33 this.eventBus = Preconditions.checkNotNull(eventBus);
34 registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
35 InstanceIdentifier.builder(Config.class).child(VppEndpoint.class).build()));
39 protected void onWrite(DataObjectModification<VppEndpoint> rootNode,
40 InstanceIdentifier<VppEndpoint> rootIdentifier) {
41 VppEndpointConfEvent event =
42 new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter());
43 LOG.trace("Dispatching event on write: {}", event.getClass());
48 protected void onDelete(DataObjectModification<VppEndpoint> rootNode,
49 InstanceIdentifier<VppEndpoint> rootIdentifier) {
50 VppEndpointConfEvent event =
51 new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter());
52 LOG.trace("Dispatching event on delete: {}", event.getClass());
57 protected void onSubtreeModified(DataObjectModification<VppEndpoint> rootNode,
58 InstanceIdentifier<VppEndpoint> rootIdentifier) {
59 VppEndpointConfEvent event =
60 new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter());
61 LOG.trace("Dispatching event on subtree modified: {}", event.getClass());