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.controller.sal.demo;
10 import java.util.ArrayList;
11 import java.util.Collection;
12 import java.util.Collections;
13 import java.util.List;
15 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
16 import org.opendaylight.controller.sal.core.api.notify.NotificationProviderService;
17 import org.opendaylight.controller.yang.data.api.Node;
18 import org.opendaylight.controller.yang.data.util.Nodes;
21 public class DemoProviderImpl implements
22 org.opendaylight.controller.sal.core.api.Provider {
24 private ProviderSession session;
25 private NotificationProviderService notifier;
28 public void onSessionInitiated(ProviderSession session) {
29 this.session = session;
30 notifier = session.getService(NotificationProviderService.class);
34 public Collection<ProviderFunctionality> getProviderFunctionality() {
35 return Collections.emptySet();
38 public void sendAlertNotification(String content) {
39 List<Node<?>> nodes = new ArrayList<Node<?>>();
40 nodes.add(DemoUtils.contentNode(content));
42 if (notifier == null) {
43 System.out.println("Provider: Error: Session not available");
45 .println(" Notification Service not available");
48 notifier.sendNotification(Nodes.containerNode(
49 DemoUtils.alertNotification, nodes));
52 public void sendChangeNotification(String content) {
53 List<Node<?>> nodes = new ArrayList<Node<?>>();
54 nodes.add(DemoUtils.contentNode(content));
56 if (notifier == null) {
57 System.out.println("Provider: Error: Session not available");
59 .println(" Notification Service not available");
62 notifier.sendNotification(Nodes.containerNode(
63 DemoUtils.changeNotification, nodes));
66 public void closeSession() {