2 * Copyright (c) 2013 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.openflowplugin.openflow.md.core;
10 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
11 import org.opendaylight.openflowplugin.openflow.md.queue.PopListener;
12 import org.opendaylight.openflowplugin.statistics.MessageSpy;
13 import org.opendaylight.yangtools.yang.binding.Notification;
16 * general publisher to MD-SAL
18 * @param <T> type of supported notification
20 public class NotificationPopListener<T> implements PopListener<T> {
22 private MessageSpy<? super T> messageSpy;
23 private NotificationProviderService notificationProviderService;
26 * @param messageSpy the messageSpy to set
28 public void setMessageSpy(MessageSpy<? super T> messageSpy) {
29 this.messageSpy = messageSpy;
33 * @param notificationProviderService the notificationProviderService to set
35 public void setNotificationProviderService(
36 NotificationProviderService notificationProviderService) {
37 this.notificationProviderService = notificationProviderService;
41 public void onPop(T processedMessage) {
42 boolean published = false;
43 if(processedMessage instanceof Notification) {
44 if (notificationProviderService != null) {
45 notificationProviderService.publish((Notification) processedMessage);
46 messageSpy.spyMessage(processedMessage, MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_SUCCESS);
52 messageSpy.spyMessage(processedMessage, MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE);