Search in sources :

Example 1 with WebServerGracefulShutdownLifecycle

use of cn.taketoday.framework.web.context.WebServerGracefulShutdownLifecycle in project today-infrastructure by TAKETODAY.

the class ReactiveWebServerApplicationContext method createWebServer.

private void createWebServer() {
    WebServerManager serverManager = this.serverManager;
    if (serverManager == null) {
        String webServerFactoryBeanName = getWebServerFactoryBeanName();
        ReactiveWebServerFactory webServerFactory = getWebServerFactory(webServerFactoryBeanName);
        StandardBeanFactory beanFactory = getBeanFactory();
        boolean lazyInit = beanFactory.getBeanDefinition(webServerFactoryBeanName).isLazyInit();
        this.serverManager = new WebServerManager(this, webServerFactory, this::getHttpHandler, lazyInit);
        beanFactory.registerSingleton("webServerGracefulShutdown", new WebServerGracefulShutdownLifecycle(this.serverManager.getWebServer()));
        beanFactory.registerSingleton("webServerStartStop", new WebServerStartStopLifecycle(this.serverManager));
    }
    initPropertySources();
}
Also used : WebServerGracefulShutdownLifecycle(cn.taketoday.framework.web.context.WebServerGracefulShutdownLifecycle) ReactiveWebServerFactory(cn.taketoday.framework.web.reactive.server.ReactiveWebServerFactory) StandardBeanFactory(cn.taketoday.beans.factory.support.StandardBeanFactory)

Example 2 with WebServerGracefulShutdownLifecycle

use of cn.taketoday.framework.web.context.WebServerGracefulShutdownLifecycle in project today-framework by TAKETODAY.

the class ReactiveWebServerApplicationContext method createWebServer.

private void createWebServer() {
    WebServerManager serverManager = this.serverManager;
    if (serverManager == null) {
        String webServerFactoryBeanName = getWebServerFactoryBeanName();
        ReactiveWebServerFactory webServerFactory = getWebServerFactory(webServerFactoryBeanName);
        StandardBeanFactory beanFactory = getBeanFactory();
        boolean lazyInit = beanFactory.getBeanDefinition(webServerFactoryBeanName).isLazyInit();
        this.serverManager = new WebServerManager(this, webServerFactory, this::getHttpHandler, lazyInit);
        beanFactory.registerSingleton("webServerGracefulShutdown", new WebServerGracefulShutdownLifecycle(this.serverManager.getWebServer()));
        beanFactory.registerSingleton("webServerStartStop", new WebServerStartStopLifecycle(this.serverManager));
    }
    initPropertySources();
}
Also used : WebServerGracefulShutdownLifecycle(cn.taketoday.framework.web.context.WebServerGracefulShutdownLifecycle) ReactiveWebServerFactory(cn.taketoday.framework.web.reactive.server.ReactiveWebServerFactory) StandardBeanFactory(cn.taketoday.beans.factory.support.StandardBeanFactory)

Example 3 with WebServerGracefulShutdownLifecycle

use of cn.taketoday.framework.web.context.WebServerGracefulShutdownLifecycle in project today-framework by TAKETODAY.

the class ServletWebServerApplicationContext method createWebServer.

private void createWebServer() {
    WebServer webServer = this.webServer;
    ServletContext servletContext = getServletContext();
    if (webServer == null && servletContext == null) {
        ServletWebServerFactory factory = getWebServerFactory();
        webServer = factory.getWebServer(getSelfInitializer());
        StandardBeanFactory beanFactory = getBeanFactory();
        beanFactory.registerSingleton("webServerStartStop", new WebServerStartStopLifecycle(this, webServer));
        beanFactory.registerSingleton("webServerGracefulShutdown", new WebServerGracefulShutdownLifecycle(webServer));
        this.webServer = webServer;
    } else if (servletContext != null) {
        try {
            getSelfInitializer().onStartup(servletContext);
        } catch (ServletException ex) {
            throw new ApplicationContextException("Cannot initialize servlet context", ex);
        }
    }
    initPropertySources();
}
Also used : ServletException(jakarta.servlet.ServletException) ServletWebServerFactory(cn.taketoday.framework.web.servlet.server.ServletWebServerFactory) WebServer(cn.taketoday.framework.web.server.WebServer) WebServerGracefulShutdownLifecycle(cn.taketoday.framework.web.context.WebServerGracefulShutdownLifecycle) ServletContext(jakarta.servlet.ServletContext) StandardBeanFactory(cn.taketoday.beans.factory.support.StandardBeanFactory) ApplicationContextException(cn.taketoday.context.ApplicationContextException)

Example 4 with WebServerGracefulShutdownLifecycle

use of cn.taketoday.framework.web.context.WebServerGracefulShutdownLifecycle in project today-infrastructure by TAKETODAY.

the class ServletWebServerApplicationContext method createWebServer.

private void createWebServer() {
    WebServer webServer = this.webServer;
    ServletContext servletContext = getServletContext();
    if (webServer == null && servletContext == null) {
        ServletWebServerFactory factory = getWebServerFactory();
        webServer = factory.getWebServer(getSelfInitializer());
        StandardBeanFactory beanFactory = getBeanFactory();
        beanFactory.registerSingleton("webServerStartStop", new WebServerStartStopLifecycle(this, webServer));
        beanFactory.registerSingleton("webServerGracefulShutdown", new WebServerGracefulShutdownLifecycle(webServer));
        this.webServer = webServer;
    } else if (servletContext != null) {
        try {
            getSelfInitializer().onStartup(servletContext);
        } catch (ServletException ex) {
            throw new ApplicationContextException("Cannot initialize servlet context", ex);
        }
    }
    initPropertySources();
}
Also used : ServletException(jakarta.servlet.ServletException) ServletWebServerFactory(cn.taketoday.framework.web.servlet.server.ServletWebServerFactory) WebServer(cn.taketoday.framework.web.server.WebServer) WebServerGracefulShutdownLifecycle(cn.taketoday.framework.web.context.WebServerGracefulShutdownLifecycle) ServletContext(jakarta.servlet.ServletContext) StandardBeanFactory(cn.taketoday.beans.factory.support.StandardBeanFactory) ApplicationContextException(cn.taketoday.context.ApplicationContextException)

Aggregations

StandardBeanFactory (cn.taketoday.beans.factory.support.StandardBeanFactory)4 WebServerGracefulShutdownLifecycle (cn.taketoday.framework.web.context.WebServerGracefulShutdownLifecycle)4 ApplicationContextException (cn.taketoday.context.ApplicationContextException)2 ReactiveWebServerFactory (cn.taketoday.framework.web.reactive.server.ReactiveWebServerFactory)2 WebServer (cn.taketoday.framework.web.server.WebServer)2 ServletWebServerFactory (cn.taketoday.framework.web.servlet.server.ServletWebServerFactory)2 ServletContext (jakarta.servlet.ServletContext)2 ServletException (jakarta.servlet.ServletException)2