Fixed a number of CLI commands.
Refactored the StoreService/Manager stuff for common serializer pool.
diff --git a/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java b/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
index e4f87ee..8c41b7f 100644
--- a/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
@@ -1,8 +1,8 @@
package org.onlab.onos.cli;
import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
+import org.onlab.osgi.DefaultServiceDirectory;
+import org.onlab.osgi.ServiceNotFoundException;
/**
* Base abstraction of Karaf shell commands.
@@ -17,8 +17,7 @@
* @return service implementation
*/
public static <T> T get(Class<T> serviceClass) {
- BundleContext bc = FrameworkUtil.getBundle(AbstractShellCommand.class).getBundleContext();
- return bc.getService(bc.getServiceReference(serviceClass));
+ return DefaultServiceDirectory.getService(serviceClass);
}
/**
@@ -41,4 +40,19 @@
System.err.println(String.format(format, args));
}
+ /**
+ * Executes this command.
+ */
+ protected abstract void execute();
+
+ @Override
+ protected Object doExecute() throws Exception {
+ try {
+ execute();
+ } catch (ServiceNotFoundException e) {
+ error(e.getMessage());
+ }
+ return null;
+ }
+
}