Search in sources :

Example 1 with Shutdown

use of org.springframework.boot.autoconfigure.task.TaskExecutionProperties.Shutdown in project spring-boot by spring-projects.

the class TaskExecutionAutoConfiguration method taskExecutorBuilder.

@Bean
@ConditionalOnMissingBean
public TaskExecutorBuilder taskExecutorBuilder(TaskExecutionProperties properties, ObjectProvider<TaskExecutorCustomizer> taskExecutorCustomizers, ObjectProvider<TaskDecorator> taskDecorator) {
    TaskExecutionProperties.Pool pool = properties.getPool();
    TaskExecutorBuilder builder = new TaskExecutorBuilder();
    builder = builder.queueCapacity(pool.getQueueCapacity());
    builder = builder.corePoolSize(pool.getCoreSize());
    builder = builder.maxPoolSize(pool.getMaxSize());
    builder = builder.allowCoreThreadTimeOut(pool.isAllowCoreThreadTimeout());
    builder = builder.keepAlive(pool.getKeepAlive());
    Shutdown shutdown = properties.getShutdown();
    builder = builder.awaitTermination(shutdown.isAwaitTermination());
    builder = builder.awaitTerminationPeriod(shutdown.getAwaitTerminationPeriod());
    builder = builder.threadNamePrefix(properties.getThreadNamePrefix());
    builder = builder.customizers(taskExecutorCustomizers.orderedStream()::iterator);
    builder = builder.taskDecorator(taskDecorator.getIfUnique());
    return builder;
}
Also used : Shutdown(org.springframework.boot.autoconfigure.task.TaskExecutionProperties.Shutdown) TaskExecutorBuilder(org.springframework.boot.task.TaskExecutorBuilder) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Shutdown (org.springframework.boot.autoconfigure.task.TaskExecutionProperties.Shutdown)1 TaskExecutorBuilder (org.springframework.boot.task.TaskExecutorBuilder)1 Bean (org.springframework.context.annotation.Bean)1