Merge "Eliminate XmlUtil.createElement(Document, String)"
authorJakub Morvay <jakub.morvay@gmail.com>
Thu, 17 Jan 2019 14:11:46 +0000 (14:11 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 17 Jan 2019 14:11:46 +0000 (14:11 +0000)
netconf/netconf-console/pom.xml
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfConnectDeviceCommand.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfDisconnectDeviceCommand.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfListDevicesCommand.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfShowDeviceCommand.java
netconf/netconf-console/src/main/java/org/opendaylight/netconf/console/commands/NetconfUpdateDeviceCommand.java
netconf/netconf-console/src/main/resources/org/opendaylight/blueprint/netconf-command.xml

index 2678901c28107c0a37fe8a1050b734f3be26388c..225afa55d56544605c57477477e0d9986f0b4239 100644 (file)
@@ -55,4 +55,19 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
           <scope>test</scope>
       </dependency>
   </dependencies>
+
+  <build>
+      <plugins>
+          <plugin>
+              <groupId>org.apache.felix</groupId>
+              <artifactId>maven-bundle-plugin</artifactId>
+              <extensions>true</extensions>
+              <configuration>
+                  <instructions>
+                      <Karaf-Commands>*</Karaf-Commands>
+                  </instructions>
+              </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>
index cedb5db57652cea52398c41ce62acef831caed53..578b49a4d3d3061f797e7468262eb79516e40d5c 100644 (file)
@@ -16,6 +16,8 @@ import java.util.Arrays;
 import org.apache.karaf.shell.api.action.Action;
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.opendaylight.netconf.console.api.NetconfCommands;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
@@ -30,20 +32,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev15
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder;
 
-@Command(name = "netconf:connect-device", scope = "netconf", description = "Connect to a netconf device.")
+@Service
+@Command(name = "connect-device", scope = "netconf", description = "Connect to a netconf device.")
 public class NetconfConnectDeviceCommand implements Action {
 
-    protected final NetconfCommands service;
+    @Reference
+    private NetconfCommands service;
+
+    public NetconfConnectDeviceCommand() {
 
-    public NetconfConnectDeviceCommand(final NetconfCommands service) {
-        this.service = service;
     }
 
     @VisibleForTesting
-    NetconfConnectDeviceCommand(final NetconfCommands service, final String deviceIp, final String devicePort) {
+    NetconfConnectDeviceCommand(final NetconfCommands service) {
         this.service = service;
-        this.deviceIp = deviceIp;
-        this.devicePort = devicePort;
     }
 
     @VisibleForTesting
index b9bf10bb6d365b8004725c30b345ee0efec1841f..1ad975245f253a2e08f7d0a15d72bd245176ffcc 100644 (file)
@@ -13,14 +13,23 @@ import com.google.common.base.Strings;
 import org.apache.karaf.shell.api.action.Action;
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.opendaylight.netconf.console.api.NetconfCommands;
 
-@Command(name = "netconf:disconnect-device", scope = "netconf", description = "Disconnect netconf device.")
+@Service
+@Command(name = "disconnect-device", scope = "netconf", description = "Disconnect netconf device.")
 public class NetconfDisconnectDeviceCommand implements Action {
 
-    protected final NetconfCommands service;
+    @Reference
+    private NetconfCommands service;
 
-    public NetconfDisconnectDeviceCommand(final NetconfCommands service) {
+    public NetconfDisconnectDeviceCommand() {
+
+    }
+
+    @VisibleForTesting
+    NetconfDisconnectDeviceCommand(final NetconfCommands service) {
         this.service = service;
     }
 
index 0db091f92656875afcae870f6770568382d4a9ff..c4d5302878e1b14efe7b87f4362514fe1d6935a8 100644 (file)
@@ -8,20 +8,30 @@
 
 package org.opendaylight.netconf.console.commands;
 
+import com.google.common.annotations.VisibleForTesting;
 import java.util.Map;
 import javax.annotation.Nonnull;
 import org.apache.karaf.shell.api.action.Action;
 import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.apache.karaf.shell.support.table.ShellTable;
 import org.opendaylight.netconf.console.api.NetconfCommands;
 import org.opendaylight.netconf.console.utils.NetconfConsoleConstants;
 
-@Command(name = "netconf:list-devices", scope = "netconf", description = "List all netconf devices in the topology.")
+@Service
+@Command(name = "list-devices", scope = "netconf", description = "List all netconf devices in the topology.")
 public class NetconfListDevicesCommand implements Action {
 
-    protected final NetconfCommands service;
+    @Reference
+    private NetconfCommands service;
 
-    public NetconfListDevicesCommand(final NetconfCommands service) {
+    public NetconfListDevicesCommand() {
+
+    }
+
+    @VisibleForTesting
+    NetconfListDevicesCommand(final NetconfCommands service) {
         this.service = service;
     }
 
index 273d9b2208dd25e7d9eaa2f965af5f3fa823713a..3245d6b5efc42433ba92de6abed3a77bb07ad024 100644 (file)
@@ -17,16 +17,25 @@ import javax.annotation.Nonnull;
 import org.apache.karaf.shell.api.action.Action;
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.apache.karaf.shell.support.table.ShellTable;
 import org.opendaylight.netconf.console.api.NetconfCommands;
 import org.opendaylight.netconf.console.utils.NetconfConsoleConstants;
 
-@Command(name = "netconf:show-device", scope = "netconf", description = "Shows netconf device attributes.")
+@Service
+@Command(name = "show-device", scope = "netconf", description = "Shows netconf device attributes.")
 public class NetconfShowDeviceCommand implements Action {
 
-    protected final NetconfCommands service;
+    @Reference
+    private NetconfCommands service;
 
-    public NetconfShowDeviceCommand(final NetconfCommands service) {
+    public NetconfShowDeviceCommand() {
+
+    }
+
+    @VisibleForTesting
+    NetconfShowDeviceCommand(final NetconfCommands service) {
         this.service = service;
     }
 
index 054d1154118d7445f8bd39c9448e88dc2a598f52..62978e208812ad1ac9ec9ec72920882d4bdf2c47 100644 (file)
@@ -14,16 +14,20 @@ import java.util.Map;
 import org.apache.karaf.shell.api.action.Action;
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.opendaylight.netconf.console.api.NetconfCommands;
 import org.opendaylight.netconf.console.utils.NetconfConsoleConstants;
 
-@Command(name = "netconf:update-device", scope = "netconf", description = "Update netconf device attributes.")
+@Service
+@Command(name = "update-device", scope = "netconf", description = "Update netconf device attributes.")
 public class NetconfUpdateDeviceCommand implements Action {
 
-    protected final NetconfCommands service;
+    @Reference
+    private NetconfCommands service;
+
+    public NetconfUpdateDeviceCommand() {
 
-    public NetconfUpdateDeviceCommand(final NetconfCommands service) {
-        this.service = service;
     }
 
     @VisibleForTesting
@@ -96,8 +100,7 @@ public class NetconfUpdateDeviceCommand implements Action {
     private String newSchemaless = "false";
 
     @Override
-    public  Object execute() {
-
+    public Object execute() {
         Map<String, String> updated = new HashMap<>();
         updated.put(NetconfConsoleConstants.NETCONF_IP, newIp);
         updated.put(NetconfConsoleConstants.NETCONF_PORT, newPort);
index 65b1a35e0f110d6bf5a794c9dbd2e74a9fbeab9d..ada935fd256c01082361cc35fae9b204e0c77463 100755 (executable)
     </bean>
     <service ref="netconfCommandsImpl" interface="org.opendaylight.netconf.console.api.NetconfCommands" />
 
-    <!--Karaf CLI-->
-
-    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
-        <command name="netconf:connect-device">
-            <action class="org.opendaylight.netconf.console.commands.NetconfConnectDeviceCommand">
-                <argument ref="netconfCommandsImpl"/>
-            </action>
-        </command>
-        <command name="netconf:list-devices">
-            <action class="org.opendaylight.netconf.console.commands.NetconfListDevicesCommand">
-                <argument ref="netconfCommandsImpl"/>
-            </action>
-        </command>
-        <command name="netconf:show-device">
-            <action class="org.opendaylight.netconf.console.commands.NetconfShowDeviceCommand">
-                <argument ref="netconfCommandsImpl"/>
-            </action>
-        </command>
-        <command name="netconf:disconnect-device">
-            <action class="org.opendaylight.netconf.console.commands.NetconfDisconnectDeviceCommand">
-                <argument ref="netconfCommandsImpl"/>
-            </action>
-        </command>
-        <command name="netconf:update-device">
-            <action class="org.opendaylight.netconf.console.commands.NetconfUpdateDeviceCommand">
-                <argument ref="netconfCommandsImpl"/>
-            </action>
-        </command>
-    </command-bundle>
-
 </blueprint>