1. 程式人生 > >Spring boot加載REACTIVE程序過程

Spring boot加載REACTIVE程序過程

() 類型 row wrap pan urn line rap ims

spring-boot通過判斷含org.springframework.web.reactive.DispatcherHandler類就肯定程序類型是REACTIVE,然後加載上下文類org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext,看下面代碼
private WebApplicationType deduceWebApplicationType() {
        if (ClassUtils.isPresent("org.springframework.web.reactive.DispatcherHandler", (ClassLoader)null
) && !ClassUtils.isPresent("org.springframework.web.servlet.DispatcherServlet", (ClassLoader)null) && !ClassUtils.isPresent("org.glassfish.jersey.server.ResourceConfig", (ClassLoader)null)) { return WebApplicationType.REACTIVE; } else { String[] var1 = WEB_ENVIRONMENT_CLASSES;
int var2 = var1.length; for(int var3 = 0; var3 < var2; ++var3) { String className = var1[var3]; if (!ClassUtils.isPresent(className, (ClassLoader)null)) { return WebApplicationType.NONE; } } return
WebApplicationType.SERVLET; } }

WebServer在org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext創建

    protected void onRefresh() {
        super.onRefresh();

        try {
            this.createWebServer();
        } catch (Throwable var2) {
            throw new ApplicationContextException("Unable to start reactive web server", var2);
        }
    }


Spring boot加載REACTIVE程序過程