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


Java ServletContainerInitializer类代码示例

本文整理汇总了Java中javax.servlet.ServletContainerInitializer的典型用法代码示例。如果您正苦于以下问题:Java ServletContainerInitializer类的具体用法?Java ServletContainerInitializer怎么用?Java ServletContainerInitializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServletContainerInitializer类属于javax.servlet包,在下文中一共展示了ServletContainerInitializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onStartup

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
@Override
public void onStartup(final Set<Class<?>> classes, final ServletContext ctx) throws ServletException {
    if (System.getProperty("openejb.embedder.source") != null) {
        ctx.log("TomEE already initialized");
        return;
    }

    ctx.log("Embedded TomEE starting");

    final Properties properties = new Properties();
    properties.putAll(System.getProperties());
    properties.setProperty("openejb.system.apps", Boolean.toString(Boolean.getBoolean("openejb.system.apps")));
    properties.setProperty("tomee.war", new File(ctx.getRealPath("WEB-INF")).getParentFile().getAbsolutePath());
    properties.setProperty("openejb.embedder.source", getClass().getSimpleName());

    TomcatEmbedder.embed(properties, ServletContainerInitializer.class.getClassLoader());

    ctx.log("Embedded TomEE started");

    Deployer.deploy(ctx);

    ctx.log("Application '" + ctx.getContextPath() + "' TomEE-ised");
}
 
开发者ID:apache,项目名称:tomee,代码行数:24,代码来源:TomEEOverlayRunner.java

示例2: start

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
private void start() throws InstantiationException, IllegalAccessException {

        TomcatApplicationBuilderFactory builderFactory = factoryClass.newInstance();
        TomcatApplicationBuilder builder = builderFactory.getBuilder(annotation);

        for (ServletContainerInitializer initializer : initializers) {
            builder.addServletContainerInitializer(initializer);
        }

        if (annotation != null) {
            this.timeout = annotation.timeout();
        } else {
            this.timeout = TomcatServerConfig.DEFAULT_TIMEOUT;
        }

        Tomcat tomcat = builder.build();

        this.runtime = tomcat.start(timeout);
    }
 
开发者ID:pidster-dot-org,项目名称:embed-apache-tomcat,代码行数:20,代码来源:TomcatServerRule.java

示例3: getBuilder

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
@Override
public TomcatApplicationBuilder getBuilder(TomcatServerConfig annotation) {

    File baseFile = getBaseDir(annotation);
    String appName = getAppName(annotation);
    int port = getPort(annotation);

    File appDir = new File(baseFile, String.format("webapps/%s", appName));
    if (!appDir.exists() && !appDir.mkdirs()) {
        throw new IllegalStateException("Unable to create app dir at: " + appDir);
    }

    TomcatApplicationBuilder builder = new TomcatFactory().create()
        .newMinimalServer(baseFile, port)
            .createApplication(appName)
            .setStartStopThreads(1)
            .withDefaultConfig();

    if (annotation != null) {
        for (Class<? extends ServletContainerInitializer> initializer : annotation.value()) {
            builder.addServletContainerInitializer(initializer);
        }
    }

    return builder;
}
 
开发者ID:pidster-dot-org,项目名称:embed-apache-tomcat,代码行数:27,代码来源:SimpleTomcatApplicationBuilderFactory.java

