Reference[] refs = component.getReferences();
if (refs != null)
{
for (int i = 0; i < refs.length; i++)
{
JSONArray buf = new JSONArray();
buf.put(refs[i].isSatisfied() ? "Satisfied" : "Unsatisfied");
buf.put("Service Name: " + refs[i].getServiceName());
if (refs[i].getTarget() != null)
{
buf.put("Target Filter: " + refs[i].getTarget());
}
buf.put("Multiple: " + (refs[i].isMultiple() ? "multiple" : "single"));
buf.put("Optional: " + (refs[i].isOptional() ? "optional" : "mandatory"));
buf.put("Policy: " + (refs[i].isStatic() ? "static" : "dynamic"));
// list bound services
ServiceReference[] boundRefs = refs[i].getServiceReferences();
if (boundRefs != null && boundRefs.length > 0)
{
for (int j = 0; j < boundRefs.length; j++)
{
final StringBuffer b = new StringBuffer();
b.append("Bound Service ID ");
b.append(boundRefs[j].getProperty(Constants.SERVICE_ID));
String name = (String) boundRefs[j].getProperty(ComponentConstants.COMPONENT_NAME);
if (name == null)
{
name = (String) boundRefs[j].getProperty(Constants.SERVICE_PID);
if (name == null)
{
name = (String) boundRefs[j].getProperty(Constants.SERVICE_DESCRIPTION);
}
}
if (name != null)
{
b.append(" (");
b.append(name);
b.append(")");
}
buf.put(b.toString());
}
}
else
{
buf.put("No Services bound");
}
keyVal(jw, "Reference " + refs[i].getName(), buf.toString());
}
}
}