public interface SpringApplicationRunListener
SpringApplication
run
method.
SpringApplicationRunListener
s are loaded via 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.Modifier and Type | Method and Description |
---|---|
default void |
contextLoaded(ConfigurableApplicationContext context)
Called once the application context has been loaded but before it has been
refreshed.
|
default void |
contextPrepared(ConfigurableApplicationContext context)
Called once the
ApplicationContext 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 the
ApplicationContext 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 all
CommandLineRunners and
ApplicationRunners have been called. |
default void |
running(ConfigurableApplicationContext context)
Deprecated.
since 2.6.0 for removal in 2.8.0 in favor of
ready(ConfigurableApplicationContext, Duration) |
default void |
started(ConfigurableApplicationContext context)
Deprecated.
since 2.6.0 for removal in 2.8.0 in favor of
started(ConfigurableApplicationContext, Duration) |
default void |
started(ConfigurableApplicationContext context,
Duration timeTaken)
The context has been refreshed and the application has started but
CommandLineRunners and ApplicationRunners have not been called. |
default void |
starting(ConfigurableBootstrapContext bootstrapContext)
Called immediately when the run method has first started.
|
default void starting(ConfigurableBootstrapContext bootstrapContext)
bootstrapContext
- the bootstrap contextdefault void environmentPrepared(ConfigurableBootstrapContext bootstrapContext, ConfigurableEnvironment environment)
ApplicationContext
has been created.bootstrapContext
- the bootstrap contextenvironment
- the environmentdefault void contextPrepared(ConfigurableApplicationContext context)
ApplicationContext
has been created and prepared, but
before sources have been loaded.context
- the application contextdefault void contextLoaded(ConfigurableApplicationContext context)
context
- the application contextdefault void started(ConfigurableApplicationContext context, Duration timeTaken)
CommandLineRunners
and ApplicationRunners
have not been called.context
- the application context.timeTaken
- the time taken to start the application or null
if unknown@Deprecated default void started(ConfigurableApplicationContext context)
started(ConfigurableApplicationContext, Duration)
CommandLineRunners
and ApplicationRunners
have not been called.context
- the application context.default void ready(ConfigurableApplicationContext context, Duration timeTaken)
CommandLineRunners
and
ApplicationRunners
have been called.context
- the application context.timeTaken
- the time taken for the application to be ready or null
if
unknown@Deprecated default void running(ConfigurableApplicationContext context)
ready(ConfigurableApplicationContext, Duration)
CommandLineRunners
and
ApplicationRunners
have been called.context
- the application context.default void failed(ConfigurableApplicationContext context, Throwable exception)
context
- the application context or null
if a failure occurred before
the context was createdexception
- the failure