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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default order of the bootstrap application listener.

    Fields inherited from interface org.springframework.core.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    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)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.context.ApplicationListener

    supportsAsyncExecution
  • Field Details

    • DEFAULT_ORDER

      public static final int DEFAULT_ORDER
      Default 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 interface org.springframework.boot.EnvironmentPostProcessor
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered
    • setOrder

      public void setOrder(int order)
    • onApplicationEvent

      public void onApplicationEvent(org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent event)
      Specified by:
      onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent>