Question & Answer
Question
How can you programmatically retrieve the version number of your plug-ins from the Help > About IBM Rational Software Architect for WebSphere... > Installation Details > Installed Software list in IBM Rational Software Architect?
Cause
You would like to be able to use Java code to get the plug-in information.
Answer
ANSWERS
There are a couple of possible answers to this question:
- Use
org.osgi.framework.BundleContext.getBundles()
, for example, from your activator class inside your plugin in order to retrieve all the plug-ins
OR - Use the following code in order to retrieve the plugins by features:
IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
if (providers != null) {
for (int i = 0; i < providers.length; ++i) {
IBundleGroup[] bundleGroups = providers[i].getBundleGroups(); //bundle //group is the same as feature
for (int j = 0; j < bundleGroups.length; ++j) {
Bundle[] bundles = bundleGroups[j].getBundles();
for (int k = 0; k < bundles.length; ++k) {
System.out.println(bundles[k]);
}
}
}
}
NOTE: Each of these two solutions might give different set of plugins, as not all plugins need to be grouped in features.
Was this topic helpful?
Document Information
Modified date:
10 September 2020
UID
swg21625777