示例4: getSCIsForClass

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
private Set<ServletContainerInitializer> getSCIsForClass(String className) {
    for (Map.Entry<Class<?>, Set<ServletContainerInitializer>> entry :
            typeInitializerMap.entrySet()) {
        Class<?> clazz = entry.getKey();
        if (!clazz.isAnnotation()) {
            if (clazz.getName().equals(className)) {
                return entry.getValue();
            }
        }
    }
    return EMPTY_SCI_SET;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:ContextConfig.java

示例5: testWebapp

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
@Test
public void testWebapp() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    File appDir = new File("test/webapp-3.0-fragments-empty-absolute-ordering");
    StandardContext ctxt = (StandardContext) tomcat.addContext(null, "/test", appDir.getAbsolutePath());
    ctxt.addLifecycleListener(new ContextConfig());
    tomcat.start();

    WebappServiceLoader<ServletContainerInitializer> loader =
            new WebappServiceLoader<ServletContainerInitializer>(ctxt);
    @SuppressWarnings("unused")
    Collection<ServletContainerInitializer> initializers = loader.load(ServletContainerInitializer.class);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:14,代码来源:TestWebappServiceLoader.java

示例6: testBug50015

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
@Test
public void testBug50015() throws Exception {
    // Test that configuring servlet security constraints programmatically
    // does work.

    // Set up a container
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    // Setup realm
    MapRealm realm = new MapRealm();
    realm.addUser("tomcat", "tomcat");
    realm.addUserRole("tomcat", "tomcat");
    ctx.setRealm(realm);

    // Configure app for BASIC auth
    LoginConfig lc = new LoginConfig();
    lc.setAuthMethod("BASIC");
    ctx.setLoginConfig(lc);
    ctx.getPipeline().addValve(new BasicAuthenticator());

    // Add ServletContainerInitializer
    ServletContainerInitializer sci = new Bug50015SCI();
    ctx.addServletContainerInitializer(sci, null);

    // Start the context
    tomcat.start();

    // Request the first servlet
    ByteChunk bc = new ByteChunk();
    int rc = getUrl("http://localhost:" + getPort() + "/bug50015",
            bc, null);

    // Check for a 401
    assertNotSame("OK", bc.toString());
    assertEquals(401, rc);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:40,代码来源:TestStandardContext.java

示例7: doTestSecurityAnnotationsAddServlet

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
private void doTestSecurityAnnotationsAddServlet(boolean useCreateServlet)
        throws Exception {

    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    Servlet s = new DenyAllServlet();
    ServletContainerInitializer sci = new SCI(s, useCreateServlet);
    ctx.addServletContainerInitializer(sci, null);

    tomcat.start();

    ByteChunk bc = new ByteChunk();
    int rc;
    rc = getUrl("http://localhost:" + getPort() + "/", bc, null, null);

    if (useCreateServlet) {
        assertTrue(bc.getLength() > 0);
        assertEquals(403, rc);
    } else {
        assertEquals("OK", bc.toString());
        assertEquals(200, rc);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:28,代码来源:TestStandardWrapper.java

示例8: populateSCIsForCacheEntry

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
private void populateSCIsForCacheEntry(JavaClassCacheEntry cacheEntry) {
	Set<ServletContainerInitializer> result = new HashSet<ServletContainerInitializer>();

	// Super class
	String superClassName = cacheEntry.getSuperclassName();
	JavaClassCacheEntry superClassCacheEntry = javaClassCache.get(superClassName);

	// Avoid an infinite loop with java.lang.Object
	if (cacheEntry.equals(superClassCacheEntry)) {
		cacheEntry.setSciSet(EMPTY_SCI_SET);
		return;
	}

	// May be null of the class is not present or could not be loaded.
	if (superClassCacheEntry != null) {
		if (superClassCacheEntry.getSciSet() == null) {
			populateSCIsForCacheEntry(superClassCacheEntry);
		}
		result.addAll(superClassCacheEntry.getSciSet());
	}
	result.addAll(getSCIsForClass(superClassName));

	// Interfaces
	for (String interfaceName : cacheEntry.getInterfaceNames()) {
		JavaClassCacheEntry interfaceEntry = javaClassCache.get(interfaceName);
		// A null could mean that the class not present in application or
		// that there is nothing of interest. Either way, nothing to do here
		// so move along
		if (interfaceEntry != null) {
			if (interfaceEntry.getSciSet() == null) {
				populateSCIsForCacheEntry(interfaceEntry);
			}
			result.addAll(interfaceEntry.getSciSet());
		}
		result.addAll(getSCIsForClass(interfaceName));
	}

	cacheEntry.setSciSet(result.isEmpty() ? EMPTY_SCI_SET : result);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:40,代码来源:ContextConfig.java

示例9: getSCIsForClass

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
private Set<ServletContainerInitializer> getSCIsForClass(String className) {
	for (Map.Entry<Class<?>, Set<ServletContainerInitializer>> entry : typeInitializerMap.entrySet()) {
		Class<?> clazz = entry.getKey();
		if (!clazz.isAnnotation()) {
			if (clazz.getName().equals(className)) {
				return entry.getValue();
			}
		}
	}
	return EMPTY_SCI_SET;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:12,代码来源:ContextConfig.java

示例10: getServletContainerInitializer

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
@Override
public ServletContainerInitializer getServletContainerInitializer() {
	if (this.servletContainerInitializer == null) {
		this.servletContainerInitializer = new FacesInitializer();
	}
	return this.servletContainerInitializer;
}
 
开发者ID:joinfaces,项目名称:joinfaces,代码行数:8,代码来源:MojarraServletContextInitializer.java

示例11: getServletContainerInitializer

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
@Override
public ServletContainerInitializer getServletContainerInitializer() {
	if (this.servletContainerInitializer == null) {
		this.servletContainerInitializer = new MyFacesContainerInitializer();
	}
	return this.servletContainerInitializer;
}
 
开发者ID:joinfaces,项目名称:joinfaces,代码行数:8,代码来源:MyfacesServletContextInitializer.java

示例12: onStartup

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
@Override
public void onStartup(ServletContext sc) throws ServletException {
	ServletContainerInitializer servletContainerInitializer = getServletContainerInitializer();
	JsfClassFactory jsfClassFactory = new JsfClassFactory(this);
	JoinFacesAnnotationProvider.setAnnotatedClasses(jsfClassFactory.getAnnotatedClassMap());
	JoinFacesAnnotationProvider.setUrls(jsfClassFactory.getURLs());
	servletContainerInitializer.onStartup(jsfClassFactory.getAllClasses(), sc);
}
 
开发者ID:joinfaces,项目名称:joinfaces,代码行数:9,代码来源:MyfacesServletContextInitializer.java

示例13: getServletContainerInitializer

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
@Override
public ServletContainerInitializer getServletContainerInitializer() {
	if (this.servletContainerInitializer == null) {
		this.servletContainerInitializer = new FacesViewsInitializer();
	}
	return this.servletContainerInitializer;
}
 
开发者ID:joinfaces,项目名称:joinfaces,代码行数:8,代码来源:OmnifacesServletContextInitializer.java

示例14: addJasperInitializer

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
private void addJasperInitializer(TomcatEmbeddedContext context) {
	try {
		ServletContainerInitializer initializer = (ServletContainerInitializer) ClassUtils
				.forName("org.apache.jasper.servlet.JasperInitializer", null)
				.newInstance();
		context.addServletContainerInitializer(initializer, null);
	}
	catch (Exception ex) {
		// Probably not Tomcat 8
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:TomcatEmbeddedServletContainerFactory.java

示例15: registerServletContainerInitializerToDriveServletContextInitializers

import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
private void registerServletContainerInitializerToDriveServletContextInitializers(
		DeploymentInfo deployment, ServletContextInitializer... initializers) {
	ServletContextInitializer[] mergedInitializers = mergeInitializers(initializers);
	Initializer initializer = new Initializer(mergedInitializers);
	deployment.addServletContainerInitalizer(new ServletContainerInitializerInfo(
			Initializer.class,
			new ImmediateInstanceFactory<ServletContainerInitializer>(initializer),
			NO_CLASSES));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:UndertowEmbeddedServletContainerFactory.java


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