Package org.springframework.boot
Interface SpringApplicationRunListener
public interface SpringApplicationRunListener
Listener for the
SpringApplication
run
method.
SpringApplicationRunListener
s 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 void
Called once the application context has been loaded but before it has been refreshed.default void
Called once theApplicationContext
has been created and prepared, but before sources have been loaded.default void
environmentPrepared
(ConfigurableBootstrapContext bootstrapContext, ConfigurableEnvironment environment) Called once the environment has been prepared, but before theApplicationContext
has been created.default void
failed
(ConfigurableApplicationContext context, Throwable exception) Called when a failure occurs when running the application.default void
ready
(ConfigurableApplicationContext context, Duration timeTaken) Called immediately before the run method finishes, when the application context has been refreshed and allCommandLineRunners
andApplicationRunners
have been called.default void
started
(ConfigurableApplicationContext context, Duration timeTaken) The context has been refreshed and the application has started butCommandLineRunners
andApplicationRunners
have not been called.default void
starting
(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 theApplicationContext
has been created.- Parameters:
bootstrapContext
- the bootstrap contextenvironment
- the environment
-
contextPrepared
Called once theApplicationContext
has 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 butCommandLineRunners
andApplicationRunners
have not been called.- Parameters:
context
- the application context.timeTaken
- the time taken to start the application ornull
if unknown- Since:
- 2.6.0
-
ready
Called immediately before the run method finishes, when the application context has been refreshed and allCommandLineRunners
andApplicationRunners
have been called.- Parameters:
context
- the application context.timeTaken
- the time taken for the application to be ready ornull
if unknown- Since:
- 2.6.0
-
failed
Called when a failure occurs when running the application.- Parameters:
context
- the application context ornull
if a failure occurred before the context was createdexception
- the failure- Since:
- 2.0.0
-