use of cn.taketoday.web.framework.WebServerApplicationContext in project today-framework by TAKETODAY.
the class AbstractServletWebServer method prepareInitialize.
@Override
protected void prepareInitialize() {
super.prepareInitialize();
WebServerApplicationContext context = obtainApplicationContext();
Class<?> mainApplicationClass = getMainApplicationClass();
if (mainApplicationClass != null) {
ServletSecurity servletSecurity = mainApplicationClass.getAnnotation(ServletSecurity.class);
if (servletSecurity != null) {
BeanDefinitionRegistry registry = context.unwrapFactory(BeanDefinitionRegistry.class);
if (registry.containsBeanDefinition(ServletSecurityElement.class)) {
log.info("Multiple: [{}] Overriding its bean definition", ServletSecurityElement.class.getName());
}
context.unwrap(BeanDefinitionRegistrar.class).registerSingleton(new ServletSecurityElement(servletSecurity));
}
}
addDefaultServlet();
addJspServlet();
}
use of cn.taketoday.web.framework.WebServerApplicationContext in project today-framework by TAKETODAY.
the class AbstractWebServer method prepareInitialize.
protected void prepareInitialize() {
log.info("Prepare initialize web server");
WebServerApplicationContext context = obtainApplicationContext();
Environment environment = context.getEnvironment();
TodayStrategies.setProperty(WebApplicationLoader.ENABLE_WEB_STARTED_LOG, Boolean.FALSE.toString());
String webMvcConfigLocation = environment.getProperty(WebApplicationLoader.WEB_MVC_CONFIG_LOCATION);
if (StringUtils.isNotEmpty(webMvcConfigLocation)) {
TodayStrategies.setProperty(WebApplicationLoader.ENABLE_WEB_MVC_XML, Boolean.TRUE.toString());
}
}
use of cn.taketoday.web.framework.WebServerApplicationContext in project today-framework by TAKETODAY.
the class NettyWebServer method preBootstrap.
/**
* before bootstrap
*
* @param bootstrap netty ServerBootstrap
*/
protected void preBootstrap(ServerBootstrap bootstrap) {
ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED);
// adjust context path
WebServerApplicationContext context = obtainApplicationContext();
NettyRequestContextConfig contextConfig = context.getBean(NettyRequestContextConfig.class);
Assert.state(contextConfig != null, "No NettyRequestContextConfig");
String contextPath = contextConfig.getContextPath();
String serverContextPath = getContextPath();
if (contextPath == null) {
contextConfig.setContextPath(serverContextPath);
} else {
if (serverContextPath != null) {
if (!Objects.equals(serverContextPath, contextPath)) {
log.info("Using NettyRequestContextConfig 'contextPath' -> '{}'", contextPath);
setContextPath(contextPath);
// reset contextPath
applyContextPath(context);
}
} else {
setContextPath(contextPath);
}
}
}
use of cn.taketoday.web.framework.WebServerApplicationContext in project today-framework by TAKETODAY.
the class NettyWebServer method getNettyServerInitializer.
protected NettyServerInitializer getNettyServerInitializer() {
NettyServerInitializer serverInitializer = this.nettyServerInitializer;
if (serverInitializer == null) {
WebServerApplicationContext context = obtainApplicationContext();
serverInitializer = context.getBean(NettyServerInitializer.class);
if (serverInitializer == null) {
ReactiveChannelHandler reactiveDispatcher = context.getBean(ReactiveChannelHandler.class);
serverInitializer = new NettyServerInitializer(reactiveDispatcher);
}
}
return serverInitializer;
}
use of cn.taketoday.web.framework.WebServerApplicationContext in project today-framework by TAKETODAY.
the class NettyWebServer method contextInitialized.
@Override
protected void contextInitialized() {
super.contextInitialized();
WebServerApplicationContext context = obtainApplicationContext();
try {
WebServerApplicationLoader loader = new WebServerApplicationLoader(this::getMergedInitializers);
loader.setApplicationContext(context);
loader.onStartup(context);
} catch (Throwable e) {
throw ExceptionUtils.sneakyThrow(e);
}
}
Aggregations