public class ServerPortInfoApplicationContextInitializer extends Object implements org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>, org.springframework.context.ApplicationListener<WebServerInitializedEvent>
ApplicationContextInitializer
that sets Environment
properties for the
ports that WebServer
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 WebServerInitializedEvent
has a
server namespace
, 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 |
---|---|
void |
initialize(org.springframework.context.ConfigurableApplicationContext applicationContext) |
void |
onApplicationEvent(WebServerInitializedEvent event) |
public ServerPortInfoApplicationContextInitializer()
public void initialize(org.springframework.context.ConfigurableApplicationContext applicationContext)
initialize
in interface org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>
public void onApplicationEvent(WebServerInitializedEvent event)
onApplicationEvent
in interface org.springframework.context.ApplicationListener<WebServerInitializedEvent>
Copyright © 2020 Pivotal Software, Inc.. All rights reserved.