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);
    }

}

Last modified July 28, 2022: refactor main docs to v0.1.1 (#199) (8423db1)