在Spring场景,Restlight支持通过xxxAware接口获取一些内部对象。
其中包含
RestlightBizExecutorAware: 获取业务线程池RestlightIoExecutorAware: 获取IO线程池RestlightServerAware: 获取RestlightServerRestlightDeployContextAware: 获取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);
}
}