Class ConfigServerBootstrapApplicationListener
java.lang.Object
org.springframework.cloud.config.server.bootstrap.ConfigServerBootstrapApplicationListener
- All Implemented Interfaces:
EventListener
,org.springframework.boot.env.EnvironmentPostProcessor
,org.springframework.context.ApplicationListener<org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent>
,org.springframework.core.Ordered
public class ConfigServerBootstrapApplicationListener
extends Object
implements org.springframework.context.ApplicationListener<org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent>, org.springframework.boot.env.EnvironmentPostProcessor, org.springframework.core.Ordered
Normally you don't want the config server to be a config client itself, so this
listener disables the config client unless
spring.cloud.config.enabled
is
explicitly "true". It has to be "true" at the time this listener is fired, which means
before the bootstrap.yml
is parsed, which in turn means to you need
to launch the application with an existing primed Environment
(e.g. via System
properties or a SpringApplicationBuilder
). This is the same rule of precedence
as for anything else affecting the bootstrap process itself, e.g. setting
spring.cloud.bootstrap.name
to something other than "bootstrap".
N.B. a config server can always be an "embedded" config client (using its own config
repository as a property source) if you set
spring.cloud.config.server.bootstrap=true
in bootstrap.yml
.
This listener is only to prevent it from using HTTP to contact itself.
- Author:
- Dave Syer, Ryan Baxter
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Default order of the bootstrap application listener.Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
getOrder()
void
onApplicationEvent
(org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent event) void
postProcessEnvironment
(org.springframework.core.env.ConfigurableEnvironment environment, org.springframework.boot.SpringApplication application) void
setOrder
(int order)
-
Field Details
-
DEFAULT_ORDER
public static final int DEFAULT_ORDERDefault order of the bootstrap application listener.- See Also:
-
-
Constructor Details
-
ConfigServerBootstrapApplicationListener
public ConfigServerBootstrapApplicationListener()
-
-
Method Details
-
postProcessEnvironment
public void postProcessEnvironment(org.springframework.core.env.ConfigurableEnvironment environment, org.springframework.boot.SpringApplication application) - Specified by:
postProcessEnvironment
in interfaceorg.springframework.boot.env.EnvironmentPostProcessor
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-
setOrder
public void setOrder(int order) -
onApplicationEvent
public void onApplicationEvent(org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent event) - Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener<org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent>
-