本文整理汇总了Java中org.springframework.boot.context.embedded.ServletContextInitializer.onStartup方法的典型用法代码示例。如果您正苦于以下问题:Java ServletContextInitializer.onStartup方法的具体用法?Java ServletContextInitializer.onStartup怎么用?Java ServletContextInitializer.onStartup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.boot.context.embedded.ServletContextInitializer
的用法示例。
在下文中一共展示了ServletContextInitializer.onStartup方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEmbeddedServletContainer
import org.springframework.boot.context.embedded.ServletContextInitializer; //导入方法依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(ServletContextInitializer... initializers) {
ClassLoader parentClassLoader = resourceLoader != null ? resourceLoader.getClassLoader() : ClassUtils.getDefaultClassLoader();
Package nettyPackage = Bootstrap.class.getPackage();
String title = nettyPackage.getImplementationTitle();
String version = nettyPackage.getImplementationVersion();
logger.info("Running with " + title + " " + version);
NettyEmbeddedContext context = new NettyEmbeddedContext(getContextPath(), new URLClassLoader(new URL[]{}, parentClassLoader), SERVER_INFO);
if (isRegisterDefaultServlet()) {
logger.warn("This container does not support a default servlet");
}
for (ServletContextInitializer initializer : initializers) {
try {
initializer.onStartup(context);
} catch (ServletException e) {
throw new RuntimeException(e);
}
}
int port = getPort() > 0 ? getPort() : new Random().nextInt(65535 - 1024) + 1024;
InetSocketAddress address = new InetSocketAddress(port);
logger.info("Server initialized with port: " + port);
return new NettyEmbeddedServletContainer(address, context);
}
示例2: onStartup
import org.springframework.boot.context.embedded.ServletContextInitializer; //导入方法依赖的package包/类
@Override
public void onStartup(Set<Class<?>> classes, ServletContext servletContext)
throws ServletException {
try {
for (ServletContextInitializer initializer : this.initializers) {
initializer.onStartup(servletContext);
}
}
catch (Exception ex) {
this.startUpException = ex;
// Prevent Tomcat from logging and re-throwing when we know we can
// deal with it in the main thread, but log for information here.
if (logger.isErrorEnabled()) {
logger.error("Error starting Tomcat context: " + ex.getClass().getName());
}
}
}
示例3: getEmbeddedServletContainer
import org.springframework.boot.context.embedded.ServletContextInitializer; //导入方法依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(ServletContextInitializer... initializers) {
ClassLoader parentClassLoader = resourceLoader != null ? resourceLoader.getClassLoader() : ClassUtils.getDefaultClassLoader();
Package nettyPackage = Bootstrap.class.getPackage();
String title = nettyPackage.getImplementationTitle();
String version = nettyPackage.getImplementationVersion();
logger.info("Running with " + title + " " + version);
NettyEmbeddedContext context = new NettyEmbeddedContext(getContextPath(), new URLClassLoader(new URL[]{}, parentClassLoader), SERVER_INFO);
if (isRegisterDefaultServlet()) {
logger.warn("This container does not support a default servlet");
}
if (isRegisterJspServlet()) {
logger.warn("This container does not support a JSP servlet");
}
for (ServletContextInitializer initializer : initializers) {
try {
initializer.onStartup(context);
} catch (ServletException e) {
throw new RuntimeException(e);
}
}
int port = getPort() > 0 ? getPort() : new Random().nextInt(65535 - 1024) + 1024;
InetSocketAddress address = new InetSocketAddress(port);
logger.info("Server initialized with port: " + port);
return new NettyEmbeddedServletContainer(address, context);
}
开发者ID:DanielThomas,项目名称:spring-boot-starter-netty,代码行数:27,代码来源:NettyEmbeddedServletContainerFactory.java
示例4: onStartup
import org.springframework.boot.context.embedded.ServletContextInitializer; //导入方法依赖的package包/类
@Override
public void onStartup(Set<Class<?>> classes, ServletContext servletContext)
throws ServletException {
for (ServletContextInitializer initializer : this.initializers) {
initializer.onStartup(servletContext);
}
}
示例5: callInitializers
import org.springframework.boot.context.embedded.ServletContextInitializer; //导入方法依赖的package包/类
private void callInitializers() throws ServletException {
try {
setExtendedListenerTypes(true);
for (ServletContextInitializer initializer : ServletContextInitializerConfiguration.this.initializers) {
initializer.onStartup(this.context.getServletContext());
}
}
finally {
setExtendedListenerTypes(false);
}
}
示例6: triggerInitializers
import org.springframework.boot.context.embedded.ServletContextInitializer; //导入方法依赖的package包/类
private void triggerInitializers(ConfigurableEmbeddedServletContainer container,
ServletContext servletContext) throws ServletException {
verify(container, atLeastOnce())
.addInitializers(this.initializersCaptor.capture());
for (Object initializers : this.initializersCaptor.getAllValues()) {
if (initializers instanceof ServletContextInitializer) {
((ServletContextInitializer) initializers).onStartup(servletContext);
}
else {
for (ServletContextInitializer initializer : (ServletContextInitializer[]) initializers) {
initializer.onStartup(servletContext);
}
}
}
}