17
17
package org .springframework .context ;
18
18
19
19
/**
20
- * An extension of the Lifecycle interface for those beans that require to be
20
+ * An extension of the Lifecycle interface for those objects that require to be
21
21
* started upon ApplicationContext refresh and/or shutdown in a particular order.
22
+ * The {@link #isAutoStartup()} return value indicates whether this object should
23
+ * be started at the time of a context refresh. The callback-accepting
24
+ * {@link #stop(Runnable)} method is useful for objects that have an asynchronous
25
+ * shutdown process. Any implementation of this interface <i>must</i> invoke the
26
+ * callback's run() method upon shutdown completion to avoid unnecessary delays
27
+ * in the overall ApplicationContext shutdown.
28
+ * <p>
29
+ * 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>
32
+ * phase value and ends with the <i>highest</i> phase value (Integer.MIN_VALUE
33
+ * is the lowest possible, and Integer.MAX_VALUE is the highest possible). The
34
+ * shutdown process will apply the reverse order. Any components with the
35
+ * same value will be arbitrarily ordered within the same phase.
36
+ * <p>
37
+ * Example: if component B depends on component A having already started, then
38
+ * component A should have a lower phase value than component B. During the
39
+ * shutdown process, component B would be stopped before component A.
40
+ * <p>
41
+ * Any explicit "depends-on" relationship will take precedence over
42
+ * the phase order such that the dependent bean always starts after its
43
+ * dependency and always stops before its dependency.
44
+ * <p>
45
+ * Any Lifecycle components within the context that do not also implement
46
+ * SmartLifecycle will be treated as if they have a phase value of 0. That
47
+ * way a SmartLifecycle implementation may start before those Lifecycle
48
+ * components if it has a negative phase value, or it may start after
49
+ * those components if it has a positive phase value.
22
50
*
23
51
* @author Mark Fisher
24
52
* @since 3.0
25
53
*/
26
- public interface SmartLifecycle extends Lifecycle {
54
+ public interface SmartLifecycle extends Lifecycle , Phased {
27
55
28
56
/**
29
57
* Return whether this Lifecycle component should be started automatically
@@ -32,30 +60,6 @@ public interface SmartLifecycle extends Lifecycle {
32
60
*/
33
61
boolean isAutoStartup ();
34
62
35
- /**
36
- * Return the phase within which this Lifecycle component should be started
37
- * and stopped. The startup process begins with the <i>lowest</i> phase
38
- * value and ends with the <i>highest</i> phase value (Integer.MIN_VALUE is
39
- * the lowest possible, and Integer.MAX_VALUE is the highest possible). The
40
- * shutdown process will apply the reverse order. Any components with the
41
- * same value will be arbitrarily ordered within the same phase.
42
- * <p>
43
- * Example: if component B depends on component A having already started, then
44
- * component A should have a lower phase value than component B. During the
45
- * shutdown process, component B would be stopped before component A.
46
- * <p>
47
- * Any Lifecycle components within the context that do not also implement
48
- * SmartLifecycle will be treated as if they have a phase value of 0. That
49
- * way a SmartLifecycle implementation may start before those Lifecycle
50
- * components if it has a negative phase value, or it may start after
51
- * those components if it has a positive phase value.
52
- * <p>
53
- * Any explicit "depends-on" relationship will take precedence over
54
- * the phase order such that the dependent bean always starts after its
55
- * dependency and always stops before its dependency.
56
- */
57
- int getPhase ();
58
-
59
63
/**
60
64
* Indicates that a Lifecycle component must stop if it is currently running.
61
65
* The provided callback is used by the LifecycleProcessor to support an
0 commit comments