LiveBeansView exposes aliases as well

Issue: SPR-14632
master
Juergen Hoeller 8 years ago
parent dfdfd72a3e
commit 57cb7c7e0a
  1. 28
      spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java

@ -165,6 +165,9 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
result.append(",\n"); result.append(",\n");
} }
result.append("{\n\"bean\": \"").append(beanName).append("\",\n"); result.append("{\n\"bean\": \"").append(beanName).append("\",\n");
result.append("\"aliases\": ");
appendArray(result, bf.getAliases(beanName));
result.append(",\n");
String scope = bd.getScope(); String scope = bd.getScope();
if (!StringUtils.hasText(scope)) { if (!StringUtils.hasText(scope)) {
scope = BeanDefinition.SCOPE_SINGLETON; scope = BeanDefinition.SCOPE_SINGLETON;
@ -178,16 +181,9 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
result.append("\"type\": null,\n"); result.append("\"type\": null,\n");
} }
result.append("\"resource\": \"").append(getEscapedResourceDescription(bd)).append("\",\n"); result.append("\"resource\": \"").append(getEscapedResourceDescription(bd)).append("\",\n");
result.append("\"dependencies\": ["); result.append("\"dependencies\": ");
String[] dependencies = bf.getDependenciesForBean(beanName); appendArray(result, bf.getDependenciesForBean(beanName));
if (dependencies.length > 0) { result.append("\n}");
result.append("\"");
}
result.append(StringUtils.arrayToDelimitedString(dependencies, "\", \""));
if (dependencies.length > 0) {
result.append("\"");
}
result.append("]\n}");
elementAppended = true; elementAppended = true;
} }
} }
@ -241,4 +237,16 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
return result.toString(); return result.toString();
} }
private void appendArray(StringBuilder result, String[] arr) {
result.append('[');
if (arr.length > 0) {
result.append('\"');
}
result.append(StringUtils.arrayToDelimitedString(arr, "\", \""));
if (arr.length > 0) {
result.append('\"');
}
result.append(']');
}
} }

Loading…
Cancel
Save