本文整理汇总了Java中org.apache.catalina.startup.Tomcat.FixContextListener类的典型用法代码示例。如果您正苦于以下问题:Java FixContextListener类的具体用法?Java FixContextListener怎么用?Java FixContextListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FixContextListener类属于org.apache.catalina.startup.Tomcat包,在下文中一共展示了FixContextListener类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: prepareContext
import org.apache.catalina.startup.Tomcat.FixContextListener; //导入依赖的package包/类
protected void prepareContext(Host host, ServletContextInitializer[] initializers) {
File docBase = getValidDocumentRoot();
docBase = (docBase != null ? docBase : createTempDir("tomcat-docbase"));
TomcatEmbeddedContext context = new TomcatEmbeddedContext();
context.setName(getContextPath());
context.setDisplayName(getDisplayName());
context.setPath(getContextPath());
context.setDocBase(docBase.getAbsolutePath());
context.addLifecycleListener(new FixContextListener());
context.setParentClassLoader(
this.resourceLoader != null ? this.resourceLoader.getClassLoader()
: ClassUtils.getDefaultClassLoader());
try {
context.setUseRelativeRedirects(false);
}
catch (NoSuchMethodError ex) {
// Tomcat is < 8.0.30. Continue
}
SkipPatternJarScanner.apply(context, this.tldSkip);
WebappLoader loader = new WebappLoader(context.getParentClassLoader());
loader.setLoaderClass(TomcatEmbeddedWebappClassLoader.class.getName());
loader.setDelegate(true);
context.setLoader(loader);
if (isRegisterDefaultServlet()) {
addDefaultServlet(context);
}
if (shouldRegisterJspServlet()) {
addJspServlet(context);
addJasperInitializer(context);
context.addLifecycleListener(new StoreMergedWebXmlListener());
}
ServletContextInitializer[] initializersToUse = mergeInitializers(initializers);
configureContext(context, initializersToUse);
host.addChild(context);
postProcessContext(context);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:37,代码来源:TomcatEmbeddedServletContainerFactory.java
示例2: prepareContext
import org.apache.catalina.startup.Tomcat.FixContextListener; //导入依赖的package包/类
protected void prepareContext(Host host, ServletContextInitializer[] initializers) {
File docBase = getValidDocumentRoot();
docBase = (docBase != null ? docBase : createTempDir("tomcat-docbase"));
TomcatEmbeddedContext context = new TomcatEmbeddedContext();
context.setName(getContextPath());
context.setDisplayName(getDisplayName());
context.setPath(getContextPath());
context.setDocBase(docBase.getAbsolutePath());
context.addLifecycleListener(new FixContextListener());
context.setParentClassLoader(
this.resourceLoader != null ? this.resourceLoader.getClassLoader()
: ClassUtils.getDefaultClassLoader());
try {
context.setUseRelativeRedirects(false);
context.setMapperContextRootRedirectEnabled(true);
}
catch (NoSuchMethodError ex) {
// Tomcat is < 8.0.30. Continue
}
SkipPatternJarScanner.apply(context, this.tldSkip);
WebappLoader loader = new WebappLoader(context.getParentClassLoader());
loader.setLoaderClass(TomcatEmbeddedWebappClassLoader.class.getName());
loader.setDelegate(true);
context.setLoader(loader);
if (isRegisterDefaultServlet()) {
addDefaultServlet(context);
}
if (shouldRegisterJspServlet()) {
addJspServlet(context);
addJasperInitializer(context);
context.addLifecycleListener(new StoreMergedWebXmlListener());
}
ServletContextInitializer[] initializersToUse = mergeInitializers(initializers);
configureContext(context, initializersToUse);
host.addChild(context);
postProcessContext(context);
}
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:38,代码来源:TomcatEmbeddedServletContainerFactory.java
示例3: prepareContext
import org.apache.catalina.startup.Tomcat.FixContextListener; //导入依赖的package包/类
protected void prepareContext(Host host, ServletContextInitializer[] initializers) {
File docBase = getValidDocumentRoot();
docBase = (docBase != null ? docBase : createTempDir("tomcat-docbase"));
TomcatEmbeddedContext context = new TomcatEmbeddedContext();
context.setName(getContextPath());
context.setDisplayName(getDisplayName());
context.setPath(getContextPath());
context.setDocBase(docBase.getAbsolutePath());
context.addLifecycleListener(new FixContextListener());
context.setParentClassLoader(
this.resourceLoader != null ? this.resourceLoader.getClassLoader()
: ClassUtils.getDefaultClassLoader());
SkipPatternJarScanner.apply(context, this.tldSkip);
WebappLoader loader = new WebappLoader(context.getParentClassLoader());
loader.setLoaderClass(TomcatEmbeddedWebappClassLoader.class.getName());
loader.setDelegate(true);
context.setLoader(loader);
if (isRegisterDefaultServlet()) {
addDefaultServlet(context);
}
if (shouldRegisterJspServlet()) {
addJspServlet(context);
addJasperInitializer(context);
context.addLifecycleListener(new StoreMergedWebXmlListener());
}
ServletContextInitializer[] initializersToUse = mergeInitializers(initializers);
configureContext(context, initializersToUse);
host.addChild(context);
postProcessContext(context);
}
开发者ID:Nephilim84,项目名称:contestparser,代码行数:31,代码来源:TomcatEmbeddedServletContainerFactory.java
示例4: testBug57190
import org.apache.catalina.startup.Tomcat.FixContextListener; //导入依赖的package包/类
@Test
public void testBug57190() throws Exception {
Tomcat tomcat = getTomcatInstance();
Context foo1 = new StandardContext();
foo1.setName("/foo##1");
foo1.setPath("/foo");
foo1.setWebappVersion("1");
foo1.setDocBase(System.getProperty("java.io.tmpdir"));
foo1.addLifecycleListener(new FixContextListener());
foo1.addLifecycleListener(new SetIdListener("foo1"));
tomcat.getHost().addChild(foo1);
Context foo2 = new StandardContext();
foo2.setName("/foo##2");
foo2.setPath("/foo");
foo2.setWebappVersion("2");
foo2.setDocBase(System.getProperty("java.io.tmpdir"));
foo2.addLifecycleListener(new FixContextListener());
foo2.addLifecycleListener(new SetIdListener("foo2"));
tomcat.getHost().addChild(foo2);
// No file system docBase required
Context bar = tomcat.addContext("/bar", null);
bar.addLifecycleListener(new SetIdListener("bar"));
// No file system docBase required
Context ctx = tomcat.addContext("", null);
ctx.addLifecycleListener(new SetIdListener("ROOT"));
ctx.setCrossContext(true);
Tomcat.addServlet(ctx, "Bug57190Servlet", new Bug57190Servlet());
ctx.addServletMapping("/", "Bug57190Servlet");
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
String body = res.toString();
Assert.assertTrue(body, body.contains("01-bar"));
Assert.assertTrue(body, body.contains("02-foo2"));
Assert.assertTrue(body, body.contains("03-foo1"));
Assert.assertTrue(body, body.contains("04-foo2"));
Assert.assertTrue(body, body.contains("05-foo2"));
Assert.assertTrue(body, body.contains("06-ROOT"));
Assert.assertTrue(body, body.contains("07-ROOT"));
Assert.assertTrue(body, body.contains("08-foo2"));
Assert.assertTrue(body, body.contains("09-ROOT"));
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:50,代码来源:TestApplicationContext.java
注:本文中的org.apache.catalina.startup.Tomcat.FixContextListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论