Search in sources :

Example 6 with SatisfiedReferenceDTO

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

the class WebConsolePlugin method listReferences.

private void listReferences(JSONWriter jw, ComponentDescriptionDTO desc, ComponentConfigurationDTO config) throws IOException {
    for (final ReferenceDTO dto : desc.references) {
        jw.object();
        jw.key("key");
        jw.value("Reference " + dto.name);
        jw.key("value");
        jw.array();
        final SatisfiedReferenceDTO satisfiedRef;
        if (config != null) {
            satisfiedRef = findReference(config, dto.name);
            jw.value(satisfiedRef != null ? "Satisfied" : "Unsatisfied");
        } else {
            satisfiedRef = null;
        }
        jw.value("Service Name: " + dto.interfaceName);
        if (dto.target != null) {
            jw.value("Target Filter: " + dto.target);
        }
        jw.value("Cardinality: " + dto.cardinality);
        jw.value("Policy: " + dto.policy);
        jw.value("Policy Option: " + dto.policyOption);
        // list bound services
        if (satisfiedRef != null) {
            for (int j = 0; j < satisfiedRef.boundServices.length; j++) {
                final StringBuffer b = new StringBuffer();
                b.append("Bound Service ID ");
                b.append(satisfiedRef.boundServices[j].id);
                String name = (String) satisfiedRef.boundServices[j].properties.get(ComponentConstants.COMPONENT_NAME);
                if (name == null) {
                    name = (String) satisfiedRef.boundServices[j].properties.get(Constants.SERVICE_PID);
                    if (name == null) {
                        name = (String) satisfiedRef.boundServices[j].properties.get(Constants.SERVICE_DESCRIPTION);
                    }
                }
                if (name != null) {
                    b.append(" (");
                    b.append(name);
                    b.append(")");
                }
                jw.value(b.toString());
            }
        } else if (config != null) {
            jw.value("No Services bound");
        }
        jw.endArray();
        jw.endObject();
    }
}
Also used : ReferenceDTO(org.osgi.service.component.runtime.dto.ReferenceDTO) SatisfiedReferenceDTO(org.osgi.service.component.runtime.dto.SatisfiedReferenceDTO) SatisfiedReferenceDTO(org.osgi.service.component.runtime.dto.SatisfiedReferenceDTO)

Aggregations

SatisfiedReferenceDTO (org.osgi.service.component.runtime.dto.SatisfiedReferenceDTO)6 ServiceReferenceDTO (org.osgi.framework.dto.ServiceReferenceDTO)5 ReferenceDTO (org.osgi.service.component.runtime.dto.ReferenceDTO)4 UnsatisfiedReferenceDTO (org.osgi.service.component.runtime.dto.UnsatisfiedReferenceDTO)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 TreeMap (java.util.TreeMap)1 ServiceReference (org.osgi.framework.ServiceReference)1 ComponentConfigurationDTO (org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)1 ComponentDescriptionDTO (org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)1