Skip to content

Commit 5a004c3

Browse files
committed
LiveBeansView exposes aliases as well
Issue: SPR-14632 (cherry picked from commit 57cb7c7)
1 parent 430180a commit 5a004c3

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -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)