You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2007/12/31 10:46:06 UTC
svn commit: r607706 - in
/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal:
AjaxBundleDetailsAction.java AjaxConfigManagerAction.java
Author: cziegeler
Date: Mon Dec 31 01:46:04 2007
New Revision: 607706
URL: http://svn.apache.org/viewvc?rev=607706&view=rev
Log:
Sort list of exported and imported packages alphabetically.
Modified:
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxBundleDetailsAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxConfigManagerAction.java
Modified: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxBundleDetailsAction.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxBundleDetailsAction.java?rev=607706&r1=607705&r2=607706&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxBundleDetailsAction.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxBundleDetailsAction.java Mon Dec 31 01:46:04 2007
@@ -17,8 +17,12 @@
package org.apache.sling.osgi.console.web.internal;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.Date;
import java.util.Dictionary;
+import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -121,6 +125,13 @@
private void listImportExport(JSONArray props, Bundle bundle) {
ExportedPackage[] exports = packageAdmin.getExportedPackages(bundle);
if (exports != null && exports.length > 0) {
+ // do alphabetical sort
+ Arrays.sort(exports, new Comparator<ExportedPackage>() {
+ public int compare(ExportedPackage p1, ExportedPackage p2) {
+ return p1.getName().compareTo(p2.getName());
+ }
+ });
+
StringBuffer val = new StringBuffer();
for (int i = 0; i < exports.length; i++) {
val.append(exports[i].getName());
@@ -135,43 +146,57 @@
exports = packageAdmin.getExportedPackages((Bundle) null);
if (exports != null && exports.length > 0) {
- StringBuffer val = new StringBuffer();
+ // collect import packages first
+ final List<ExportedPackage> imports = new ArrayList<ExportedPackage>();
for (int i = 0; i < exports.length; i++) {
- ExportedPackage ep = exports[i];
- Bundle[] importers = ep.getImportingBundles();
+ final ExportedPackage ep = exports[i];
+ final Bundle[] importers = ep.getImportingBundles();
for (int j = 0; importers != null && j < importers.length; j++) {
if (importers[j].getBundleId() == bundle.getBundleId()) {
- val.append(ep.getName());
- val.append(",version=").append(ep.getVersion());
- val.append(" from ");
-
- if (ep.getExportingBundle().getSymbolicName() != null) {
- // list the bundle name if not null
- val.append(ep.getExportingBundle().getSymbolicName());
- val.append(" (").append(
- ep.getExportingBundle().getBundleId());
- val.append(")");
- } else if (ep.getExportingBundle().getLocation() != null) {
- // otherwise try the location
- val.append(ep.getExportingBundle().getLocation());
- val.append(" (").append(
- ep.getExportingBundle().getBundleId());
- val.append(")");
- } else {
- // fallback to just the bundle id
- // only append the bundle
- val.append(ep.getExportingBundle().getBundleId());
- }
-
- val.append("<br />");
+ imports.add(ep);
break;
}
}
}
+ // now sort
+ StringBuffer val = new StringBuffer();
+ if ( imports.size() > 0 ) {
+ final ExportedPackage[] packages = imports.toArray(new ExportedPackage[imports.size()]);
+ Arrays.sort(packages, new Comparator<ExportedPackage>() {
+ public int compare(ExportedPackage p1, ExportedPackage p2) {
+ return p1.getName().compareTo(p2.getName());
+ }
+ });
+ // and finally print out
+ for (int i = 0; i < packages.length; i++) {
+ ExportedPackage ep = packages[i];
+ val.append(ep.getName());
+ val.append(",version=").append(ep.getVersion());
+ val.append(" from ");
+
+ if (ep.getExportingBundle().getSymbolicName() != null) {
+ // list the bundle name if not null
+ val.append(ep.getExportingBundle().getSymbolicName());
+ val.append(" (").append(
+ ep.getExportingBundle().getBundleId());
+ val.append(")");
+ } else if (ep.getExportingBundle().getLocation() != null) {
+ // otherwise try the location
+ val.append(ep.getExportingBundle().getLocation());
+ val.append(" (").append(
+ ep.getExportingBundle().getBundleId());
+ val.append(")");
+ } else {
+ // fallback to just the bundle id
+ // only append the bundle
+ val.append(ep.getExportingBundle().getBundleId());
+ }
- // add description if there are no imports
- if (val.length() == 0) {
+ val.append("<br />");
+ }
+ } else {
+ // add description if there are no imports
val.append("None");
}
Modified: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxConfigManagerAction.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxConfigManagerAction.java?rev=607706&r1=607705&r2=607706&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxConfigManagerAction.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxConfigManagerAction.java Mon Dec 31 01:46:04 2007
@@ -369,7 +369,7 @@
props.put(propName, this.toType(ad.getType(), prop));
} else {
// array or vector of any type
- Vector vec = new Vector();
+ Vector<Object> vec = new Vector<Object>();
String[] properties = request.getParameterValues(propName);
if (properties != null) {
@@ -428,7 +428,7 @@
}
}
- private Object toArray(int type, Vector values) {
+ private Object toArray(int type, Vector<Object> values) {
int size = values.size();
// short cut for string array