LiveBeansView exposes aliases as well

Issue: SPR-14632
(cherry picked from commit 57cb7c7)
This commit is contained in:
Juergen Hoeller
2016-08-26 20:04:23 +02:00
parent 430180aa96
commit 5a004c3b2a

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -165,6 +165,9 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
result.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();
if (!StringUtils.hasText(scope)) {
scope = BeanDefinition.SCOPE_SINGLETON;
@@ -178,16 +181,9 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
result.append("\"type\": null,\n");
}
result.append("\"resource\": \"").append(getEscapedResourceDescription(bd)).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) {
result.append("\"");
}
result.append("]\n}");
result.append("\"dependencies\": ");
appendArray(result, bf.getDependenciesForBean(beanName));
result.append("\n}");
elementAppended = true;
}
}
@@ -241,4 +237,16 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
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(']');
}
}