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 TypeMethodDescriptiondefault voidcontextLoaded(org.springframework.context.ConfigurableApplicationContext context) Called once the application context has been loaded but before it has been refreshed.default voidcontextPrepared(org.springframework.context.ConfigurableApplicationContext context) Called once theApplicationContexthas been created and prepared, but before sources have been loaded.default voidenvironmentPrepared(ConfigurableBootstrapContext bootstrapContext, org.springframework.core.env.ConfigurableEnvironment environment) Called once the environment has been prepared, but before theApplicationContexthas been created.default voidfailed(@Nullable org.springframework.context.ConfigurableApplicationContext context, Throwable exception) Called when a failure occurs when running the application.default voidready(org.springframework.context.ConfigurableApplicationContext context, @Nullable Duration timeTaken) Called immediately before the run method finishes, when the application context has been refreshed and allCommandLineRunnersandApplicationRunnershave been called.default voidstarted(org.springframework.context.ConfigurableApplicationContext context, @Nullable Duration timeTaken) The context has been refreshed and the application has started butCommandLineRunnersandApplicationRunnershave not been called.default voidstarting(ConfigurableBootstrapContext bootstrapContext) Called immediately when the run method has first started.
-
Method Details
-
starting
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 theApplicationContexthas been created.- Parameters:
bootstrapContext- the bootstrap contextenvironment- the environment
-
contextPrepared
default void contextPrepared(org.springframework.context.ConfigurableApplicationContext context) Called once theApplicationContexthas 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, @Nullable Duration timeTaken) The context has been refreshed and the application has started butCommandLineRunnersandApplicationRunnershave not been called.- Parameters:
context- the application context.timeTaken- the time taken to start the application ornullif unknown- Since:
- 2.6.0
-
ready
default void ready(org.springframework.context.ConfigurableApplicationContext context, @Nullable Duration timeTaken) Called immediately before the run method finishes, when the application context has been refreshed and allCommandLineRunnersandApplicationRunnershave been called.- Parameters:
context- the application context.timeTaken- the time taken for the application to be ready ornullif unknown- Since:
- 2.6.0
-
failed
default void failed(@Nullable org.springframework.context.ConfigurableApplicationContext context, Throwable exception) Called when a failure occurs when running the application.- Parameters:
context- the application context ornullif a failure occurred before the context was createdexception- the failure- Since:
- 2.0.0
-