本文整理匯總了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