Polishing
This commit is contained in:
parent
f50b230fb3
commit
8e8c3f5a7c
|
@ -979,7 +979,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||||
for (String beanName : beanNames) {
|
for (String beanName : beanNames) {
|
||||||
Object singletonInstance = getSingleton(beanName);
|
Object singletonInstance = getSingleton(beanName);
|
||||||
if (singletonInstance instanceof SmartInitializingSingleton smartSingleton) {
|
if (singletonInstance instanceof SmartInitializingSingleton smartSingleton) {
|
||||||
StartupStep smartInitialize = this.getApplicationStartup().start("spring.beans.smart-initialize")
|
StartupStep smartInitialize = getApplicationStartup().start("spring.beans.smart-initialize")
|
||||||
.tag("beanName", beanName);
|
.tag("beanName", beanName);
|
||||||
smartSingleton.afterSingletonsInstantiated();
|
smartSingleton.afterSingletonsInstantiated();
|
||||||
smartInitialize.end();
|
smartInitialize.end();
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
|
||||||
/**
|
/**
|
||||||
* Specify the maximum time allotted in milliseconds for the shutdown of
|
* Specify the maximum time allotted in milliseconds for the shutdown of
|
||||||
* any phase (group of SmartLifecycle beans with the same 'phase' value).
|
* any phase (group of SmartLifecycle beans with the same 'phase' value).
|
||||||
* <p>The default value is 30 seconds.
|
* <p>The default value is 30000 milliseconds (30 seconds).
|
||||||
*/
|
*/
|
||||||
public void setTimeoutPerShutdownPhase(long timeoutPerShutdownPhase) {
|
public void setTimeoutPerShutdownPhase(long timeoutPerShutdownPhase) {
|
||||||
this.timeoutPerShutdownPhase = timeoutPerShutdownPhase;
|
this.timeoutPerShutdownPhase = timeoutPerShutdownPhase;
|
||||||
|
|
|
@ -108,9 +108,9 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac
|
||||||
/**
|
/**
|
||||||
* Set whether to wait for scheduled tasks to complete on shutdown,
|
* Set whether to wait for scheduled tasks to complete on shutdown,
|
||||||
* not interrupting running tasks and executing all tasks in the queue.
|
* not interrupting running tasks and executing all tasks in the queue.
|
||||||
* <p>Default is "false", shutting down immediately through interrupting
|
* <p>Default is {@code false}, shutting down immediately through interrupting
|
||||||
* ongoing tasks and clearing the queue. Switch this flag to "true" if you
|
* ongoing tasks and clearing the queue. Switch this flag to {@code true} if
|
||||||
* prefer fully completed tasks at the expense of a longer shutdown phase.
|
* you prefer fully completed tasks at the expense of a longer shutdown phase.
|
||||||
* <p>Note that Spring's container shutdown continues while ongoing tasks
|
* <p>Note that Spring's container shutdown continues while ongoing tasks
|
||||||
* are being completed. If you want this executor to block and wait for the
|
* are being completed. If you want this executor to block and wait for the
|
||||||
* termination of tasks before the rest of the container continues to shut
|
* termination of tasks before the rest of the container continues to shut
|
||||||
|
@ -211,9 +211,13 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a shutdown on the underlying ExecutorService.
|
* Perform a full shutdown on the underlying ExecutorService,
|
||||||
|
* according to the corresponding configuration settings.
|
||||||
|
* @see #setWaitForTasksToCompleteOnShutdown
|
||||||
|
* @see #setAwaitTerminationMillis
|
||||||
* @see java.util.concurrent.ExecutorService#shutdown()
|
* @see java.util.concurrent.ExecutorService#shutdown()
|
||||||
* @see java.util.concurrent.ExecutorService#shutdownNow()
|
* @see java.util.concurrent.ExecutorService#shutdownNow()
|
||||||
|
* @see java.util.concurrent.ExecutorService#awaitTermination
|
||||||
*/
|
*/
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
|
|
|
@ -96,8 +96,7 @@ public class EnableAsyncTests {
|
||||||
public void properExceptionForExistingProxyDependencyMismatch() {
|
public void properExceptionForExistingProxyDependencyMismatch() {
|
||||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||||
ctx.register(AsyncConfig.class, AsyncBeanWithInterface.class, AsyncBeanUser.class);
|
ctx.register(AsyncConfig.class, AsyncBeanWithInterface.class, AsyncBeanUser.class);
|
||||||
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(
|
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(ctx::refresh)
|
||||||
ctx::refresh)
|
|
||||||
.withCauseInstanceOf(BeanNotOfRequiredTypeException.class);
|
.withCauseInstanceOf(BeanNotOfRequiredTypeException.class);
|
||||||
ctx.close();
|
ctx.close();
|
||||||
}
|
}
|
||||||
|
@ -106,8 +105,7 @@ public class EnableAsyncTests {
|
||||||
public void properExceptionForResolvedProxyDependencyMismatch() {
|
public void properExceptionForResolvedProxyDependencyMismatch() {
|
||||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||||
ctx.register(AsyncConfig.class, AsyncBeanUser.class, AsyncBeanWithInterface.class);
|
ctx.register(AsyncConfig.class, AsyncBeanUser.class, AsyncBeanWithInterface.class);
|
||||||
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(
|
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(ctx::refresh)
|
||||||
ctx::refresh)
|
|
||||||
.withCauseInstanceOf(BeanNotOfRequiredTypeException.class);
|
.withCauseInstanceOf(BeanNotOfRequiredTypeException.class);
|
||||||
ctx.close();
|
ctx.close();
|
||||||
}
|
}
|
||||||
|
@ -208,8 +206,7 @@ public class EnableAsyncTests {
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||||
ctx.register(AspectJAsyncAnnotationConfig.class);
|
ctx.register(AspectJAsyncAnnotationConfig.class);
|
||||||
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(
|
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(ctx::refresh);
|
||||||
ctx::refresh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -521,6 +518,7 @@ public class EnableAsyncTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
static class AsyncWithExecutorQualifiedByExpressionConfig {
|
static class AsyncWithExecutorQualifiedByExpressionConfig {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -125,18 +125,19 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify the phase in which this container should be started and
|
* Specify the lifecycle phase in which this container should be started and stopped.
|
||||||
* stopped. The startup order proceeds from lowest to highest, and
|
* <p>The startup order proceeds from lowest to highest, and the shutdown order
|
||||||
* the shutdown order is the reverse of that. By default this value
|
* is the reverse of that. The default is {@link #DEFAULT_PHASE} meaning that
|
||||||
* is Integer.MAX_VALUE meaning that this container starts as late
|
* this container starts as late as possible and stops as soon as possible.
|
||||||
* as possible and stops as soon as possible.
|
* @see SmartLifecycle#getPhase()
|
||||||
*/
|
*/
|
||||||
public void setPhase(int phase) {
|
public void setPhase(int phase) {
|
||||||
this.phase = phase;
|
this.phase = phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the phase in which this container will be started and stopped.
|
* Return the lifecycle phase in which this container will be started and stopped.
|
||||||
|
* @see #setPhase
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getPhase() {
|
public int getPhase() {
|
||||||
|
|
Loading…
Reference in New Issue