Search in sources :

Example 1 with ConfigurableWebServer

use of cn.taketoday.web.framework.server.ConfigurableWebServer in project today-framework by TAKETODAY.

the class WebApplicationUtils method obtainWebServer.

/**
 * Obtain a {@link WebServer} form bean-factory
 *
 * @param beanFactory Target bean-factory
 * @return WebServer
 */
public static WebServer obtainWebServer(WebServerApplicationContext beanFactory) {
    // disable web mvc xml
    TodayStrategies.setProperty(WebApplicationLoader.ENABLE_WEB_MVC_XML, "false");
    // Get WebServer instance
    WebServer webServer = beanFactory.getBean(WebServer.class);
    if (webServer == null) {
        throw new ConfigurationException("The bean factory: [" + beanFactory + "] doesn't exist a [cn.taketoday.web.framework.server.WebServer] bean");
    }
    if (webServer instanceof ConfigurableWebServer) {
        if (webServer instanceof AbstractWebServer) {
            ((AbstractWebServer) webServer).getWebApplicationConfiguration().configureWebServer((AbstractWebServer) webServer);
        }
        ((ConfigurableWebServer) webServer).initialize();
    }
    return webServer;
}
Also used : ConfigurableWebServer(cn.taketoday.web.framework.server.ConfigurableWebServer) AbstractWebServer(cn.taketoday.web.framework.server.AbstractWebServer) WebServer(cn.taketoday.web.framework.server.WebServer) ConfigurationException(cn.taketoday.core.ConfigurationException) ConfigurableWebServer(cn.taketoday.web.framework.server.ConfigurableWebServer) AbstractWebServer(cn.taketoday.web.framework.server.AbstractWebServer)

Aggregations

ConfigurationException (cn.taketoday.core.ConfigurationException)1 AbstractWebServer (cn.taketoday.web.framework.server.AbstractWebServer)1 ConfigurableWebServer (cn.taketoday.web.framework.server.ConfigurableWebServer)1 WebServer (cn.taketoday.web.framework.server.WebServer)1