From d6c7e80b4372f994640863af3066039527c8d3e9 Mon Sep 17 00:00:00 2001 From: Ed Warnicke Date: Sun, 18 May 2014 12:59:02 -0500 Subject: [PATCH] Bug 1029: Remove dead code: sal-dom-demo opendaylight/md-sal/sal-dom-demo is dead code that is not being built and hasn't for some time. Its complicating keeping versions up to date and verifying that they are up to date. If it needs to be revived in the future it can be retrieved from git. Change-Id: I77357764b8a779c444ed173e9e8a29a227ba3bf7 Signed-off-by: Ed Warnicke --- opendaylight/md-sal/sal-dom-demo/pom.xml | 62 ------- .../controller/sal/demo/DemoConsumerImpl.java | 107 ------------ .../controller/sal/demo/DemoProviderImpl.java | 69 -------- .../controller/sal/demo/DemoUtils.java | 44 ----- .../controller/sal/demo/SALDemo.java | 159 ------------------ .../controller/sal/demo/package-info.java | 8 - 6 files changed, 449 deletions(-) delete mode 100644 opendaylight/md-sal/sal-dom-demo/pom.xml delete mode 100644 opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/DemoConsumerImpl.java delete mode 100644 opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/DemoProviderImpl.java delete mode 100644 opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/DemoUtils.java delete mode 100644 opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/SALDemo.java delete mode 100644 opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/package-info.java diff --git a/opendaylight/md-sal/sal-dom-demo/pom.xml b/opendaylight/md-sal/sal-dom-demo/pom.xml deleted file mode 100644 index 322bad787b..0000000000 --- a/opendaylight/md-sal/sal-dom-demo/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - 4.0.0 - - org.opendaylight.controller - sal-parent - 1.0-SNAPSHOT - - sal-core-demo - - scm:git:ssh://git.opendaylight.org:29418/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - - - - org.opendaylight.controller - sal-broker-impl - 1.0-SNAPSHOT - - - org.opendaylight.controller - yang-data-util - - - org.slf4j - slf4j-simple - 1.7.2 - runtime - - - - - - maven-assembly-plugin - 2.4 - - - jar-with-dependencies - - - - org.opendaylight.controller.sal.demo.SALDemo - - - - - - make-assembly - package - - single - - - - - - - - - diff --git a/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/DemoConsumerImpl.java b/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/DemoConsumerImpl.java deleted file mode 100644 index e0752dca02..0000000000 --- a/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/DemoConsumerImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.demo; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import org.opendaylight.controller.sal.core.api.Consumer; -import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; -import org.opendaylight.controller.sal.core.api.notify.NotificationListener; -import org.opendaylight.controller.sal.core.api.notify.NotificationService; -import org.opendaylight.controller.yang.common.QName; -import org.opendaylight.controller.yang.data.api.CompositeNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class DemoConsumerImpl implements Consumer { - - private ConsumerSession session; - private NotificationService notificationService; - private final String name; - private static Logger log = LoggerFactory.getLogger("AlertLogger"); - - private boolean changeAware; - - public DemoConsumerImpl(String name) { - this.name = name; - } - - private NotificationListener alertLogger = new NotificationListener() { - - @Override - public void onNotification(CompositeNode notification) { - System.out.println(name - + ": Received alert: " - + notification.getFirstSimpleByName( - DemoUtils.contentNodeName).getValue()); - log.info("AlertLogger: Received notification: " + notification); - } - - @Override - public Set getSupportedNotifications() { - Set supported = new HashSet(); - supported.add(DemoUtils.alertNotification); - return supported; - } - }; - - private NotificationListener changeLogger = new NotificationListener() { - - @Override - public void onNotification(CompositeNode notification) { - System.out.println(name - + ": Received change: " - + notification.getFirstSimpleByName( - DemoUtils.contentNodeName).getValue()); - log.info("ChangeLogger: Received notification: " + notification); - } - - @Override - public Set getSupportedNotifications() { - Set supported = new HashSet(); - supported.add(DemoUtils.alertNotification); - return supported; - } - }; - - @Override - public void onSessionInitiated(ConsumerSession session) { - this.session = session; - this.notificationService = session - .getService(NotificationService.class); - notificationService.addNotificationListener( - DemoUtils.alertNotification, alertLogger); - if (isChangeAware()) { - notificationService.addNotificationListener( - DemoUtils.changeNotification, changeLogger); - } - } - - @Override - public Collection getConsumerFunctionality() { - Set func = new HashSet(); - func.add(alertLogger); - return func; - } - - public void closeSession() { - session.close(); - } - - public boolean isChangeAware() { - return changeAware; - } - - public void setChangeAware(boolean changeAware) { - this.changeAware = changeAware; - } - -} diff --git a/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/DemoProviderImpl.java b/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/DemoProviderImpl.java deleted file mode 100644 index 8a393be43d..0000000000 --- a/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/DemoProviderImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.demo; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; -import org.opendaylight.controller.sal.core.api.notify.NotificationProviderService; -import org.opendaylight.controller.yang.data.api.Node; -import org.opendaylight.controller.yang.data.util.Nodes; - - -public class DemoProviderImpl implements - org.opendaylight.controller.sal.core.api.Provider { - - private ProviderSession session; - private NotificationProviderService notifier; - - @Override - public void onSessionInitiated(ProviderSession session) { - this.session = session; - notifier = session.getService(NotificationProviderService.class); - } - - @Override - public Collection getProviderFunctionality() { - return Collections.emptySet(); - } - - public void sendAlertNotification(String content) { - List> nodes = new ArrayList>(); - nodes.add(DemoUtils.contentNode(content)); - - if (notifier == null) { - System.out.println("Provider: Error: Session not available"); - System.out - .println(" Notification Service not available"); - return; - } - notifier.sendNotification(Nodes.containerNode( - DemoUtils.alertNotification, nodes)); - } - - public void sendChangeNotification(String content) { - List> nodes = new ArrayList>(); - nodes.add(DemoUtils.contentNode(content)); - - if (notifier == null) { - System.out.println("Provider: Error: Session not available"); - System.out - .println(" Notification Service not available"); - return; - } - notifier.sendNotification(Nodes.containerNode( - DemoUtils.changeNotification, nodes)); - } - - public void closeSession() { - session.close(); - } -} diff --git a/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/DemoUtils.java b/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/DemoUtils.java deleted file mode 100644 index 3b0430935f..0000000000 --- a/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/DemoUtils.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.demo; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Date; - -import org.opendaylight.controller.yang.common.QName; -import org.opendaylight.controller.yang.data.api.Node; -import org.opendaylight.controller.yang.data.util.Nodes; - - -public class DemoUtils { - - public static final URI namespace = uri("urn:cisco:prototype:sal:demo"); - public static final Date revision = new Date(); - - public static final QName alertNotification = qName("alert"); - public static final QName changeNotification = qName("change"); - - public static final QName contentNodeName = qName("content"); - - public static URI uri(String str) { - try { - return new URI(str); - } catch (URISyntaxException e) { - throw new IllegalArgumentException(e); - } - } - - public static QName qName(String str) { - return new QName(namespace, revision, str); - } - - public static Node contentNode(String content) { - return Nodes.leafNode(contentNodeName, content); - } -} diff --git a/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/SALDemo.java b/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/SALDemo.java deleted file mode 100644 index 9e50059972..0000000000 --- a/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/SALDemo.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.demo; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -import org.opendaylight.controller.sal.core.impl.BrokerImpl; -import org.opendaylight.controller.sal.core.impl.NotificationModule; - - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SALDemo { - protected static final Logger logger = LoggerFactory - .getLogger(SALDemo.class); - - static BrokerImpl broker; - static DemoProviderImpl provider; - static DemoConsumerImpl consumer1; - static DemoConsumerImpl consumer2; - - public static void main(String[] args) { - - initialize(); - initializeProvider(); - displayHelp(); - - BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); - String s; - try { - while (true) { - - System.out.print("\nEnter your choice (0 - list): "); - s = in.readLine(); - int choice = Integer.parseInt(s.trim()); - try { - switch (choice) { - case 0: - displayHelp(); - break; - case 1: - registerProvider(); - break; - case 2: - registerConsumer1(); - break; - case 3: - registerConsumer2(); - break; - case 4: - sendAlert(in); - break; - case 5: - sendChange(in); - break; - case 6: - unregisterConsumer1(); - break; - case 7: - unregisterConsumer2(); - break; - case 8: - unregisterProvider(); - break; - case 9: - return; - default: - System.out.println("Please enter valid input."); - break; - } - } catch (Exception e) { - System.out - .println("Operation failed. Reason exception raised: " - + e.getClass().getSimpleName()); - System.out.println(" Message: " + e.getMessage()); - } - - } - } catch (IOException e) { - - logger.error("",e); - } - } - - private static void registerConsumer1() { - broker.registerConsumer(consumer1); - } - - private static void registerConsumer2() { - broker.registerConsumer(consumer2); - } - - private static void sendAlert(BufferedReader in) throws IOException { - System.out.print("Please enter notification content:"); - String content = in.readLine(); - provider.sendAlertNotification(content); - } - - private static void sendChange(BufferedReader in) throws IOException { - System.out.print("Please enter notification content:"); - String content = in.readLine(); - provider.sendChangeNotification(content); - } - - private static void unregisterConsumer1() { - consumer1.closeSession(); - } - - private static void unregisterConsumer2() { - consumer2.closeSession(); - } - - private static void unregisterProvider() { - provider.closeSession(); - } - - private static void displayHelp() { - System.out.println("Usage: "); - System.out.println(" 0) Display Help"); - System.out.println(" 1) Register Provider"); - System.out.println(" 2) Register Consumer 1 (listening on alert)"); - System.out - .println(" 3) Register Consumer 2 (listening on alert,change)"); - System.out.println(" 4) Send Alert Notification"); - System.out.println(" 5) Send Change Notification"); - System.out.println(" 6) Unregister Consumer 1"); - System.out.println(" 7) Unregister Consumer 2"); - System.out.println(" 8) Unregister Provider"); - System.out.println(" 9) Exit"); - - } - - private static void initializeProvider() { - provider = new DemoProviderImpl(); - } - - private static void initialize() { - System.out.println("Initializing broker"); - broker = new BrokerImpl(); - NotificationModule notifyModule = new NotificationModule(); - broker.addModule(notifyModule); - - consumer1 = new DemoConsumerImpl("Consumer 1"); - consumer2 = new DemoConsumerImpl("Consumer 2"); - consumer2.setChangeAware(true); - } - - private static void registerProvider() { - broker.registerProvider(provider); - } -} diff --git a/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/package-info.java b/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/package-info.java deleted file mode 100644 index 09d4bfb8e4..0000000000 --- a/opendaylight/md-sal/sal-dom-demo/src/main/java/org/opendaylight/controller/sal/demo/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.demo; \ No newline at end of file -- 2.36.6