Add display-name option
Allow the display-name of the application to be customized when deployed in an embedded container via the `server.display-name` property. Closes gh-2600
This commit is contained in:
@@ -80,6 +80,11 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
|
||||
*/
|
||||
private String contextPath;
|
||||
|
||||
/**
|
||||
* Display name of the application.
|
||||
*/
|
||||
private String displayName = "application";
|
||||
|
||||
@NestedConfigurationProperty
|
||||
private Ssl ssl;
|
||||
|
||||
@@ -122,6 +127,14 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getServletPath() {
|
||||
return this.servletPath;
|
||||
}
|
||||
@@ -213,6 +226,9 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
|
||||
if (getContextPath() != null) {
|
||||
container.setContextPath(getContextPath());
|
||||
}
|
||||
if (getDisplayName() != null) {
|
||||
container.setDisplayName(getDisplayName());
|
||||
}
|
||||
if (getSessionTimeout() != null) {
|
||||
container.setSessionTimeout(getSessionTimeout());
|
||||
}
|
||||
|
||||
@@ -112,6 +112,21 @@ public class ServerPropertiesTests {
|
||||
verify(factory, never()).setContextPath("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultDisplayName() throws Exception {
|
||||
ConfigurableEmbeddedServletContainer factory = mock(ConfigurableEmbeddedServletContainer.class);
|
||||
this.properties.customize(factory);
|
||||
verify(factory).setDisplayName("application");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomizeDisplayName() throws Exception {
|
||||
ConfigurableEmbeddedServletContainer factory = mock(ConfigurableEmbeddedServletContainer.class);
|
||||
this.properties.setDisplayName("TestName");
|
||||
this.properties.customize(factory);
|
||||
verify(factory).setDisplayName("TestName");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomizeTomcatPort() throws Exception {
|
||||
ConfigurableEmbeddedServletContainer factory = mock(ConfigurableEmbeddedServletContainer.class);
|
||||
@@ -136,6 +151,18 @@ public class ServerPropertiesTests {
|
||||
assertEquals(9999, this.properties.getTomcat().getMaxHttpHeaderSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customizeTomcatDisplayName() throws Exception {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put("server.display-name", "MyBootApp");
|
||||
bindProperties(map);
|
||||
|
||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
||||
this.properties.customize(container);
|
||||
|
||||
assertEquals("MyBootApp", container.getDisplayName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disableTomcatRemoteIpValve() throws Exception {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
|
||||
Reference in New Issue
Block a user