Skip to content

Commit 997f07d

Browse files
ayudovinsnicoll
authored andcommitted
Add default no-op method to SpringApplicationRunListener
See gh-16104
1 parent 3d0219c commit 997f07d

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,40 @@
3131
* @author Phillip Webb
3232
* @author Dave Syer
3333
* @author Andy Wilkinson
34+
* @author Artsiom Yudovin
3435
*/
3536
public interface SpringApplicationRunListener {
3637

3738
/**
3839
* Called immediately when the run method has first started. Can be used for very
3940
* early initialization.
4041
*/
41-
void starting();
42+
default void starting() {
43+
}
4244

4345
/**
4446
* Called once the environment has been prepared, but before the
4547
* {@link ApplicationContext} has been created.
4648
* @param environment the environment
4749
*/
48-
void environmentPrepared(ConfigurableEnvironment environment);
50+
default void environmentPrepared(ConfigurableEnvironment environment) {
51+
}
4952

5053
/**
5154
* Called once the {@link ApplicationContext} has been created and prepared, but
5255
* before sources have been loaded.
5356
* @param context the application context
5457
*/
55-
void contextPrepared(ConfigurableApplicationContext context);
58+
default void contextPrepared(ConfigurableApplicationContext context) {
59+
}
5660

5761
/**
5862
* Called once the application context has been loaded but before it has been
5963
* refreshed.
6064
* @param context the application context
6165
*/
62-
void contextLoaded(ConfigurableApplicationContext context);
66+
default void contextLoaded(ConfigurableApplicationContext context) {
67+
}
6368

6469
/**
6570
* The context has been refreshed and the application has started but
@@ -68,7 +73,8 @@ public interface SpringApplicationRunListener {
6873
* @param context the application context.
6974
* @since 2.0.0
7075
*/
71-
void started(ConfigurableApplicationContext context);
76+
default void started(ConfigurableApplicationContext context) {
77+
}
7278

7379
/**
7480
* Called immediately before the run method finishes, when the application context has
@@ -77,7 +83,8 @@ public interface SpringApplicationRunListener {
7783
* @param context the application context.
7884
* @since 2.0.0
7985
*/
80-
void running(ConfigurableApplicationContext context);
86+
default void running(ConfigurableApplicationContext context) {
87+
}
8188

8289
/**
8390
* Called when a failure occurs when running the application.
@@ -86,6 +93,7 @@ public interface SpringApplicationRunListener {
8693
* @param exception the failure
8794
* @since 2.0.0
8895
*/
89-
void failed(ConfigurableApplicationContext context, Throwable exception);
96+
default void failed(ConfigurableApplicationContext context, Throwable exception) {
97+
}
9098

9199
}

0 commit comments

Comments
 (0)