public class ServerPortInfoApplicationContextInitializer extends Object implements ApplicationContextInitializer<ConfigurableApplicationContext>
ApplicationContextInitializer
that sets Environment
properties for the
ports that EmbeddedServletContainer
servers are actually listening on. The
property "local.server.port" can be injected directly into tests using
@Value
or obtained via the Environment
.
If the EmbeddedWebApplicationContext
has a
namespace
set, it will be
used to construct the property name. For example, the "management" actuator context
will have the property name "local.management.port".
Properties are automatically propagated up to any parent context.
Constructor and Description |
---|
ServerPortInfoApplicationContextInitializer() |
Modifier and Type | Method and Description |
---|---|
protected String |
getPropertyName(EmbeddedWebApplicationContext context) |
void |
initialize(ConfigurableApplicationContext applicationContext) |
protected void |
onApplicationEvent(EmbeddedServletContainerInitializedEvent event) |
public ServerPortInfoApplicationContextInitializer()
public void initialize(ConfigurableApplicationContext applicationContext)
initialize
in interface ApplicationContextInitializer<ConfigurableApplicationContext>
protected void onApplicationEvent(EmbeddedServletContainerInitializedEvent event)
protected String getPropertyName(EmbeddedWebApplicationContext context)
Copyright © 2015 Pivotal Software, Inc.. All rights reserved.