Search in sources :

Example 16 with ComponentDescriptionDTO

use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project smarthome by eclipse.

the class MissingServiceAnalyzer method printUnsatisfiedServices.

private <T> void printUnsatisfiedServices(ServiceComponentRuntime scr, String interfaceName, String prefix) {
    Bundle[] allBundlesArrays = getAllBundles();
    List<ComponentDescriptionDTO> descriptions = getComponentDescriptions(scr, interfaceName, allBundlesArrays);
    if (descriptions.isEmpty()) {
        ps.println(prefix + "No component implementing " + interfaceName + " is currently registered.");
    } else {
        for (ComponentDescriptionDTO description : descriptions) {
            Collection<ComponentConfigurationDTO> configurations = scr.getComponentConfigurationDTOs(description);
            for (ComponentConfigurationDTO configuration : configurations) {
                ps.println(prefix + configuration.id + " [" + getState(configuration.state) + "] " + description.implementationClass + " in " + description.bundle.symbolicName);
                for (ReferenceDTO ref : getUnsatisfiedReferences(description, configuration)) {
                    ps.println(prefix + "\t" + ref.name + " (" + ref.interfaceName + ")");
                    printUnsatisfiedServices(scr, ref.interfaceName, prefix + "\t\t");
                }
            }
        }
    }
}
Also used : ReferenceDTO(org.osgi.service.component.runtime.dto.ReferenceDTO) ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) Bundle(org.osgi.framework.Bundle) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)

Example 17 with ComponentDescriptionDTO

use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project acs-aem-commons by Adobe-Consulting-Services.

the class ComponentDisablerDriverDS13 method disable.

@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);
        }
    }
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) Bundle(org.osgi.framework.Bundle)

Example 18 with ComponentDescriptionDTO

use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project karaf by apache.

the class ListAction method doScrAction.

@Override
protected Object doScrAction(ServiceComponentRuntime serviceComponentRuntime) throws Exception {
    ShellTable table = new ShellTable();
    table.column("ID");
    table.column("State");
    table.column("Component Name");
    List<ComponentConfigurationDTO> configs = new ArrayList<>();
    for (ComponentDescriptionDTO component : serviceComponentRuntime.getComponentDescriptionDTOs()) {
        configs.addAll(serviceComponentRuntime.getComponentConfigurationDTOs(component));
    }
    Collections.sort(configs, idComparator);
    for (ComponentConfigurationDTO config : configs) {
        // Display only non hidden components, or all if showHidden is true
        if (showHidden || !ScrActionSupport.isHiddenComponent(config)) {
            table.addRow().addContent(config.id, ScrUtils.getState(config.state), config.description.name);
        }
    }
    table.print(System.out);
    return null;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) ArrayList(java.util.ArrayList) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)

Example 19 with ComponentDescriptionDTO

use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project karaf by apache.

the class ScrBundleStateService method getDiag.

@Override
public String getDiag(Bundle bundle) {
    StringBuilder sb = new StringBuilder();
    for (ComponentDescriptionDTO desc : scr.getComponentDescriptionDTOs(bundle)) {
        for (ComponentConfigurationDTO cfg : scr.getComponentConfigurationDTOs(desc)) {
            if (cfg.state != ComponentConfigurationDTO.ACTIVE && cfg.state != ComponentConfigurationDTO.SATISFIED) {
                sb.append(cfg.description.name).append(" (").append(cfg.id).append(")\n");
                if ((cfg.state & ComponentConfigurationDTO.UNSATISFIED_CONFIGURATION) != 0) {
                    sb.append("  missing configurations: ");
                    boolean first = true;
                    for (String s : cfg.description.configurationPid) {
                        if (!first) {
                            sb.append(", ");
                        }
                        sb.append(s);
                        first = false;
                    }
                    sb.append("\n");
                }
                if ((cfg.state & ComponentConfigurationDTO.UNSATISFIED_REFERENCE) != 0) {
                    sb.append("  missing references: ");
                    boolean first = true;
                    for (UnsatisfiedReferenceDTO ur : cfg.unsatisfiedReferences) {
                        if (!first) {
                            sb.append(", ");
                        }
                        sb.append(ur.name);
                        first = false;
                    }
                    sb.append("\n");
                }
            }
        }
    }
    return sb.toString();
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO) UnsatisfiedReferenceDTO(org.osgi.service.component.runtime.dto.UnsatisfiedReferenceDTO)

Example 20 with ComponentDescriptionDTO

use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project karaf by apache.

the class ActivateAction method doScrAction.

@Override
protected Object doScrAction(ServiceComponentRuntime serviceComponentRuntime) throws Exception {
    logger.debug("Activate Action");
    logger.debug("  Activating the Component: " + name);
    for (ComponentDescriptionDTO component : serviceComponentRuntime.getComponentDescriptionDTOs()) {
        if (name.equals(component.name)) {
            serviceComponentRuntime.enableComponent(component);
        }
    }
    return null;
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)

Aggregations

ComponentDescriptionDTO (org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)36 ComponentConfigurationDTO (org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)18 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 Bundle (org.osgi.framework.Bundle)3 ServiceComponentRuntime (org.osgi.service.component.runtime.ServiceComponentRuntime)3 ReferenceDTO (org.osgi.service.component.runtime.dto.ReferenceDTO)3 UnsatisfiedReferenceDTO (org.osgi.service.component.runtime.dto.UnsatisfiedReferenceDTO)3 Iterator (java.util.Iterator)2 TreeMap (java.util.TreeMap)2 Component (org.apache.felix.scr.Component)2 Descriptor (org.apache.felix.service.command.Descriptor)2 JSONWriter (org.apache.felix.utils.json.JSONWriter)2 ServiceReferenceDTO (org.osgi.framework.dto.ServiceReferenceDTO)2 SatisfiedReferenceDTO (org.osgi.service.component.runtime.dto.SatisfiedReferenceDTO)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Pattern (java.util.regex.Pattern)1