You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ga...@apache.org on 2011/04/14 04:34:35 UTC
svn commit: r1091991 - in
/karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi:
BundleSelector.java BundlesCommand.java BundlesCommandOptional.java
Headers.java Info.java ListServices.java RefreshBundle.java
ResolveBundle.java
Author: gawor
Date: Thu Apr 14 02:34:34 2011
New Revision: 1091991
URL: http://svn.apache.org/viewvc?rev=1091991&view=rev
Log:
KARAF-452: Add bundle range support to headers, ls, info, refresh, resolve commands. Also, fix some additional NPEs
Added:
karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/BundleSelector.java
- copied unchanged from r1091989, karaf/trunk/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/BundleSelector.java
Modified:
karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/BundlesCommand.java
karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/BundlesCommandOptional.java
karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Headers.java
karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Info.java
karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/ListServices.java
karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/RefreshBundle.java
karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/ResolveBundle.java
Modified: karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/BundlesCommand.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/BundlesCommand.java?rev=1091991&r1=1091990&r2=1091991&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/BundlesCommand.java (original)
+++ karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/BundlesCommand.java Thu Apr 14 02:34:34 2011
@@ -16,16 +16,12 @@
*/
package org.apache.karaf.shell.osgi;
-import java.util.ArrayList;
import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.apache.felix.gogo.commands.Argument;
import org.apache.felix.gogo.commands.Option;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
public abstract class BundlesCommand extends OsgiCommandSupport {
@@ -36,133 +32,11 @@ public abstract class BundlesCommand ext
boolean force;
protected Object doExecute() throws Exception {
- List<Bundle> bundles = new ArrayList<Bundle>();
- if (ids != null && !ids.isEmpty()) {
- for (String id : ids) {
-
- // id is a number
- Pattern pattern = Pattern.compile("^\\d+$");
- Matcher matcher = pattern.matcher(id);
- if (matcher.find()) {
- Bundle bundle = this.getBundleById(id);
- this.addBundle(bundle, id, force, bundles);
- continue;
- }
-
- // id is a number range
- pattern = Pattern.compile("^(\\d+)-(\\d+)$");
- matcher = pattern.matcher(id);
- if (matcher.find()) {
- int index = id.indexOf('-');
- Long startId = Long.valueOf(id.substring(0, index));
- Long endId = Long.valueOf(id.substring(index + 1));
- if (startId < endId) {
- for (long i = startId; i <= endId; i++) {
- Bundle bundle = getBundleContext().getBundle(i);
- this.addBundle(bundle, id, force, bundles);
- }
- }
- continue;
- }
-
- Bundle bundle = null;
- int index = id.indexOf('/');
- List<Bundle> bundlesByName = null;
- if (index != -1) {
- // user has provided name and version
- bundlesByName = this.getBundleByNameAndVersion(id.substring(0, index), id.substring(index + 1));
- } else {
- // user has provided only the name
- bundlesByName = this.getBundleByName(id);
- }
- for (Bundle bundleByName : bundlesByName) {
- this.addBundle(bundleByName, id, force, bundles);
- }
-
- }
- }
+ BundleSelector selector = new BundleSelector(getBundleContext(), session);
+ List<Bundle> bundles = selector.selectBundles(ids, force);
doExecute(bundles);
return null;
}
-
- private void addBundle(Bundle bundle, String id, boolean force, List bundles) throws Exception {
- if (bundle == null) {
- // if the bundle is null here, it's because we didn't find it
- System.err.println("Bundle " + id + " is invalid");
- } else {
- if (force || !Util.isASystemBundle(getBundleContext(), bundle) || Util.accessToSystemBundleIsAllowed(bundle.getBundleId(), session)) {
- bundles.add(bundle);
- }
- }
- }
-
- /**
- * Get a bundle identified by an id number.
- *
- * @param id the id number.
- * @return the bundle or null if not found.
- */
- private Bundle getBundleById(String id) {
- Bundle bundle = null;
- try {
- long idNumber = Long.valueOf(id);
- bundle = getBundleContext().getBundle(idNumber);
- } catch (NumberFormatException nfe) {
- // ignore
- }
- return bundle;
- }
-
- /**
- * Get a bundles list with the name or symbolic name matching the pattern.
- *
- * @param name the bundle name or symbolic name pattern to match.
- * @return the bundles list.
- */
- private List<Bundle> getBundleByName(String name) {
- return this.getBundleByNameAndVersion(name, null);
- }
-
- /**
- * Get a bundles list with the name or symbolic name matching the name pattern and version matching the version pattern.
- *
- * @param name the bundle name or symbolic name regex to match.
- * @param version the bundle version regex to match.
- * @return the bundles list.
- */
- private List<Bundle> getBundleByNameAndVersion(String name, String version) {
- Bundle[] bundles = getBundleContext().getBundles();
-
- ArrayList<Bundle> result = new ArrayList<Bundle>();
-
- Pattern namePattern = Pattern.compile(name);
-
- for (int i = 0; i < bundles.length; i++) {
-
- String bundleName = (String) bundles[i].getHeaders().get(Constants.BUNDLE_NAME);
- String bundleSymbolicName = bundles[i].getSymbolicName();
-
- Matcher nameMatcher = namePattern.matcher(bundleName);
- Matcher symbolicNameMatcher = namePattern.matcher(bundleSymbolicName);
-
- if (version != null) {
-
- Pattern versionPattern = Pattern.compile(version);
-
- String bundleVersion = (String) bundles[i].getHeaders().get(Constants.BUNDLE_VERSION);
- Matcher versionMatcher = versionPattern.matcher(bundleVersion);
-
- if ((nameMatcher.find() || symbolicNameMatcher.find()) && versionMatcher.find()) {
- result.add(bundles[i]);
- }
- } else {
- if (nameMatcher.find() || symbolicNameMatcher.find()) {
- result.add(bundles[i]);
- }
- }
- }
- return result;
- }
-
+
protected abstract void doExecute(List<Bundle> bundles) throws Exception;
}
Modified: karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/BundlesCommandOptional.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/BundlesCommandOptional.java?rev=1091991&r1=1091990&r2=1091991&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/BundlesCommandOptional.java (original)
+++ karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/BundlesCommandOptional.java Thu Apr 14 02:34:34 2011
@@ -16,7 +16,6 @@
*/
package org.apache.karaf.shell.osgi;
-import java.util.ArrayList;
import java.util.List;
import org.apache.felix.gogo.commands.Argument;
@@ -25,30 +24,27 @@ import org.apache.karaf.shell.console.Os
import org.osgi.framework.Bundle;
public abstract class BundlesCommandOptional extends OsgiCommandSupport {
-
- @Argument(index = 0, name = "ids", description = "The list of bundle IDs separated by whitespaces", required = false, multiValued = true)
- List<Long> ids;
+
+ @Argument(index = 0, name = "ids", description = "The list of bundle (identified by IDs or name or name/version) separated by whitespaces", required = false, multiValued = true)
+ List<String> ids;
@Option(name = "--force", aliases = {}, description = "Forces the command to execute", required = false, multiValued = false)
boolean force;
protected Object doExecute() throws Exception {
- List<Bundle> bundles = new ArrayList<Bundle>();
+ List<Bundle> bundles = null;
if (ids != null && !ids.isEmpty()) {
- for (long id : ids) {
- Bundle bundle = getBundleContext().getBundle(id);
- if (bundle == null) {
- System.err.println("Bundle ID" + id + " is invalid");
- } else {
- if (force || !Util.isASystemBundle(getBundleContext(), bundle) || Util.accessToSystemBundleIsAllowed(bundle.getBundleId(), session)) {
- bundles.add(bundle);
- }
- }
- }
+ BundleSelector selector = new BundleSelector(getBundleContext(), session);
+ bundles = selector.selectBundles(ids, force);
}
doExecute(bundles);
return null;
}
+ /**
+ *
+ * @param bundles null if no bundle ids or names were specified.
+ * @throws Exception
+ */
protected abstract void doExecute(List<Bundle> bundles) throws Exception;
}
Modified: karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Headers.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Headers.java?rev=1091991&r1=1091990&r2=1091991&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Headers.java (original)
+++ karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Headers.java Thu Apr 14 02:34:34 2011
@@ -26,7 +26,6 @@ import java.util.List;
import java.util.Map;
import jline.Terminal;
-import org.apache.felix.gogo.commands.Argument;
import org.apache.felix.gogo.commands.Command;
import org.apache.felix.gogo.commands.Option;
import org.apache.felix.utils.manifest.Attribute;
@@ -34,7 +33,6 @@ import org.apache.felix.utils.manifest.C
import org.apache.felix.utils.manifest.Directive;
import org.apache.felix.utils.manifest.Parser;
import org.apache.felix.utils.version.VersionRange;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.fusesource.jansi.Ansi;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
@@ -42,7 +40,7 @@ import org.osgi.service.packageadmin.Exp
import org.osgi.service.packageadmin.PackageAdmin;
@Command(scope = "osgi", name = "headers", description = "Displays OSGi headers of a given bundle.")
-public class Headers extends OsgiCommandSupport {
+public class Headers extends BundlesCommandOptional {
protected final static String BUNDLE_PREFIX = "Bundle-";
protected final static String PACKAGE_SUFFFIX = "-Package";
@@ -56,44 +54,34 @@ public class Headers extends OsgiCommand
@Option(name = "--indent", description = "Indentation method")
int indent = -1;
- @Argument(index = 0, name = "ids", description = "A list of bundle IDs separated by whitespaces", required = false, multiValued = true)
- List<Long> ids;
-
- protected Object doExecute() throws Exception {
+ protected void doExecute(List<Bundle> bundles) throws Exception {
// Get package admin service.
ref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
if (ref == null) {
System.out.println("PackageAdmin service is unavailable.");
- return null;
+ return;
}
try {
admin = (PackageAdmin) getBundleContext().getService(ref);
if (admin == null) {
System.out.println("PackageAdmin service is unavailable.");
- return null;
+ return;
}
- if (ids != null && !ids.isEmpty()) {
- for (long id : ids) {
- Bundle bundle = getBundleContext().getBundle(id);
- if (bundle != null) {
- printHeaders(bundle);
- } else {
- System.err.println("Bundle ID " + id + " is invalid.");
- }
+ if (bundles == null) {
+ Bundle[] allBundles = getBundleContext().getBundles();
+ for (int i = 0; i < allBundles.length; i++) {
+ printHeaders(allBundles[i]);
}
} else {
- Bundle[] bundles = getBundleContext().getBundles();
- for (int i = 0; i < bundles.length; i++) {
- printHeaders(bundles[i]);
+ for (Bundle bundle : bundles) {
+ printHeaders(bundle);
}
}
} finally {
getBundleContext().ungetService(ref);
}
-
- return null;
}
protected void printHeaders(Bundle bundle) throws Exception {
Modified: karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Info.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Info.java?rev=1091991&r1=1091990&r2=1091991&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Info.java (original)
+++ karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/Info.java Thu Apr 14 02:34:34 2011
@@ -16,40 +16,29 @@
*/
package org.apache.karaf.shell.osgi;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.util.StringEscapeUtils;
-import org.osgi.framework.Bundle;
-
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.List;
-@Command(scope = "osgi", name = "info", description = "Displays detailed information of a given bundle.")
-public class Info extends OsgiCommandSupport {
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.util.StringEscapeUtils;
+import org.osgi.framework.Bundle;
- @Argument(index = 0, name = "ids", description = "A list of bundle IDs separated by whitespaces", required = false, multiValued = true)
- List<Long> ids;
+@Command(scope = "osgi", name = "info", description = "Displays detailed information of a given bundle.")
+public class Info extends BundlesCommandOptional {
- protected Object doExecute() throws Exception {
- if (ids != null && !ids.isEmpty()) {
- for (long id : ids) {
- Bundle bundle = getBundleContext().getBundle(id);
- if (bundle != null) {
- printInfo(bundle);
- } else {
- System.err.println("Bundle ID " + id + " is invalid.");
- }
+ protected void doExecute(List<Bundle> bundles) throws Exception {
+ if (bundles == null) {
+ Bundle[] allBundles = getBundleContext().getBundles();
+ for (int i = 0; i < allBundles.length; i++) {
+ printInfo(allBundles[i]);
}
} else {
- Bundle[] bundles = getBundleContext().getBundles();
for (Bundle bundle : bundles) {
printInfo(bundle);
}
}
- return null;
}
/**
Modified: karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/ListServices.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/ListServices.java?rev=1091991&r1=1091990&r2=1091991&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/ListServices.java (original)
+++ karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/ListServices.java Thu Apr 14 02:34:34 2011
@@ -18,16 +18,14 @@ package org.apache.karaf.shell.osgi;
import java.util.List;
-import org.apache.felix.service.command.Function;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Option;
import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.service.command.Function;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
@Command(scope = "osgi", name = "ls", description = "Lists OSGi services.")
-public class ListServices extends OsgiCommandSupport {
+public class ListServices extends BundlesCommandOptional {
@Option(name = "-a", aliases = {}, description = "Shows all services", required = false, multiValued = false)
boolean showAll;
@@ -35,142 +33,108 @@ public class ListServices extends OsgiCo
@Option(name = "-u", aliases = {}, description = "Shows services which are in use", required = false, multiValued = false)
boolean inUse;
- @Argument(index = 0, name = "ids", description = "Show only services for the given bundle ids", required = false, multiValued = true)
- List<Long> ids;
+ protected void doExecute(List<Bundle> bundles) throws Exception {
+ if (bundles == null) {
+ Bundle[] allBundles = getBundleContext().getBundles();
+ for (int i = 0; i < allBundles.length; i++) {
+ printServicesShort(allBundles[i]);
+ }
+ } else {
+ for (Bundle bundle : bundles) {
+ printServices(bundle);
+ }
+ }
+ }
+
+ private void printServices(Bundle bundle) {
+ boolean headerPrinted = false;
+ boolean needSeparator = false;
+ ServiceReference[] refs = null;
+
+ // Get registered or in-use services.
+ if (inUse) {
+ refs = bundle.getServicesInUse();
+ } else {
+ refs = bundle.getRegisteredServices();
+ }
+
+ // Print properties for each service.
+ for (int refIdx = 0; (refs != null) && (refIdx < refs.length); refIdx++) {
+ String[] objectClass = (String[]) refs[refIdx].getProperty("objectClass");
+
+ // Determine if we need to print the service, depending
+ // on whether it is a command service or not.
+ boolean print = true;
+ for (int ocIdx = 0; !showAll && (ocIdx < objectClass.length); ocIdx++) {
+ if (objectClass[ocIdx].equals(Function.class.getName())) {
+ print = false;
+ }
+ }
+
+ // Print header if we have not already done so.
+ if (!headerPrinted) {
+ headerPrinted = true;
+ String title = Util.getBundleName(bundle);
+ title = (inUse) ? title + " uses:" : title + " provides:";
+ System.out.println("");
+ System.out.println(title);
+ System.out.println(Util.getUnderlineString(title));
+ }
+
+ if (showAll || print) {
+ // Print service separator if necessary.
+ if (needSeparator) {
+ System.out.println("----");
+ }
- protected Object doExecute() throws Exception {
- if (ids != null && !ids.isEmpty()) {
- for (long id : ids) {
- Bundle bundle = getBundleContext().getBundle(id);
- if (bundle != null) {
- boolean headerPrinted = false;
- boolean needSeparator = false;
- ServiceReference[] refs = null;
-
- // Get registered or in-use services.
- if (inUse) {
- refs = bundle.getServicesInUse();
- } else {
- refs = bundle.getRegisteredServices();
- }
-
- // Print properties for each service.
- for (int refIdx = 0;
- (refs != null) && (refIdx < refs.length);
- refIdx++) {
- String[] objectClass = (String[])
- refs[refIdx].getProperty("objectClass");
-
- // Determine if we need to print the service, depending
- // on whether it is a command service or not.
- boolean print = true;
- for (int ocIdx = 0;
- !showAll && (ocIdx < objectClass.length);
- ocIdx++) {
- if (objectClass[ocIdx].equals(Function.class.getName())) {
- print = false;
- }
- }
-
- // Print header if we have not already done so.
- if (!headerPrinted) {
- headerPrinted = true;
- String title = Util.getBundleName(bundle);
- title = (inUse)
- ? title + " uses:"
- : title + " provides:";
- System.out.println("");
- System.out.println(title);
- System.out.println(Util.getUnderlineString(title));
- }
-
- if (showAll || print) {
- // Print service separator if necessary.
- if (needSeparator) {
- System.out.println("----");
- }
-
- // Print service properties.
- String[] keys = refs[refIdx].getPropertyKeys();
- for (int keyIdx = 0;
- (keys != null) && (keyIdx < keys.length);
- keyIdx++) {
- Object v = refs[refIdx].getProperty(keys[keyIdx]);
- System.out.println(
- keys[keyIdx] + " = " + Util.getValueString(v));
- }
-
- needSeparator = true;
- }
- }
- } else {
- System.err.println("Bundle ID " + id + " is invalid.");
+ // Print service properties.
+ String[] keys = refs[refIdx].getPropertyKeys();
+ for (int keyIdx = 0; (keys != null) && (keyIdx < keys.length); keyIdx++) {
+ Object v = refs[refIdx].getProperty(keys[keyIdx]);
+ System.out.println(keys[keyIdx] + " = " + Util.getValueString(v));
}
+
+ needSeparator = true;
}
}
- else
- {
- Bundle[] bundles = getBundleContext().getBundles();
- if (bundles != null)
- {
- // TODO: Sort list.
- for (int bundleIdx = 0; bundleIdx < bundles.length; bundleIdx++)
- {
- boolean headerPrinted = false;
- ServiceReference[] refs = null;
-
- // Get registered or in-use services.
- if (inUse)
- {
- refs = bundles[bundleIdx].getServicesInUse();
- }
- else
- {
- refs = bundles[bundleIdx].getRegisteredServices();
- }
-
- for (int refIdx = 0; (refs != null) && (refIdx < refs.length); refIdx++)
- {
- String[] objectClass = (String[])
- refs[refIdx].getProperty("objectClass");
-
- // Determine if we need to print the service, depending
- // on whether it is a command service or not.
- boolean print = true;
- for (int ocIdx = 0;
- !showAll && (ocIdx < objectClass.length);
- ocIdx++)
- {
- if (objectClass[ocIdx].equals(Function.class.getName()))
- {
- print = false;
- }
- }
-
- // Print the service if necessary.
- if (showAll || print)
- {
- if (!headerPrinted)
- {
- headerPrinted = true;
- String title = Util.getBundleName(bundles[bundleIdx]);
- title = (inUse)
- ? title + " uses:"
- : title + " provides:";
- System.out.println("\n" + title);
- System.out.println(Util.getUnderlineString(title));
- }
- System.out.println(Util.getValueString(objectClass));
- }
- }
+ }
+
+ private void printServicesShort(Bundle bundle) {
+ boolean headerPrinted = false;
+ ServiceReference[] refs = null;
+
+ // Get registered or in-use services.
+ if (inUse) {
+ refs = bundle.getServicesInUse();
+ } else {
+ refs = bundle.getRegisteredServices();
+ }
+
+ for (int refIdx = 0; (refs != null) && (refIdx < refs.length); refIdx++) {
+ String[] objectClass = (String[]) refs[refIdx].getProperty("objectClass");
+
+ // Determine if we need to print the service, depending
+ // on whether it is a command service or not.
+ boolean print = true;
+ for (int ocIdx = 0; !showAll && (ocIdx < objectClass.length); ocIdx++) {
+ if (objectClass[ocIdx].equals(Function.class.getName())) {
+ print = false;
}
}
- else
- {
- System.out.println("There are no registered services.");
+
+ // Print the service if necessary.
+ if (showAll || print) {
+ if (!headerPrinted) {
+ headerPrinted = true;
+ String title = Util.getBundleName(bundle);
+ title = (inUse) ? title + " uses:" : title + " provides:";
+ System.out.println("\n" + title);
+ System.out.println(Util.getUnderlineString(title));
+ }
+ System.out.println(Util.getValueString(objectClass));
}
}
- return null;
+
}
}
Modified: karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/RefreshBundle.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/RefreshBundle.java?rev=1091991&r1=1091990&r2=1091991&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/RefreshBundle.java (original)
+++ karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/RefreshBundle.java Thu Apr 14 02:34:34 2011
@@ -18,8 +18,6 @@ package org.apache.karaf.shell.osgi;
import java.util.List;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.felix.gogo.commands.Argument;
import org.apache.felix.gogo.commands.Command;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
@@ -41,10 +39,9 @@ public class RefreshBundle extends Bundl
System.out.println("PackageAdmin service is unavailable.");
return;
}
- if (bundles.isEmpty()) {
+ if (bundles == null) {
pa.refreshPackages(null);
- }
- else {
+ } else {
pa.refreshPackages(bundles.toArray(new Bundle[bundles.size()]));
}
}
Modified: karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/ResolveBundle.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/ResolveBundle.java?rev=1091991&r1=1091990&r2=1091991&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/ResolveBundle.java (original)
+++ karaf/branches/karaf-2.2.x/shell/osgi/src/main/java/org/apache/karaf/shell/osgi/ResolveBundle.java Thu Apr 14 02:34:34 2011
@@ -39,7 +39,7 @@ public class ResolveBundle extends Bundl
System.out.println("PackageAdmin service is unavailable.");
return;
}
- if (bundles.isEmpty()) {
+ if (bundles == null) {
pa.resolveBundles(null);
} else {
pa.resolveBundles(bundles.toArray(new Bundle[bundles.size()]));