33
33
import org .springframework .context .ApplicationContext ;
34
34
import org .springframework .context .ApplicationContextAware ;
35
35
import org .springframework .context .ApplicationListener ;
36
+ import org .springframework .context .Lifecycle ;
36
37
import org .springframework .context .SmartLifecycle ;
37
38
import org .springframework .context .event .ContextClosedEvent ;
38
39
import org .springframework .lang .Nullable ;
@@ -58,6 +59,20 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac
58
59
implements BeanNameAware , ApplicationContextAware , InitializingBean , DisposableBean ,
59
60
SmartLifecycle , ApplicationListener <ContextClosedEvent > {
60
61
62
+ /**
63
+ * The default phase for an executor {@link SmartLifecycle}: {@code Integer.MAX_VALUE / 2}.
64
+ * <p>This is different from the default phase {@code Integer.MAX_VALUE} associated with
65
+ * other {@link SmartLifecycle} implementations, putting the typically auto-started
66
+ * executor/scheduler beans into an earlier startup phase and a later shutdown phase while
67
+ * still leaving room for regular {@link Lifecycle} components with the common phase 0.
68
+ * @since 6.2
69
+ * @see #getPhase()
70
+ * @see SmartLifecycle#DEFAULT_PHASE
71
+ * @see org.springframework.context.support.DefaultLifecycleProcessor#setTimeoutPerShutdownPhase
72
+ */
73
+ public static final int DEFAULT_PHASE = Integer .MAX_VALUE / 2 ;
74
+
75
+
61
76
protected final Log logger = LogFactory .getLog (getClass ());
62
77
63
78
private ThreadFactory threadFactory = this ;
@@ -218,7 +233,8 @@ public void setAwaitTerminationMillis(long awaitTerminationMillis) {
218
233
219
234
/**
220
235
* Specify the lifecycle phase for pausing and resuming this executor.
221
- * The default is {@link #DEFAULT_PHASE}.
236
+ * <p>The default for executors/schedulers is {@link #DEFAULT_PHASE} as of 6.2,
237
+ * for stopping after other {@link SmartLifecycle} implementations.
222
238
* @since 6.1
223
239
* @see SmartLifecycle#getPhase()
224
240
*/
0 commit comments