1
1
/*
2
- * Copyright 2002-2018 the original author or authors.
2
+ * Copyright 2002-2019 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
17
17
package org .springframework .context ;
18
18
19
19
/**
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
23
25
* be started at the time of a context refresh. The callback-accepting
24
26
* {@link #stop(Runnable)} method is useful for objects that have an asynchronous
25
27
* shutdown process. Any implementation of this interface <i>must</i> invoke the
26
28
* 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.
28
30
*
29
31
* <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}
33
35
* is the lowest possible, and {@code Integer.MAX_VALUE} is the highest possible).
34
36
* The shutdown process will apply the reverse order. Any components with the
35
37
* same value will be arbitrarily ordered within the same phase.
44
46
*
45
47
* <p>Any {@code Lifecycle} components within the context that do not also
46
48
* 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.
50
54
*
51
55
* <p>Note that, due to the auto-startup support in {@code SmartLifecycle}, a
52
56
* {@code SmartLifecycle} bean instance will usually get initialized on startup
55
59
*
56
60
* @author Mark Fisher
57
61
* @author Juergen Hoeller
62
+ * @author Sam Brannen
58
63
* @since 3.0
59
64
* @see LifecycleProcessor
60
65
* @see ConfigurableApplicationContext
@@ -63,9 +68,10 @@ public interface SmartLifecycle extends Lifecycle, Phased {
63
68
64
69
/**
65
70
* 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
67
72
* {@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.
69
75
* @since 5.1
70
76
* @see #getPhase()
71
77
* @see org.springframework.context.support.DefaultLifecycleProcessor#getPhase(Lifecycle)
@@ -115,7 +121,8 @@ default void stop(Runnable callback) {
115
121
/**
116
122
* Return the phase that this lifecycle object is supposed to run in.
117
123
* <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.
119
126
* @see #isAutoStartup()
120
127
* @see #start()
121
128
* @see #stop(Runnable)
0 commit comments