}
else {
result.append("\"parent\": null,\n");
}
result.append("\"beans\": [\n");
ConfigurableListableBeanFactory bf = context.getBeanFactory();
String[] beanNames = bf.getBeanDefinitionNames();
for (int i = 0; i < beanNames.length; i++) {
String beanName = beanNames[i];
BeanDefinition bd = bf.getBeanDefinition(beanName);
if (bd.getRole() != BeanDefinition.ROLE_INFRASTRUCTURE &&
(!bd.isLazyInit() || bf.containsSingleton(beanName))) {
result.append("{\n\"bean\": \"").append(beanName).append("\",\n");
String scope = bd.getScope();
if (!StringUtils.hasText(scope)) {
scope = BeanDefinition.SCOPE_SINGLETON;
}
result.append("\"scope\": \"").append(scope).append("\",\n");
Class<?> beanType = bf.getType(beanName);
if (beanType != null) {
result.append("\"type\": \"").append(beanType.getName()).append("\",\n");
}
else {
result.append("\"type\": null,\n");
}
String resource = StringUtils.replace(bd.getResourceDescription(), "\\", "/");
result.append("\"resource\": \"").append(resource).append("\",\n");
result.append("\"dependencies\": [");
String[] dependencies = bf.getDependenciesForBean(beanName);
if (dependencies.length > 0) {
result.append("\"");
}
result.append(StringUtils.arrayToDelimitedString(dependencies, "\", \""));
if (dependencies.length > 0) {