Fix remote shell to support custom banners

Update the remote shell to use the `Banner` interface when possible.

Fixes gh-3988
Closes gh-5453
This commit is contained in:
cjstehno
2016-03-20 08:10:38 -05:00
committed by Phillip Webb
parent b567959482
commit 309f8484a7
4 changed files with 77 additions and 6 deletions

View File

@@ -1,8 +1,25 @@
welcome = { ->
if (!crash.context.attributes['spring.environment'].getProperty("spring.main.show_banner", Boolean.class, Boolean.TRUE)) {
def environment = crash.context.attributes['spring.environment']
def propertyResolver = new org.springframework.boot.bind.RelaxedPropertyResolver(environment, "spring.main.");
def beanFactory = crash.context.attributes['spring.beanfactory']
if (!propertyResolver.getProperty("show-banner", Boolean.class, Boolean.TRUE)) {
return ""
}
// Try to print using the banner interface
if (beanFactory != null) {
try {
def banner = beanFactory.getBean("springBootBanner")
def out = new java.io.ByteArrayOutputStream()
banner.printBanner(environment, null, new java.io.PrintStream(out))
return out.toString()
} catch (Exception ex) {
// Ignore
}
}
// Resolve hostname
def hostName;
try {