Search in sources :

Example 86 with ComponentConfigurationDTO

use of org.osgi.service.component.runtime.dto.ComponentConfigurationDTO in project felix by apache.

the class ScrServiceImpl method getComponents.

/**
 * @see org.apache.felix.scr.ScrService#getComponents(org.osgi.framework.Bundle)
 */
public Component[] getComponents(final Bundle bundle) {
    List<Component> result = new ArrayList<Component>();
    final Collection<ComponentDescriptionDTO> descriptions = (bundle == null ? this.runtime.getComponentDescriptionDTOs() : this.runtime.getComponentDescriptionDTOs(bundle));
    for (final ComponentDescriptionDTO descDTO : descriptions) {
        final Collection<ComponentConfigurationDTO> configs = this.runtime.getComponentConfigurationDTOs(descDTO);
        ComponentConfigurationDTO configDTO = null;
        if (!configs.isEmpty()) {
            configDTO = configs.iterator().next();
        }
        result.add(new ComponentWrapper(this.context, this.runtime, descDTO, configDTO));
    }
    return result.isEmpty() ? null : result.toArray(new Component[result.size()]);
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) ArrayList(java.util.ArrayList) Component(org.apache.felix.scr.Component) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)

Example 87 with ComponentConfigurationDTO

use of org.osgi.service.component.runtime.dto.ComponentConfigurationDTO in project felix by apache.

the class WebConsolePlugin method renderResult.

private void renderResult(final PrintWriter pw, RequestInfo info, final ComponentConfigurationDTO component) throws IOException {
    final JSONWriter jw = new JSONWriter(pw);
    jw.object();
    // $NON-NLS-1$
    jw.key("status");
    jw.value(info.configurations.size());
    if (!info.configurations.isEmpty()) {
        // render components
        // $NON-NLS-1$
        jw.key("data");
        jw.array();
        if (component != null) {
            if (component.state == -1) {
                component(jw, component.description, null, true);
            } else {
                component(jw, component.description, component, true);
            }
        } else {
            for (final ComponentDescriptionDTO cd : info.disabled) {
                component(jw, cd, null, false);
            }
            for (final ComponentConfigurationDTO cfg : info.configurations) {
                component(jw, cfg.description, cfg, false);
            }
        }
        jw.endArray();
    }
    jw.endObject();
}
Also used : JSONWriter(org.apache.felix.utils.json.JSONWriter) ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)

Aggregations

ComponentConfigurationDTO (org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)87 Test (org.junit.Test)63 SimpleComponent (org.apache.felix.scr.integration.components.SimpleComponent)23 SimpleServiceImpl (org.apache.felix.scr.integration.components.SimpleServiceImpl)22 ComponentDescriptionDTO (org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)19 A (org.apache.felix.scr.integration.components.circular.A)9 B (org.apache.felix.scr.integration.components.circular.B)9 ArrayList (java.util.ArrayList)6 Configuration (org.osgi.service.cm.Configuration)6 Bundle (org.osgi.framework.Bundle)5 ServiceReference (org.osgi.framework.ServiceReference)5 ServiceComponentRuntime (org.osgi.service.component.runtime.ServiceComponentRuntime)4 Hashtable (java.util.Hashtable)3 ConstructorComponent (org.apache.felix.scr.integration.components.ConstructorComponent)3 FieldActivatorComponent (org.apache.felix.scr.integration.components.FieldActivatorComponent)3 ReferenceDTO (org.osgi.service.component.runtime.dto.ReferenceDTO)3 UnsatisfiedReferenceDTO (org.osgi.service.component.runtime.dto.UnsatisfiedReferenceDTO)3 TreeMap (java.util.TreeMap)2 Component (org.apache.felix.scr.Component)2 ActivatorComponent (org.apache.felix.scr.integration.components.ActivatorComponent)2