use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ComponentCommands method enable.
@Descriptor("Enable a disabled component")
public boolean enable(@Descriptor("Name of the component") final String name) {
boolean changed = false;
for (ComponentDescriptionDTO comp : findComponents(name)) {
if (!scr.isComponentEnabled(comp)) {
scr.enableComponent(comp);
changed = true;
}
}
return changed;
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ComponentConfigurationPrinter method printComponentsJson.
private final void printComponentsJson(final PrintWriter pw, final List<ComponentDescriptionDTO> disabled, final List<ComponentConfigurationDTO> configurations, final boolean details) throws IOException {
final JSONWriter jw = new JSONWriter(pw);
jw.object();
// $NON-NLS-1$
jw.key("components");
jw.array();
// render disabled descriptions
for (final ComponentDescriptionDTO cd : disabled) {
plugin.component(jw, cd, null, details);
}
// render configurations
for (final ComponentConfigurationDTO cfg : configurations) {
plugin.component(jw, cfg.description, cfg, details);
}
jw.endArray();
jw.endObject();
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ComponentConfigurationPrinter method printComponentsText.
private static final void printComponentsText(final PrintWriter pw, final List<ComponentDescriptionDTO> disabled, final List<ComponentDescriptionDTO> noConfig, final List<ComponentConfigurationDTO> configurations) {
if (!disabled.isEmpty()) {
pw.println(SEP);
pw.println("Disabled components:");
pw.println(SEP);
for (final ComponentDescriptionDTO cd : disabled) {
disabledComponent(pw, cd);
}
pw.println();
}
if (!noConfig.isEmpty()) {
pw.println(SEP);
pw.println("Components with missing configuration in Config Admin:");
pw.println(SEP);
for (final ComponentDescriptionDTO cd : noConfig) {
disabledComponent(pw, cd);
}
pw.println();
}
pw.println(SEP);
if (configurations.isEmpty()) {
pw.println("Status: No Component Configurations");
pw.println(SEP);
} else {
pw.println("Component Configurations:");
pw.println(SEP);
// order components by id
TreeMap<Long, ComponentConfigurationDTO> componentMap = new TreeMap<Long, ComponentConfigurationDTO>();
for (final ComponentConfigurationDTO cfg : configurations) {
componentMap.put(new Long(cfg.id), cfg);
}
// render components
for (final ComponentConfigurationDTO cfg : componentMap.values()) {
component(pw, cfg);
}
}
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ComponentConfigurationPrinter method print.
/**
* @see org.apache.felix.inventory.InventoryPrinter#print(java.io.PrintWriter, org.apache.felix.inventory.Format, boolean)
*/
public void print(PrintWriter pw, Format format, boolean isZip) {
final List<ComponentDescriptionDTO> noConfig = new ArrayList<ComponentDescriptionDTO>();
final List<ComponentDescriptionDTO> disabled = new ArrayList<ComponentDescriptionDTO>();
final List<ComponentConfigurationDTO> configurations = new ArrayList<ComponentConfigurationDTO>();
final Collection<ComponentDescriptionDTO> descs = scrService.getComponentDescriptionDTOs();
for (final ComponentDescriptionDTO d : descs) {
if (!scrService.isComponentEnabled(d)) {
disabled.add(d);
} else {
final Collection<ComponentConfigurationDTO> configs = scrService.getComponentConfigurationDTOs(d);
if (configs.isEmpty()) {
noConfig.add(d);
} else {
configurations.addAll(configs);
}
}
}
Collections.sort(configurations, Util.COMPONENT_COMPARATOR);
if (Format.JSON.equals(format)) {
disabled.addAll(noConfig);
try {
printComponentsJson(pw, disabled, configurations, isZip);
} catch (IOException ignore) {
// ignore
}
} else {
printComponentsText(pw, disabled, noConfig, configurations);
}
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO 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;
}
Aggregations