Skip to content

Commit 3d83f86

Browse files
committed
Fix Javadoc for SmartLifecycle.DEFAULT_PHASE regarding ordering
Closes gh-23956
1 parent 088a653 commit 3d83f86

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

spring-context/src/main/java/org/springframework/context/SmartLifecycle.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,19 +17,21 @@
1717
package org.springframework.context;
1818

1919
/**
20-
* An extension of the {@link Lifecycle} interface for those objects that require to
21-
* be started upon ApplicationContext refresh and/or shutdown in a particular order.
22-
* The {@link #isAutoStartup()} return value indicates whether this object should
20+
* An extension of the {@link Lifecycle} interface for those objects that require
21+
* to be started upon {@code ApplicationContext} refresh and/or shutdown in a
22+
* particular order.
23+
*
24+
* <p>The {@link #isAutoStartup()} return value indicates whether this object should
2325
* be started at the time of a context refresh. The callback-accepting
2426
* {@link #stop(Runnable)} method is useful for objects that have an asynchronous
2527
* shutdown process. Any implementation of this interface <i>must</i> invoke the
2628
* callback's {@code run()} method upon shutdown completion to avoid unnecessary
27-
* delays in the overall ApplicationContext shutdown.
29+
* delays in the overall {@code ApplicationContext} shutdown.
2830
*
2931
* <p>This interface extends {@link Phased}, and the {@link #getPhase()} method's
30-
* return value indicates the phase within which this Lifecycle component should
31-
* be started and stopped. The startup process begins with the <i>lowest</i> phase
32-
* value and ends with the <i>highest</i> phase value ({@code Integer.MIN_VALUE}
32+
* return value indicates the phase within which this {@code Lifecycle} component
33+
* should be started and stopped. The startup process begins with the <i>lowest</i>
34+
* phase value and ends with the <i>highest</i> phase value ({@code Integer.MIN_VALUE}
3335
* is the lowest possible, and {@code Integer.MAX_VALUE} is the highest possible).
3436
* The shutdown process will apply the reverse order. Any components with the
3537
* same value will be arbitrarily ordered within the same phase.
@@ -44,9 +46,11 @@
4446
*
4547
* <p>Any {@code Lifecycle} components within the context that do not also
4648
* implement {@code SmartLifecycle} will be treated as if they have a phase
47-
* value of 0. That way a {@code SmartLifecycle} implementation may start
48-
* before those {@code Lifecycle} components if it has a negative phase value,
49-
* or it may start after those components if it has a positive phase value.
49+
* value of {@code 0}. This allows a {@code SmartLifecycle} component to start
50+
* before those {@code Lifecycle} components if the {@code SmartLifecycle}
51+
* component has a negative phase value, or the {@code SmartLifecycle} component
52+
* may start after those {@code Lifecycle} components if the {@code SmartLifecycle}
53+
* component has a positive phase value.
5054
*
5155
* <p>Note that, due to the auto-startup support in {@code SmartLifecycle}, a
5256
* {@code SmartLifecycle} bean instance will usually get initialized on startup
@@ -55,6 +59,7 @@
5559
*
5660
* @author Mark Fisher
5761
* @author Juergen Hoeller
62+
* @author Sam Brannen
5863
* @since 3.0
5964
* @see LifecycleProcessor
6065
* @see ConfigurableApplicationContext
@@ -63,9 +68,10 @@ public interface SmartLifecycle extends Lifecycle, Phased {
6368

6469
/**
6570
* The default phase for {@code SmartLifecycle}: {@code Integer.MAX_VALUE}.
66-
* <p>This is different from the common phase 0 associated with regular
71+
* <p>This is different from the common phase {@code 0} associated with regular
6772
* {@link Lifecycle} implementations, putting the typically auto-started
68-
* {@code SmartLifecycle} beans into a separate later shutdown phase.
73+
* {@code SmartLifecycle} beans into a later startup phase and an earlier
74+
* shutdown phase.
6975
* @since 5.1
7076
* @see #getPhase()
7177
* @see org.springframework.context.support.DefaultLifecycleProcessor#getPhase(Lifecycle)
@@ -115,7 +121,8 @@ default void stop(Runnable callback) {
115121
/**
116122
* Return the phase that this lifecycle object is supposed to run in.
117123
* <p>The default implementation returns {@link #DEFAULT_PHASE} in order to
118-
* let stop callbacks execute after regular {@code Lifecycle} implementations.
124+
* let {@code stop()} callbacks execute after regular {@code Lifecycle}
125+
* implementations.
119126
* @see #isAutoStartup()
120127
* @see #start()
121128
* @see #stop(Runnable)

0 commit comments

Comments
 (0)