Eliminate blueprint for openflowplugins-impl karaf commands
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / karaf / ShowEventTimesComandProvider.java
index 1374857800d1fe456b9b308c50c58ac4bffca599..99b7a0d4ba3ba37d662ae3f3f6351eda376f175a 100644 (file)
@@ -5,31 +5,28 @@
  * 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.openflowplugin.impl.karaf;
 
-import java.io.PrintStream;
-import java.util.List;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
+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.api.console.Session;
 import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.EventsTimeCounter;
 
 /**
  * Created by Martin Bobak <mbobak@cisco.com> on 28.5.2015.
  */
 @Command(scope = "ofp", name = "show-time-counters", description = "Shows time counts for events.")
-public class ShowEventTimesComandProvider extends OsgiCommandSupport {
+@Service
+public class ShowEventTimesComandProvider implements Action {
+    @Reference
+    Session session;
 
     @Override
-    protected Object doExecute() {
-        PrintStream out = session.getConsole();
-        final List<String> statistics = EventsTimeCounter.provideTimes();
-        final StringBuilder result = new StringBuilder();
-        for (String line : statistics) {
-            result.append(line);
-            result.append("\n");
-        }
-        out.print(result.toString());
+    public Object execute() {
+        final var console = session.getConsole();
+        EventsTimeCounter.provideTimes().forEach(console::println);
         return null;
     }
 }