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
9 package org.opendaylight.openflowplugin.applications.notification.supplier.impl;
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemovedBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
24 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 * Implementation define a contract between {@link FlowCapableNode} data object
28 * and {@link NodeUpdated} and {@link NodeRemoved} notifications.
30 public class NodeNotificationSupplierImpl extends
31 AbstractNotificationSupplierForItemRoot<FlowCapableNode, NodeUpdated, NodeRemoved> {
33 private static final InstanceIdentifier<FlowCapableNode> wildCardedInstanceIdent = getNodeWildII().augmentation(FlowCapableNode.class);
36 * Constructor register supplier as DataChangeLister and create wildCarded InstanceIdentifier.
38 * @param notifProviderService - {@link NotificationProviderService}
39 * @param db - {@link DataBroker}
41 public NodeNotificationSupplierImpl(final NotificationProviderService notifProviderService, final DataBroker db) {
42 super(notifProviderService, db, FlowCapableNode.class);
46 public InstanceIdentifier<FlowCapableNode> getWildCardPath() {
47 return wildCardedInstanceIdent;
51 public NodeUpdated createNotification(final FlowCapableNode o, final InstanceIdentifier<FlowCapableNode> ii) {
52 Preconditions.checkArgument(o != null);
53 Preconditions.checkArgument(ii != null);
54 final FlowCapableNodeUpdatedBuilder flowNodeNotifBuilder = new FlowCapableNodeUpdatedBuilder(o);
55 final NodeUpdatedBuilder notifBuilder = new NodeUpdatedBuilder();
56 notifBuilder.setId(ii.firstKeyOf(Node.class, NodeKey.class).getId());
57 notifBuilder.setNodeRef(new NodeRef(getNodeII(ii)));
58 notifBuilder.addAugmentation(FlowCapableNodeUpdated.class, flowNodeNotifBuilder.build());
59 return notifBuilder.build();
63 public NodeRemoved deleteNotification(final InstanceIdentifier<FlowCapableNode> path) {
64 Preconditions.checkArgument(path != null);
65 final NodeRemovedBuilder delNodeNotifBuilder = new NodeRemovedBuilder();
66 delNodeNotifBuilder.setNodeRef(new NodeRef(path));
67 return delNodeNotifBuilder.build();