private ComponentDescriptionDTO getComponent(String name) { for (ComponentDescriptionDTO component : scrService.getComponentDescriptionDTOs()) { if (component.name.equals(name)) { return component; } } return null; }
private List<ComponentDescriptionDTO> findComponents(String name) { String lowerName = name.toLowerCase(); List<ComponentDescriptionDTO> matches = new LinkedList<>(); for (ComponentDescriptionDTO dto : scr.getComponentDescriptionDTOs()) { if (dto.name.equalsIgnoreCase(name)) { // Exact match, return only this component. return Collections.singletonList(dto); } if (dto.name.toLowerCase().contains(lowerName)) matches.add(dto); } return matches; }
private List<ComponentDescriptionDTO> getComponentDescriptions(ServiceComponentRuntime scr, String interfaceName, Bundle[] allBundlesArrays) { return scr.getComponentDescriptionDTOs(allBundlesArrays).stream() .filter(description -> Stream.of(description.serviceInterfaces).anyMatch(s -> s.equals(interfaceName))) .collect(toList()); }
private List<ComponentDescriptionDTO> findComponents(String name) { String lowerName = name.toLowerCase(); List<ComponentDescriptionDTO> matches = new LinkedList<>(); for (ComponentDescriptionDTO dto : scr.getComponentDescriptionDTOs()) { if (dto.name.equalsIgnoreCase(name)) { // Exact match, return only this component. return Collections.singletonList(dto); } if (dto.name.toLowerCase().contains(lowerName)) matches.add(dto); } return matches; }
@Override public TabularData getComponents() { return JmxComponentDescription.tableFrom(scrService.getComponentDescriptionDTOs()); }
@Descriptor("List all components") public ComponentDescriptionDTO[] list() { ComponentDescriptionDTO[] result = scr.getComponentDescriptionDTOs().toArray(new ComponentDescriptionDTO[0]); Arrays.sort(result, new Comparator<ComponentDescriptionDTO>() { @Override public int compare(ComponentDescriptionDTO c1, ComponentDescriptionDTO c2) { return Long.compare(c1.bundle.id, c2.bundle.id); } }); return result; }
@Override public Component getComponent(long componentId) { for (ComponentDescriptionDTO dto : scr.getComponentDescriptionDTOs()) { Long id = (Long) dto.properties.get(ComponentConstants.COMPONENT_ID); if (componentId == id) { return toComponent(dto); } } return null; }
@Descriptor("List all components") public ComponentDescriptionDTO[] list() { return scr.getComponentDescriptionDTOs().toArray(new ComponentDescriptionDTO[0]); }
@Override public Component[] getComponents() { return toComponents(scr.getComponentDescriptionDTOs()); }
@Override public Component[] getComponents(String componentName) { Collection<ComponentDescriptionDTO> dtos = new ArrayList<ComponentDescriptionDTO>(); for (ComponentDescriptionDTO dto : scr.getComponentDescriptionDTOs()) { if (componentName.equals(dto.name)) { dtos.add(dto); } } return toComponents(dtos); }
@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 Component[] getComponents(Bundle bundle) { return toComponents(scr.getComponentDescriptionDTOs(bundle)); }
@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 getComponentConfigs() { return JmxComponentConfiguration.tableFrom( scrService.getComponentDescriptionDTOs().stream() .map(c -> scrService.getComponentConfigurationDTOs(c)) .flatMap(Collection::stream)); }
@Descriptor("List components of a specific bundle") public ComponentDescriptionDTO[] list(@Descriptor("ID of the bundle") long bundleId) { Bundle bundle = context.getBundle(bundleId); return bundle != null ? scr.getComponentDescriptionDTOs(bundle).toArray(new ComponentDescriptionDTO[0]) : null; }
@Descriptor("List components of a specific bundle") public ComponentDescriptionDTO[] list(@Descriptor("ID of the bundle") long bundleId) { Bundle bundle = context.getBundle(bundleId); return bundle != null ? scr.getComponentDescriptionDTOs(bundle).toArray(new ComponentDescriptionDTO[0]) : null; }
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; }
/** * @see org.apache.felix.scr.ScrService#getComponent(long) */ public Component getComponent( long componentId ) { final Collection<ComponentDescriptionDTO> descriptions = this.runtime.getComponentDescriptionDTOs(); for(final ComponentDescriptionDTO descDTO : descriptions ) { final Collection<ComponentConfigurationDTO> configs = this.runtime.getComponentConfigurationDTOs(descDTO); for(final ComponentConfigurationDTO configDTO : configs) { if ( configDTO.id == componentId ) { return new ComponentWrapper(this.context, this.runtime, descDTO, configDTO); } } } return null; }
@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; }
@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; }