From 57cb7c7e0a6b7979ab38cf6e47f2e0a33a062bad Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 26 Aug 2016 20:04:23 +0200 Subject: [PATCH] LiveBeansView exposes aliases as well Issue: SPR-14632 --- .../context/support/LiveBeansView.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java b/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java index 8b10f6bc3b..98d91a086c 100644 --- a/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java +++ b/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\"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(']'); + } + }