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
- Author:
- Phillip Webb, Dave Syer, Andy Wilkinson, Chris Bono
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidCalled once the application context has been loaded but before it has been refreshed.default voidCalled once theApplicationContexthas been created and prepared, but before sources have been loaded.default voidenvironmentPrepared(ConfigurableBootstrapContext bootstrapContext, ConfigurableEnvironment environment) Called once the environment has been prepared, but before theApplicationContexthas been created.default voidfailed(@Nullable ConfigurableApplicationContext context, Throwable exception) Called when a failure occurs when running the application.default voidready(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(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, ConfigurableEnvironment environment) Called once the environment has been prepared, but before theApplicationContexthas been created.- Parameters:
bootstrapContext- the bootstrap contextenvironment- the environment
-
contextPrepared
Called once theApplicationContexthas been created and prepared, but before sources have been loaded.- Parameters:
context- the application context
-
contextLoaded
Called once the application context has been loaded but before it has been refreshed.- Parameters:
context- the application context
-
started
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
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
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
-