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 July 28, 2022: refactor main docs to v0.1.1 (#199) (8423db1)