Skip to content

Commit 57cb7c7

Browse files
committed
LiveBeansView exposes aliases as well
Issue: SPR-14632
1 parent dfdfd72 commit 57cb7c7

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ protected String generateJson(Set<ConfigurableApplicationContext> contexts) {
165165
result.append(",\n");
166166
}
167167
result.append("{\n\"bean\": \"").append(beanName).append("\",\n");
168+
result.append("\"aliases\": ");
169+
appendArray(result, bf.getAliases(beanName));
170+
result.append(",\n");
168171
String scope = bd.getScope();
169172
if (!StringUtils.hasText(scope)) {
170173
scope = BeanDefinition.SCOPE_SINGLETON;
@@ -178,16 +181,9 @@ protected String generateJson(Set<ConfigurableApplicationContext> contexts) {
178181
result.append("\"type\": null,\n");
179182
}
180183
result.append("\"resource\": \"").append(getEscapedResourceDescription(bd)).append("\",\n");
181-
result.append("\"dependencies\": [");
182-
String[] dependencies = bf.getDependenciesForBean(beanName);
183-
if (dependencies.length > 0) {
184-
result.append("\"");
185-
}
186-
result.append(StringUtils.arrayToDelimitedString(dependencies, "\", \""));
187-
if (dependencies.length > 0) {
188-
result.append("\"");
189-
}
190-
result.append("]\n}");
184+
result.append("\"dependencies\": ");
185+
appendArray(result, bf.getDependenciesForBean(beanName));
186+
result.append("\n}");
191187
elementAppended = true;
192188
}
193189
}
@@ -241,4 +237,16 @@ else if (character == '"') {
241237
return result.toString();
242238
}
243239

240+
private void appendArray(StringBuilder result, String[] arr) {
241+
result.append('[');
242+
if (arr.length > 0) {
243+
result.append('\"');
244+
}
245+
result.append(StringUtils.arrayToDelimitedString(arr, "\", \""));
246+
if (arr.length > 0) {
247+
result.append('\"');
248+
}
249+
result.append(']');
250+
}
251+
244252
}

0 commit comments

Comments
 (0)