pw.println("The factory " + name + " does not exist or is private");
return;
}
try {
JSONObject resp = new JSONObject();
// Statline.
resp.put("count", m_factories.size());
resp.put("valid_count", StateUtils.getValidFactoriesCount(m_factories));
resp.put("invalid_count", StateUtils.getInvalidFactoriesCount(m_factories));
// End of the statline
// Factory object
JSONObject data = new JSONObject();
data.put("name", factory.getName());
data.put("state", StateUtils.getFactoryState(factory.getState()));
String bundle = factory.getBundleContext().getBundle().getSymbolicName()
+ " (" + factory.getBundleContext().getBundle().getBundleId() + ")";
data.put("bundle", bundle);
// Provided service specifications
if (factory.getComponentDescription().getprovidedServiceSpecification().length != 0) {
JSONArray services = new JSONArray
(Arrays.asList(factory.getComponentDescription().getprovidedServiceSpecification()));
data.put("services", services);
}
// Properties
PropertyDescription[] props = factory.getComponentDescription().getProperties();
if (props != null && props.length != 0) {
JSONArray properties = new JSONArray();
for (int i = 0; i < props.length; i++) {
JSONObject prop = new JSONObject();
prop.put("name", props[i].getName());
prop.put("type", props[i].getType());
prop.put("mandatory", props[i].isMandatory());
prop.put("immutable", props[i].isImmutable());
if (props[i].getValue() != null) {
prop.put("value", props[i].getValue());
}
properties.put(prop);
}
data.put("properties", properties);
}