Migrate deprecated OsgiCommandSupport 82/70782/3
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Wed, 11 Apr 2018 10:57:42 +0000 (12:57 +0200)
committerClaudio David Gasparini <claudio.gasparini@pantheon.tech>
Thu, 26 Apr 2018 09:14:44 +0000 (09:14 +0000)
Change-Id: I3fabc2af08746b2690a8e1ca8cb87e6ec84ad411
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
bgp/cli/pom.xml
bgp/cli/src/main/java/org/opendaylight/protocol/bgp/cli/OperationalStateCommandProvider.java
bgp/cli/src/main/resources/org/opendaylight/blueprint/bgp-cli.xml [deleted file]
pcep/topology/cli/pom.xml
pcep/topology/cli/src/main/java/org/opendaylight/protocol/pcep/cli/PcepStateCommandProvider.java
pcep/topology/cli/src/main/resources/org/opendaylight/blueprint/pcep-cli.xml [deleted file]

index c13b308be395a4733f938d452079dfe1acbbbfe1..b09bd15b157e3ace9f323225c346f433f0d09d5e 100644 (file)
             <artifactId>org.apache.karaf.shell.console</artifactId>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.karaf.shell</groupId>
-            <artifactId>org.apache.karaf.shell.table</artifactId>
-            <version>${karaf.version}</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.karaf.shell</groupId>
-            <artifactId>org.apache.karaf.shell.commands</artifactId>
-            <version>${karaf.version}</version>
-            <scope>provided</scope>
-        </dependency>
         <!--Test dependencies-->
         <dependency>
             <groupId>junit</groupId>
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Karaf-Commands>*</Karaf-Commands>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
     <scm>
         <connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
         <developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
index 981dcce1e891ad1ffe3de0eddcb38075b671e20e..579cf8cddcc850e9b1a944084a8648101f05aa56 100644 (file)
@@ -7,16 +7,21 @@
  */
 package org.opendaylight.protocol.bgp.cli;
 
-import static java.util.Objects.requireNonNull;
-
+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.console.OsgiCommandSupport;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.api.console.Session;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.protocol.bgp.cli.utils.BGPOperationalStateUtils;
 
+@Service
 @Command(scope = "bgp", name = "operational-state", description = "Shows BGP Operational State.")
-public final class OperationalStateCommandProvider extends OsgiCommandSupport {
+public final class OperationalStateCommandProvider implements Action {
+    @Reference
+    private Session session;
+    @Reference
     private DataBroker dataBroker;
     @Option(name = "-neighbor", aliases = {"--neighbor"}, description = "Neighbor address")
     private String peer;
@@ -26,13 +31,9 @@ public final class OperationalStateCommandProvider extends OsgiCommandSupport {
     private String group;
 
     @Override
-    protected Object doExecute() throws Exception {
+    public Object execute() {
         BGPOperationalStateUtils.displayBgpOperationalState(this.dataBroker, this.session.getConsole(),
                 this.ribId, this.group, this.peer);
         return null;
     }
-
-    public void setDataBroker(final DataBroker dataBroker) {
-        this.dataBroker = requireNonNull(dataBroker);
-    }
 }
diff --git a/bgp/cli/src/main/resources/org/opendaylight/blueprint/bgp-cli.xml b/bgp/cli/src/main/resources/org/opendaylight/blueprint/bgp-cli.xml
deleted file mode 100644 (file)
index 3025473..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Copyright (c) 2017 AT&T Intellectual Property. 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
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
-
-    <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
-               odl:type="pingpong"/>
-
-    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
-        <command name="bgp/operational-state">
-            <action class="org.opendaylight.protocol.bgp.cli.OperationalStateCommandProvider">
-                <property name="dataBroker" ref="dataBroker"/>
-            </action>
-        </command>
-    </command-bundle>
-</blueprint>
\ No newline at end of file
index 27989a5ee5dc76a90bcb6f6e979eda99872b199f..2a8b10587160874a472dc66f5687f82a4eadebc7 100644 (file)
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <!-- This bundle works with Karaf 3 and 4.0 -->
+                        <Import-Package>
+                            org.apache.karaf.shell.commands;version="[3.0.0,4.2)",
+                            org.apache.karaf.shell.console;version="[3.0.0,4.2)",
+                            *
+                        </Import-Package>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Karaf-Commands>*</Karaf-Commands>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
     <scm>
         <connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
         <developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
index f89ccadc3786b3bdbff2082d31ee0769ac729aa8..2f6e3b13647296dc8f5aa32403231a432310bebb 100644 (file)
@@ -7,16 +7,21 @@
  */
 package org.opendaylight.protocol.pcep.cli;
 
-import static java.util.Objects.requireNonNull;
-
+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.console.OsgiCommandSupport;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.api.console.Session;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.protocol.pcep.cli.utils.PcepStateUtils;
 
+@Service
 @Command(scope = "pcep", name = "node-state", description = "Shows PCEP Topology Node Session State.")
-public final class PcepStateCommandProvider extends OsgiCommandSupport {
+public final class PcepStateCommandProvider implements Action {
+    @Reference
+    private Session session;
+    @Reference
     private DataBroker dataBroker;
     @Option(name = "-topology-id", aliases = {"--tpi"}, description = "Topology Id", required = true)
     private String tpi;
@@ -24,12 +29,8 @@ public final class PcepStateCommandProvider extends OsgiCommandSupport {
     private String ni;
 
     @Override
-    protected Object doExecute() throws Exception {
+    public Object execute() {
         PcepStateUtils.displayNodeState(this.dataBroker, this.session.getConsole(), this.tpi, this.ni);
         return null;
     }
-
-    public void setDataBroker(final DataBroker dataBroker) {
-        this.dataBroker = requireNonNull(dataBroker);
-    }
 }
diff --git a/pcep/topology/cli/src/main/resources/org/opendaylight/blueprint/pcep-cli.xml b/pcep/topology/cli/src/main/resources/org/opendaylight/blueprint/pcep-cli.xml
deleted file mode 100644 (file)
index 3242cab..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Copyright (c) 2017 AT&T Intellectual Property. 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
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
-
-    <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
-               odl:type="pingpong"/>
-
-    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
-        <command name="pcep/node-state">
-            <action class="org.opendaylight.protocol.pcep.cli.PcepStateCommandProvider">
-                <property name="dataBroker" ref="dataBroker"/>
-            </action>
-        </command>
-    </command-bundle>
-</blueprint>
\ No newline at end of file