Interface SpringApplicationRunListener


public interface SpringApplicationRunListener
Listener for the SpringApplication run method. SpringApplicationRunListeners are loaded through the SpringFactoriesLoader and should declare a public constructor that accepts a SpringApplication instance and a String[] of arguments. A new SpringApplicationRunListener instance will be created for each run.
Since:
1.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    contextLoaded(org.springframework.context.ConfigurableApplicationContext context)
    Called once the application context has been loaded but before it has been refreshed.
    default void
    contextPrepared(org.springframework.context.ConfigurableApplicationContext context)
    Called once the ApplicationContext has been created and prepared, but before sources have been loaded.
    default void
    environmentPrepared(ConfigurableBootstrapContext bootstrapContext, org.springframework.core.env.ConfigurableEnvironment environment)
    Called once the environment has been prepared, but before the ApplicationContext has been created.
    default void
    failed(org.springframework.context.ConfigurableApplicationContext context, Throwable exception)
    Called when a failure occurs when running the application.
    default void
    ready(org.springframework.context.ConfigurableApplicationContext context, Duration timeTaken)
    Called immediately before the run method finishes, when the application context has been refreshed and all CommandLineRunners and ApplicationRunners have been called.
    default void
    started(org.springframework.context.ConfigurableApplicationContext context, Duration timeTaken)
    The context has been refreshed and the application has started but CommandLineRunners and ApplicationRunners have not been called.
    default void
    Called immediately when the run method has first started.
  • Method Details

    • starting

      default void starting(ConfigurableBootstrapContext bootstrapContext)
      Called immediately when the run method has first started. Can be used for very early initialization.
      Parameters:
      bootstrapContext - the bootstrap context
    • environmentPrepared

      default void environmentPrepared(ConfigurableBootstrapContext bootstrapContext, org.springframework.core.env.ConfigurableEnvironment environment)
      Called once the environment has been prepared, but before the ApplicationContext has been created.
      Parameters:
      bootstrapContext - the bootstrap context
      environment - the environment
    • contextPrepared

      default void contextPrepared(org.springframework.context.ConfigurableApplicationContext context)
      Called once the ApplicationContext has been created and prepared, but before sources have been loaded.
      Parameters:
      context - the application context
    • contextLoaded

      default void contextLoaded(org.springframework.context.ConfigurableApplicationContext context)
      Called once the application context has been loaded but before it has been refreshed.
      Parameters:
      context - the application context
    • started

      default void started(org.springframework.context.ConfigurableApplicationContext context, Duration timeTaken)
      The context has been refreshed and the application has started but CommandLineRunners and ApplicationRunners have not been called.
      Parameters:
      context - the application context.
      timeTaken - the time taken to start the application or null if unknown
      Since:
      2.6.0
    • ready

      default void ready(org.springframework.context.ConfigurableApplicationContext context, Duration timeTaken)
      Called immediately before the run method finishes, when the application context has been refreshed and all CommandLineRunners and ApplicationRunners have been called.
      Parameters:
      context - the application context.
      timeTaken - the time taken for the application to be ready or null if unknown
      Since:
      2.6.0
    • failed

      default void failed(org.springframework.context.ConfigurableApplicationContext context, Throwable exception)
      Called when a failure occurs when running the application.
      Parameters:
      context - the application context or null if a failure occurred before the context was created
      exception - the failure
      Since:
      2.0.0