private boolean isFullyStarted(Bundle bundle) { for (ComponentDescriptionDTO component : scrService.getComponentDescriptionDTOs(bundle)) { if (scrService.isComponentEnabled(component)) { for (ComponentConfigurationDTO config : scrService.getComponentConfigurationDTOs(component)) { if (config.state != ComponentConfigurationDTO.ACTIVE) { return false; } } } } return true; }
@Override public void enable() { scr.disableComponent(config.description); }
@Override public BundleState getState(Bundle bundle) { if (bundle.getState() == Bundle.ACTIVE) { for (ComponentDescriptionDTO desc : scr.getComponentDescriptionDTOs(bundle)) { for (ComponentConfigurationDTO cfg : scr.getComponentConfigurationDTOs(desc)) { if (cfg.state != ComponentConfigurationDTO.ACTIVE && cfg.state != ComponentConfigurationDTO.SATISFIED) { return BundleState.Waiting; } } } } return BundleState.Unknown; } }
private ComponentDescriptionDTO getComponent(String name) { for (ComponentDescriptionDTO component : scrService.getComponentDescriptionDTOs()) { if (component.name.equals(name)) { return component; } } return null; }
@Override public void disable(String componentName) { for (Bundle bundle : bundleContext.getBundles()) { ComponentDescriptionDTO dto = scr.getComponentDescriptionDTO(bundle, componentName); if (dto != null && scr.isComponentEnabled(dto)) { log.info("Component {} disabled by configuration.", dto.implementationClass); scr.disableComponent(dto); } } }
@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; }
@Descriptor("Disable an enabled component") public boolean disable(@Descriptor("Name of the component") final String name) { boolean changed = false; for (ComponentDescriptionDTO comp : findComponents(name)) { if (scr.isComponentEnabled(comp)) { scr.disableComponent(comp); changed = true; } } return changed; }
@Override public TabularData getComponentConfigs(long bundleId, String componentName) { return JmxComponentConfiguration.tableFrom( scrService.getComponentConfigurationDTOs( findComponent(bundleId, componentName))); }
public boolean isComponentEnabled(long bundleId, String componentName) { return scrService.isComponentEnabled(findComponent(bundleId, componentName)); }
public void enableComponent(long bundleId, String componentName) { scrService.enableComponent(findComponent(bundleId, componentName)); }
private ComponentDescriptionDTO findComponent(long bundleId, String componentName) { Bundle bundle = context.getBundle(bundleId); if (bundle != null) { return scrService.getComponentDescriptionDTO(bundle, componentName); } else { throw new IllegalArgumentException("No component found for name: " + componentName); } }
@Override public BundleState getState(Bundle bundle) { if (bundle.getState() == Bundle.ACTIVE) { for (ComponentDescriptionDTO desc : scr.getComponentDescriptionDTOs(bundle)) { for (ComponentConfigurationDTO cfg : scr.getComponentConfigurationDTOs(desc)) { if (cfg.state != ComponentConfigurationDTO.ACTIVE && cfg.state != ComponentConfigurationDTO.SATISFIED) { return BundleState.Waiting; } } } } return BundleState.Unknown; } }
@Override public TabularData getComponents() { return JmxComponentDescription.tableFrom(scrService.getComponentDescriptionDTOs()); }
@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; }
@Override public void disable() { scr.disableComponent(config.description); } }
@Descriptor("Dump information of a component configuration") public ComponentConfigurationDTO info(@Descriptor("ID of the component configuration") long id) { for (ComponentDescriptionDTO descDto : scr.getComponentDescriptionDTOs()) { for (ComponentConfigurationDTO configDto : scr.getComponentConfigurationDTOs(descDto)) { if (configDto.id == id) return configDto; } } return null; }
@Override public Component[] getComponents() { return toComponents(scr.getComponentDescriptionDTOs()); }
public void disableComponent(long bundleId, String componentName) { scrService.disableComponent(findComponent(bundleId, componentName)); }
@Descriptor("Dump information of a component configuration") public ComponentConfigurationDTO info(@Descriptor("ID of the component configuration") long id) { for (ComponentDescriptionDTO descDto : scr.getComponentDescriptionDTOs()) { for (ComponentConfigurationDTO configDto : scr.getComponentConfigurationDTOs(descDto)) { if (configDto.id == id) return configDto; } } return null; }
@Override public Component[] getComponents(Bundle bundle) { return toComponents(scr.getComponentDescriptionDTOs(bundle)); }