Class ConfigServerBootstrapApplicationListener
java.lang.Object
org.springframework.cloud.config.server.bootstrap.ConfigServerBootstrapApplicationListener
- All Implemented Interfaces:
EventListener, org.springframework.boot.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.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 intDefault 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 TypeMethodDescriptionintgetOrder()voidonApplicationEvent(org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent event) voidpostProcessEnvironment(org.springframework.core.env.ConfigurableEnvironment environment, org.springframework.boot.SpringApplication application) voidsetOrder(int order) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
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:
postProcessEnvironmentin interfaceorg.springframework.boot.EnvironmentPostProcessor
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
setOrder
public void setOrder(int order) -
onApplicationEvent
public void onApplicationEvent(org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent event) - Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent>
-