Merge "XSQL Karaf Command"
authorEd Warnicke <eaw@cisco.com>
Thu, 28 Aug 2014 16:52:58 +0000 (16:52 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 28 Aug 2014 16:52:58 +0000 (16:52 +0000)
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLAdapter.java
opendaylight/md-sal/sal-karaf-xsql/pom.xml [new file with mode: 0644]
opendaylight/md-sal/sal-karaf-xsql/src/main/java/org/opendaylight/controller/xsql/xsql.java [new file with mode: 0644]

index 6d4400f..496f27e 100644 (file)
@@ -200,8 +200,7 @@ public class XSQLAdapter extends Thread implements SchemaContextListener {
 
     }
 
-    protected void processCommand(StringBuffer inputString, PrintStream sout,
-            TelnetConnection tc) {
+    public void processCommand(StringBuffer inputString, PrintStream sout) {
         if (inputString.toString().trim().equals("r")) {
             sout.println(lastInputString);
             inputString = lastInputString;
@@ -263,25 +262,6 @@ public class XSQLAdapter extends Thread implements SchemaContextListener {
             for (int i = 0; i < iNames.length; i++) {
                 sout.println(iNames[i]);
             }
-        } else if (input.startsWith("cd sid")) {
-            String substr = input.substring("cd sid".length()).trim();
-            for (NEEntry e : elements.values()) {
-                if (((Module) e.ne).getName().equals(substr)) {
-                    tc.currentModule = (Module) e.ne;
-                }
-            }
-        } else if (input.equals("list sid")) {
-            String arr[] = new String[elements.size()];
-
-            int i = 0;
-            for (NEEntry entry : elements.values()) {
-                arr[i] = entry.toString();
-                i++;
-            }
-            Arrays.sort(arr);
-            for (String s : arr) {
-                sout.println(s);
-            }
         } else if (input.equals("help") || input.equals("?")) {
             // sout.println(getLongDescription());
         } else if (input.equals("avmdata")) {
@@ -517,7 +497,7 @@ public class XSQLAdapter extends Thread implements SchemaContextListener {
                         }
                     }
 
-                    processCommand(inputString, out, this);
+                    processCommand(inputString, out);
                     inputString = new StringBuffer();
                 }
             } catch (Exception err) {
diff --git a/opendaylight/md-sal/sal-karaf-xsql/pom.xml b/opendaylight/md-sal/sal-karaf-xsql/pom.xml
new file mode 100644 (file)
index 0000000..c32d960
--- /dev/null
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+\r
+    <!--
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements.  See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You under the Apache License, Version 2.0
+        (the "License"); you may not use this file except in compliance with
+        the License.  You may obtain a copy of the License at
+
+            http://www.apache.org/licenses/LICENSE-2.0
+
+        Unless required by applicable law or agreed to in writing, software
+        distributed under the License is distributed on an "AS IS" BASIS,
+        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+        See the License for the specific language governing permissions and
+        limitations under the License.
+    -->\r
+\r
+    <modelVersion>4.0.0</modelVersion>\r
+\r
+    <parent>\r
+    <artifactId>sal-parent</artifactId>\r
+    <groupId>org.opendaylight.controller</groupId>\r
+    <version>1.1-SNAPSHOT</version>\r
+  </parent>\r
+\r
+    <groupId>xsqlcommand</groupId>\r
+    <artifactId>xsqlcommand</artifactId>\r
+    <packaging>bundle</packaging>\r
+    <version>1.0.0-SNAPSHOT</version>\r
+    <name>Apache Karaf :: Shell odl/xsql Commands</name>\r
+\r
+    <description>Provides the OSGi odl commands</description>\r
+\r
+    <dependencies>\r
+        <dependency>\r
+            <groupId>org.apache.karaf.shell</groupId>\r
+            <artifactId>org.apache.karaf.shell.console</artifactId>\r
+            <version>3.0.1</version>\r
+        </dependency>\r
+\r
+        <dependency>\r
+            <groupId>org.osgi</groupId>\r
+            <artifactId>org.osgi.core</artifactId>\r
+            <version>5.0.0</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
+\r
+        <dependency>\r
+            <groupId>org.osgi</groupId>\r
+            <artifactId>org.osgi.compendium</artifactId>\r
+            <version>5.0.0</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
+\r
+        <dependency>\r
+            <groupId>junit</groupId>\r
+            <artifactId>junit</artifactId>\r
+            <version>4.11</version>\r
+            <scope>test</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.opendaylight.controller</groupId>\r
+            <artifactId>sal-dom-xsql</artifactId>\r
+            <type>bundle</type>\r
+            <version>1.1-SNAPSHOT</version>\r
+        </dependency>\r
+    </dependencies>\r
+\r
+    <build>\r
+        <plugins>\r
+            <plugin>\r
+                <artifactId>maven-compiler-plugin</artifactId>\r
+                <inherited>true</inherited>\r
+                <version>2.3.2</version>\r
+                <configuration>\r
+                    <source>1.5</source>\r
+                    <target>1.5</target>\r
+                </configuration>\r
+            </plugin>\r
+            <plugin>\r
+                <groupId>org.apache.felix</groupId>\r
+                <artifactId>maven-bundle-plugin</artifactId>\r
+                <version>2.4.0</version>\r
+                <extensions>true</extensions>\r
+                <configuration>\r
+                    <instructions>\r
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>\r
+                        <Export-Package>org.opendaylight.controller.xsql*;version=${project.version}</Export-Package>\r
+                        <Import-Package>!org.opendaylight.controller.xsql*,\r
+                            org.apache.aries.blueprint,\r
+                            org.osgi.service.blueprint.container,\r
+                            org.osgi.service.blueprint.reflect,\r
+                            org.apache.felix.service.command,\r
+                            org.apache.karaf.shell.commands,\r
+                            org.apache.karaf.shell.console,\r
+                            *</Import-Package>\r
+                    </instructions>\r
+                </configuration>\r
+            </plugin>\r
+        </plugins>\r
+    </build>\r
+\r
+</project>\r
diff --git a/opendaylight/md-sal/sal-karaf-xsql/src/main/java/org/opendaylight/controller/xsql/xsql.java b/opendaylight/md-sal/sal-karaf-xsql/src/main/java/org/opendaylight/controller/xsql/xsql.java
new file mode 100644 (file)
index 0000000..b7994dc
--- /dev/null
@@ -0,0 +1,23 @@
+package org.opendaylight.controller.xsql;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLAdapter;
+
+@Command(scope = "odl", name = "xsql", description = "XSQL Karaf Command")
+public class xsql extends OsgiCommandSupport {
+
+    @Option(name = "-o", aliases = { "--option" }, description = "An option to the command", required = false, multiValued = false)
+    private String option;
+
+    @Argument(name = "argument", description = "Argument to the command", required = false, multiValued = false)
+    private String argument;
+
+    protected Object doExecute() throws Exception {
+        XSQLAdapter.getInstance().processCommand(new StringBuffer(argument),
+                System.out);
+        return null;
+    }
+}