use of cn.taketoday.framework.web.server.WebServer in project today-framework by TAKETODAY.
the class JettyReactiveWebServerFactory method getWebServer.
@Override
public WebServer getWebServer(HttpHandler httpHandler) {
JettyHttpHandlerAdapter servlet = new JettyHttpHandlerAdapter(httpHandler);
Server server = createJettyServer(servlet);
return new JettyWebServer(server, getPort() >= 0);
}
use of cn.taketoday.framework.web.server.WebServer 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();
}
use of cn.taketoday.framework.web.server.WebServer in project today-framework by TAKETODAY.
the class WebServerPortFileWriterTests method mockEvent.
private WebServerInitializedEvent mockEvent(String namespace, int port) {
WebServer webServer = mock(WebServer.class);
given(webServer.getPort()).willReturn(port);
WebServerApplicationContext applicationContext = mock(WebServerApplicationContext.class);
given(applicationContext.getServerNamespace()).willReturn(namespace);
given(applicationContext.getWebServer()).willReturn(webServer);
WebServerInitializedEvent event = mock(WebServerInitializedEvent.class);
given(event.getApplicationContext()).willReturn(applicationContext);
given(event.getWebServer()).willReturn(webServer);
return event;
}
use of cn.taketoday.framework.web.server.WebServer in project today-infrastructure by TAKETODAY.
the class WebServerPortFileWriterTests method mockEvent.
private WebServerInitializedEvent mockEvent(String namespace, int port) {
WebServer webServer = mock(WebServer.class);
given(webServer.getPort()).willReturn(port);
WebServerApplicationContext applicationContext = mock(WebServerApplicationContext.class);
given(applicationContext.getServerNamespace()).willReturn(namespace);
given(applicationContext.getWebServer()).willReturn(webServer);
WebServerInitializedEvent event = mock(WebServerInitializedEvent.class);
given(event.getApplicationContext()).willReturn(applicationContext);
given(event.getWebServer()).willReturn(webServer);
return event;
}
use of cn.taketoday.framework.web.server.WebServer 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();
}
Aggregations