2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.controller.sal.demo;
\r
10 import java.util.ArrayList;
\r
11 import java.util.Collection;
\r
12 import java.util.Collections;
\r
13 import java.util.List;
\r
15 import org.opendaylight.controller.data.util.Nodes;
\r
16 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
\r
17 import org.opendaylight.controller.sal.core.api.notify.NotificationProviderService;
\r
18 import org.opendaylight.controller.yang.data.api.Node;
\r
21 public class DemoProviderImpl implements
\r
22 org.opendaylight.controller.sal.core.api.Provider {
\r
24 private ProviderSession session;
\r
25 private NotificationProviderService notifier;
\r
28 public void onSessionInitiated(ProviderSession session) {
\r
29 this.session = session;
\r
30 notifier = session.getService(NotificationProviderService.class);
\r
34 public Collection<ProviderFunctionality> getProviderFunctionality() {
\r
35 return Collections.emptySet();
\r
38 public void sendAlertNotification(String content) {
\r
39 List<Node<?>> nodes = new ArrayList<Node<?>>();
\r
40 nodes.add(DemoUtils.contentNode(content));
\r
42 if (notifier == null) {
\r
43 System.out.println("Provider: Error: Session not available");
\r
45 .println(" Notification Service not available");
\r
48 notifier.sendNotification(Nodes.containerNode(
\r
49 DemoUtils.alertNotification, nodes));
\r
52 public void sendChangeNotification(String content) {
\r
53 List<Node<?>> nodes = new ArrayList<Node<?>>();
\r
54 nodes.add(DemoUtils.contentNode(content));
\r
56 if (notifier == null) {
\r
57 System.out.println("Provider: Error: Session not available");
\r
59 .println(" Notification Service not available");
\r
62 notifier.sendNotification(Nodes.containerNode(
\r
63 DemoUtils.changeNotification, nodes));
\r
66 public void closeSession() {
\r