Aware扩展
在Spring
场景,Restlight
支持通过xxxAware
接口获取一些内部对象。
其中包含
RestlightBizExecutorAware
: 获取业务线程池RestlightIoExecutorAware
: 获取IO线程池RestlightServerAware
: 获取RestlightServer
RestlightDeployContextAware
: 获取DeployContext
eg.
获取业务线程池
@Controller
public class HelloController implements RestlightBizExecutorAware {
private Executor bizExecutor;
@Override
public void setRestlightBizExecutor(Executor bizExecutor) {
this.bizExecutor = bizExecutor;
}
@GetMapping("/foo")
public CompletableFuture<String> foo() {
return CompletableFuture.supplyAsync(() -> "Hello Restlight!", bizExecutor);
}
}
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.
Last modified March 10, 2022: introduce docsy as the website framework and add docs-v1.0.0 (#120) (79630ff)