use of org.apache.felix.webconsole.bundleinfo.BundleInfo in project felix by apache.
the class BundlesServlet method bundleInfoDetails.
private final void bundleInfoDetails(List<Map<String, Object>> props, Bundle bundle, String appRoot, final Locale locale) {
final Map<String, Object> val = new LinkedHashMap<String, Object>();
val.put("key", "nfo");
final Map<String, Object[]> value = new LinkedHashMap<String, Object[]>();
final Object[] bundleInfoProviders = bundleInfoTracker.getServices();
for (int i = 0; bundleInfoProviders != null && i < bundleInfoProviders.length; i++) {
final BundleInfoProvider infoProvider = (BundleInfoProvider) bundleInfoProviders[i];
final BundleInfo[] infos = infoProvider.getBundleInfo(bundle, appRoot, locale);
if (null != infos && infos.length > 0) {
final Object[] infoArray = new Object[infos.length];
for (int j = 0; j < infos.length; j++) {
infoArray[j] = bundleInfo(infos[j]);
}
value.put(infoProvider.getName(locale), infoArray);
}
}
val.put("value", value);
props.add(val);
}
use of org.apache.felix.webconsole.bundleinfo.BundleInfo in project felix by apache.
the class InfoProvider method getBundleInfo.
/**
* @see org.apache.felix.webconsole.bundleinfo.BundleInfoProvider#getBundleInfo(org.osgi.framework.Bundle,
* java.lang.String, java.util.Locale)
*/
public BundleInfo[] getBundleInfo(Bundle bundle, String webConsoleRoot, Locale locale) {
final List<ComponentDescriptionDTO> disabled = new ArrayList<ComponentDescriptionDTO>();
final List<ComponentConfigurationDTO> configurations = new ArrayList<ComponentConfigurationDTO>();
final Collection<ComponentDescriptionDTO> descs = scrService.getComponentDescriptionDTOs(bundle);
for (final ComponentDescriptionDTO d : descs) {
if (!scrService.isComponentEnabled(d)) {
disabled.add(d);
} else {
final Collection<ComponentConfigurationDTO> configs = scrService.getComponentConfigurationDTOs(d);
if (configs.isEmpty()) {
disabled.add(d);
} else {
configurations.addAll(configs);
}
}
}
Collections.sort(configurations, Util.COMPONENT_COMPARATOR);
if (configurations.isEmpty()) {
return NO_INFO;
}
BundleInfo[] ret = new BundleInfo[configurations.size() + disabled.size()];
int i = 0;
for (final ComponentDescriptionDTO cfg : disabled) {
ret[i] = toInfo(cfg, webConsoleRoot, locale);
i++;
}
for (final ComponentConfigurationDTO cfg : configurations) {
ret[i] = toInfo(cfg, webConsoleRoot, locale);
i++;
}
return ret;
}
use of org.apache.felix.webconsole.bundleinfo.BundleInfo in project felix by apache.
the class InfoProvider method toInfo.
private BundleInfo toInfo(final ComponentConfigurationDTO cfg, String webConsoleRoot, Locale locale) {
final ResourceBundle bundle = localization.getResourceBundle(locale);
final String state = ComponentConfigurationPrinter.toStateString(cfg.state);
final String name = cfg.description.name;
// $NON-NLS-1$;
final String descr = bundle.getString("info.descr");
// $NON-NLS-1$;
String key = bundle.getString("info.key");
// Component #{0} {1}, state {2}
key = MessageFormat.format(key, new Object[] { String.valueOf(cfg.id), name, state });
return new // $NON-NLS-1$
BundleInfo(// $NON-NLS-1$
key, // $NON-NLS-1$
(webConsoleRoot == null ? "" : webConsoleRoot) + "/components/" + cfg.id, BundleInfoType.LINK, descr);
}
use of org.apache.felix.webconsole.bundleinfo.BundleInfo in project felix by apache.
the class InfoProvider method toInfo.
private BundleInfo toInfo(final ComponentDescriptionDTO cfg, String webConsoleRoot, Locale locale) {
final ResourceBundle bundle = localization.getResourceBundle(locale);
final String state = "disabled";
final String name = cfg.name;
// $NON-NLS-1$;
final String descr = bundle.getString("info.descr");
// $NON-NLS-1$;
String key = bundle.getString("info.key");
// Component #{0} {1}, state {2}
key = MessageFormat.format(key, new Object[] { // $NON-NLS-1$
"", name, state });
return new BundleInfo(key, // $NON-NLS-1$
(webConsoleRoot == null ? "" : webConsoleRoot) + "/components", BundleInfoType.LINK, descr);
}
Aggregations