本文整理汇总了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");
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例10: getServletContainerInitializer
import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
@Override
public ServletContainerInitializer getServletContainerInitializer() {
if (this.servletContainerInitializer == null) {
this.servletContainerInitializer = new FacesInitializer();
}
return this.servletContainerInitializer;
}
示例11: getServletContainerInitializer
import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
@Override
public ServletContainerInitializer getServletContainerInitializer() {
if (this.servletContainerInitializer == null) {
this.servletContainerInitializer = new MyFacesContainerInitializer();
}
return this.servletContainerInitializer;
}
示例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);
}
示例13: getServletContainerInitializer
import javax.servlet.ServletContainerInitializer; //导入依赖的package包/类
@Override
public ServletContainerInitializer getServletContainerInitializer() {
if (this.servletContainerInitializer == null) {
this.servletContainerInitializer = new FacesViewsInitializer();
}
return this.servletContainerInitializer;
}
示例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