在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 CompletionStage<String> foo() {
return CompletableFuture.supplyAsync(() -> "Hello Restlight!", bizExecutor);
}
}