{
return compare( ( ExportedPackage ) o1, ( ExportedPackage ) o2 );
}
} );
JSONArray val = new JSONArray();
for ( int j = 0; j < exports.length; j++ )
{
ExportedPackage export = exports[j];
collectExport( val, export.getName(), export.getVersion() );
Bundle[] ubList = export.getImportingBundles();
if ( ubList != null )
{
for ( int i = 0; i < ubList.length; i++ )
{
Bundle ub = ubList[i];
String name = ub.getSymbolicName();
if (name == null) name = ub.getLocation();
usingBundles.put( name, ub );
}
}
}
WebConsoleUtil.keyVal( jw, "Exported Packages", val );
}
else
{
WebConsoleUtil.keyVal( jw, "Exported Packages", "---" );
}
exports = packageAdmin.getExportedPackages( ( Bundle ) null );
if ( exports != null && exports.length > 0 )
{
// collect import packages first
final List imports = new ArrayList();
for ( int i = 0; i < exports.length; i++ )
{
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() )
{
imports.add( ep );
break;
}
}
}
// now sort
JSONArray val = new JSONArray();
if ( imports.size() > 0 )
{
final ExportedPackage[] packages = ( ExportedPackage[] ) imports.toArray( new ExportedPackage[imports
.size()] );
Arrays.sort( packages, new Comparator()
{
public int compare( ExportedPackage p1, ExportedPackage p2 )
{
return p1.getName().compareTo( p2.getName() );
}
public int compare( Object o1, Object o2 )
{
return compare( ( ExportedPackage ) o1, ( ExportedPackage ) o2 );
}
} );
// and finally print out
for ( int i = 0; i < packages.length; i++ )
{
ExportedPackage ep = packages[i];
collectImport( val, ep.getName(), ep.getVersion(), false, ep, pluginRoot );
}
}
else
{
// add description if there are no imports
val.put( "None" );
}
WebConsoleUtil.keyVal( jw, "Imported Packages", val );
}
if ( !usingBundles.isEmpty() )
{
JSONArray val = new JSONArray();
for ( Iterator ui = usingBundles.values().iterator(); ui.hasNext(); )
{
Bundle usingBundle = ( Bundle ) ui.next();
val.put( getBundleDescriptor( usingBundle, pluginRoot ) );
}
WebConsoleUtil.keyVal( jw, "Importing Bundles", val );
}
}