Modify "find" command to use start level service. (FELIX-1662)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@820292 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/shell/src/main/java/org/apache/felix/shell/impl/FindCommandImpl.java b/shell/src/main/java/org/apache/felix/shell/impl/FindCommandImpl.java
index 99866a3..7153538 100644
--- a/shell/src/main/java/org/apache/felix/shell/impl/FindCommandImpl.java
+++ b/shell/src/main/java/org/apache/felix/shell/impl/FindCommandImpl.java
@@ -26,6 +26,8 @@
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.startlevel.StartLevel;
/**
* Shell command to display a list of bundles whose
@@ -49,6 +51,20 @@
return;
}
+ // Get start level service.
+ ServiceReference ref = m_context.getServiceReference(
+ org.osgi.service.startlevel.StartLevel.class.getName());
+ StartLevel sl = null;
+ if (ref != null)
+ {
+ sl = (StartLevel) m_context.getService(ref);
+ }
+
+ if (sl == null)
+ {
+ out.println("StartLevel service is unavailable.");
+ }
+
st.nextToken();
String pattern = st.nextToken();
@@ -68,7 +84,7 @@
if (found.size() > 0)
{
- printBundleList((Bundle[]) found.toArray(new Bundle[found.size()]), null, out, false, false, false);
+ printBundleList((Bundle[]) found.toArray(new Bundle[found.size()]), sl, out, false, false, false);
}
else
{
diff --git a/shell/src/main/java/org/apache/felix/shell/impl/PsCommandImpl.java b/shell/src/main/java/org/apache/felix/shell/impl/PsCommandImpl.java
index a9e78ec..d6b010f 100644
--- a/shell/src/main/java/org/apache/felix/shell/impl/PsCommandImpl.java
+++ b/shell/src/main/java/org/apache/felix/shell/impl/PsCommandImpl.java
@@ -30,6 +30,10 @@
public class PsCommandImpl implements Command
{
+ private static final String LOCATION_SWITCH = "-l";
+ private static final String SYMBOLIC_NAME_SWITCH = "-s";
+ private static final String UPDATE_LOCATION_SWITCH = "-u";
+
protected final BundleContext m_context;
public PsCommandImpl(BundleContext context)
@@ -44,7 +48,9 @@
public String getUsage()
{
- return "ps [-l | -s | -u]";
+ return "ps [" + LOCATION_SWITCH
+ + " | " + SYMBOLIC_NAME_SWITCH
+ + " | " + UPDATE_LOCATION_SWITCH + "]";
}
public String getShortDescription()
@@ -83,15 +89,15 @@
while (st.hasMoreTokens())
{
String token = st.nextToken().trim();
- if (token.equals("-l"))
+ if (token.equals(LOCATION_SWITCH))
{
showLoc = true;
}
- else if (token.equals("-s"))
+ else if (token.equals(SYMBOLIC_NAME_SWITCH))
{
showSymbolic = true;
}
- else if (token.equals("-u"))
+ else if (token.equals(UPDATE_LOCATION_SWITCH))
{
showUpdate = true;
}