@@ -168,7 +168,7 @@ public void setTimeoutPerShutdownPhase(long timeoutPerShutdownPhase) {
168
168
this .timeoutPerShutdownPhase = timeoutPerShutdownPhase ;
169
169
}
170
170
171
- private long determineTimeout (int phase ) {
171
+ protected long determineStopTimeout (int phase ) {
172
172
Long timeout = this .timeoutsForShutdownPhases .get (phase );
173
173
return (timeout != null ? timeout : this .timeoutPerShutdownPhase );
174
174
}
@@ -182,7 +182,7 @@ public void setBeanFactory(BeanFactory beanFactory) {
182
182
this .beanFactory = clbf ;
183
183
}
184
184
185
- private ConfigurableListableBeanFactory getBeanFactory () {
185
+ protected ConfigurableListableBeanFactory getBeanFactory () {
186
186
ConfigurableListableBeanFactory beanFactory = this .beanFactory ;
187
187
Assert .state (beanFactory != null , "No BeanFactory available" );
188
188
return beanFactory ;
@@ -275,15 +275,15 @@ void restartAfterStop() {
275
275
}
276
276
}
277
277
278
- private void startBeans (boolean autoStartupOnly ) {
278
+ protected void startBeans (boolean autoStartupOnly ) {
279
279
Map <String , Lifecycle > lifecycleBeans = getLifecycleBeans ();
280
280
Map <Integer , LifecycleGroup > phases = new TreeMap <>();
281
281
282
282
lifecycleBeans .forEach ((beanName , bean ) -> {
283
283
if (!autoStartupOnly || isAutoStartupCandidate (beanName , bean )) {
284
284
int startupPhase = getPhase (bean );
285
285
phases .computeIfAbsent (startupPhase ,
286
- phase -> new LifecycleGroup (phase , determineTimeout (phase ), lifecycleBeans , autoStartupOnly )
286
+ phase -> new LifecycleGroup (phase , determineStopTimeout (phase ), lifecycleBeans , autoStartupOnly )
287
287
).add (beanName , bean );
288
288
}
289
289
});
@@ -293,7 +293,7 @@ private void startBeans(boolean autoStartupOnly) {
293
293
}
294
294
}
295
295
296
- private boolean isAutoStartupCandidate (String beanName , Lifecycle bean ) {
296
+ protected boolean isAutoStartupCandidate (String beanName , Lifecycle bean ) {
297
297
Set <String > stoppedBeans = this .stoppedBeans ;
298
298
return (stoppedBeans != null ? stoppedBeans .contains (beanName ) :
299
299
(bean instanceof SmartLifecycle smartLifecycle && smartLifecycle .isAutoStartup ()));
@@ -305,7 +305,7 @@ private boolean isAutoStartupCandidate(String beanName, Lifecycle bean) {
305
305
* @param lifecycleBeans a Map with bean name as key and Lifecycle instance as value
306
306
* @param beanName the name of the bean to start
307
307
*/
308
- private void doStart (Map <String , ? extends Lifecycle > lifecycleBeans , String beanName , boolean autoStartupOnly ) {
308
+ protected void doStart (Map <String , ? extends Lifecycle > lifecycleBeans , String beanName , boolean autoStartupOnly ) {
309
309
Lifecycle bean = lifecycleBeans .remove (beanName );
310
310
if (bean != null && bean != this ) {
311
311
String [] dependenciesForBean = getBeanFactory ().getDependenciesForBean (beanName );
@@ -342,7 +342,7 @@ private void stopBeans() {
342
342
lifecycleBeans .forEach ((beanName , bean ) -> {
343
343
int shutdownPhase = getPhase (bean );
344
344
phases .computeIfAbsent (shutdownPhase ,
345
- phase -> new LifecycleGroup (phase , determineTimeout (phase ), lifecycleBeans , false )
345
+ phase -> new LifecycleGroup (phase , determineStopTimeout (phase ), lifecycleBeans , false )
346
346
).add (beanName , bean );
347
347
});
348
348
@@ -357,7 +357,7 @@ private void stopBeans() {
357
357
* @param lifecycleBeans a Map with bean name as key and Lifecycle instance as value
358
358
* @param beanName the name of the bean to stop
359
359
*/
360
- private void doStop (Map <String , ? extends Lifecycle > lifecycleBeans , final String beanName ,
360
+ protected void doStop (Map <String , ? extends Lifecycle > lifecycleBeans , final String beanName ,
361
361
final CountDownLatch latch , final Set <String > countDownBeanNames ) {
362
362
363
363
Lifecycle bean = lifecycleBeans .remove (beanName );
@@ -466,17 +466,17 @@ protected int getPhase(Lifecycle bean) {
466
466
* The group is expected to be created in an ad-hoc fashion and group members are
467
467
* expected to always have the same 'phase' value.
468
468
*/
469
- private class LifecycleGroup {
469
+ protected class LifecycleGroup {
470
470
471
- private final int phase ;
471
+ protected final int phase ;
472
472
473
- private final long timeout ;
473
+ protected final long timeout ;
474
474
475
- private final Map <String , ? extends Lifecycle > lifecycleBeans ;
475
+ protected final Map <String , ? extends Lifecycle > lifecycleBeans ;
476
476
477
- private final boolean autoStartupOnly ;
477
+ protected final boolean autoStartupOnly ;
478
478
479
- private final List <LifecycleGroupMember > members = new ArrayList <>();
479
+ protected final List <LifecycleGroupMember > members = new ArrayList <>();
480
480
481
481
private int smartMemberCount ;
482
482
@@ -545,7 +545,7 @@ else if (member.bean instanceof SmartLifecycle) {
545
545
/**
546
546
* A simple record of a LifecycleGroup member.
547
547
*/
548
- private record LifecycleGroupMember (String name , Lifecycle bean ) {}
548
+ protected record LifecycleGroupMember (String name , Lifecycle bean ) {}
549
549
550
550
551
551
/**
0 commit comments