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.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 (isRegisterJspServlet()
       && ClassUtils.isPresent(getJspServletClassName(), getClass().getClassLoader())) {
     addJspServlet(context);
     addJasperInitializer(context);
     context.addLifecycleListener(new StoreMergedWebXmlListener());
   }
   ServletContextInitializer[] initializersToUse = mergeInitializers(initializers);
   configureContext(context, initializersToUse);
   host.addChild(context);
   postProcessContext(context);
 }
예제 #2
0
 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);
 }