public class ContextDecorator extends Object implements org.springframework.core.task.TaskDecorator
https://stackoverflow.com/questions/23732089/how-to-enable-request-scope-in-async-task-executor
传递:RequestAttributes and MDC and SecurityContext
| 限定符和类型 | 字段和说明 |
|---|---|
protected AsyncProperties |
asyncProperties |
| 构造器和说明 |
|---|
ContextDecorator() |
| 限定符和类型 | 方法和说明 |
|---|---|
Runnable |
decorate(Runnable runnable) |
static void |
enableServletAsyncContext(org.springframework.web.context.request.ServletRequestAttributes context,
AsyncProperties asyncProperties)
启用 ServletAsyncContext
用于阻塞父线程 Servlet 的关闭(调用 destroy() 方法),导致子线程获取的上下文为空
|
protected AsyncProperties asyncProperties
public Runnable decorate(Runnable runnable)
decorate 在接口中 org.springframework.core.task.TaskDecoratorpublic static void enableServletAsyncContext(org.springframework.web.context.request.ServletRequestAttributes context,
AsyncProperties asyncProperties)
用于阻塞父线程 Servlet 的关闭(调用 destroy() 方法),导致子线程获取的上下文为空
context - 父线程上下文asyncProperties - 异步属性配置Copyright © 2021 Pivotal Software, Inc.. All rights reserved.