当前位置: 首页>>代码示例>>Java>>正文


Java ServletContextInitializer.onStartup方法代码示例

本文整理汇总了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);
}
 
开发者ID:paullyphang,项目名称:nebo,代码行数:25,代码来源:NettyEmbeddedServletContainerFactory.java

示例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());
		}
	}
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:TomcatStarter.java

示例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);
	}
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:8,代码来源:UndertowEmbeddedServletContainerFactory.java

示例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);
	}
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:12,代码来源:ServletContextInitializerConfiguration.java

示例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);
			}
		}
	}
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:16,代码来源:ServerPropertiesTests.java


注:本文中的org.springframework.boot.context.embedded.ServletContextInitializer.onStartup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。