@Option(name = "--version", multiValued = false, required = false)
private String version;
@Override
protected Object doExecute() throws Exception {
OsgiModuleRegistry registry = getModuleRegistry();
List<ModuleRegistry.Module> modules = registry.getApplicationModules();
Map<VersionedDependencyId, Bundle> installed = registry.getInstalled();
for (ModuleRegistry.Module module : modules) {
if( module.getName().equals(name) ) {
ModuleRegistry.VersionedModule selected = null;
TreeSet<String> versions = mapVersion(module.getVersionIds());
HashSet<VersionedDependencyId> installedVersionIds = new HashSet<VersionedDependencyId>(module.getVersionIds());
installedVersionIds.retainAll(installed.keySet());
TreeSet<String> installedVersions = mapVersion(installedVersionIds);
versions.removeAll(installedVersions);
if( version!=null ) {
selected = module.getVersions().get(version);
if( selected==null ) {
println("Unknown version: %s", version);
return null;
}
} else {
selected = module.latest();
}
println("%15s: %s", "Name", selected.getName());
if( !installedVersionIds.isEmpty() ) {
for (VersionedDependencyId id : installedVersionIds) {
Bundle bundle = installed.get(id);
String version = id.getVersion();
String extensionIds = (String) bundle.getHeaders().get(ServiceConstants.INSTR_FAB_MODULE_ENABLED_EXTENSIONS);
if( notEmpty(extensionIds) ) {
List<VersionedDependencyId> ids = ModuleDescriptor.decodeVersionList(extensionIds);
ArrayList<String> ext = new ArrayList<String>();
for (VersionedDependencyId x : ids) {
ModuleRegistry.VersionedModule vm = registry.getVersionedModule(x);
if( vm!=null ) {
ext.add(vm.getName());
}
}
if( !ext.isEmpty() ) {