ctx.setParentClassLoader(TomcatRuntime.class.getClassLoader()); StandardJarScanner jarScanner = (StandardJarScanner) ctx.getJarScanner(); if (System.getProperty(Constants.SKIP_JARS_PROPERTY) == null && System.getProperty(Constants.SCAN_JARS_PROPERTY) == null) {
ctx.setParentClassLoader(TomcatRuntime.class.getClassLoader()); StandardJarScanner jarScanner = (StandardJarScanner) ctx.getJarScanner(); if (System.getProperty(Constants.SKIP_JARS_PROPERTY) == null && System.getProperty(Constants.SCAN_JARS_PROPERTY) == null) {
public TomcatServer(Configuration configuration) { try { this.tomcat = new Tomcat(); tomcat.setBaseDir(configuration.getDocBase()); tomcat.setPort(configuration.getServerPort()); File root = getRootFolder(); File webContentFolder = new File(root.getAbsolutePath(), configuration.getResourcePath()); if (!webContentFolder.exists()) { webContentFolder = Files.createTempDirectory("default-doc-base").toFile(); } log.info("Tomcat:configuring app with basedir: [{}]", webContentFolder.getAbsolutePath()); StandardContext ctx = (StandardContext) tomcat.addWebapp(configuration.getContextPath(), webContentFolder.getAbsolutePath()); ctx.setParentClassLoader(this.getClass().getClassLoader()); WebResourceRoot resources = new StandardRoot(ctx); ctx.setResources(resources); tomcat.addServlet(configuration.getContextPath(), "dispatcherServlet", new DispatcherServlet()).setLoadOnStartup(0); ctx.addServletMappingDecoded("/*", "dispatcherServlet"); } catch (Exception e) { log.error("初始化Tomcat失败", e); throw new RuntimeException(e); } }
private StandardContext createContext(String path, String docBase, ClassLoader classLoader, Map<String, List<Injector<?>>> injectors) { StandardContext context = new StandardContext(); context.setDocBase(docBase); context.setPath(path); ContextConfig config = new ContextConfig(); context.addLifecycleListener(config); context.setParentClassLoader(classLoader); Fabric3Loader loader = new Fabric3Loader(classLoader); context.setLoader(loader); // turn off unpacking so Tomcat does not copy the extracted WAR to the /webapps directory and autodeploy it on a subsequent boot context.setUnpackWAR(false); Fabric3AnnotationProcessor annotationProcessor = new Fabric3AnnotationProcessor(injectors); context.setAnnotationProcessor(annotationProcessor); context.getServletContext().setAttribute(AnnotationProcessor.class.getName(), annotationProcessor); return (context); }
public void deployWebApps(AppInfo appInfo, ClassLoader classLoader) throws Exception { for (WebAppInfo webApp : appInfo.webApps) { if (getContextInfo(webApp) == null) { StandardContext standardContext = new StandardContext(); String contextXmlFile = webApp.codebase + "/META-INF/context.xml"; if (new File(contextXmlFile).exists()) { standardContext.setConfigFile(contextXmlFile); standardContext.setOverride(true); } ContextConfig contextConfig = new ContextConfig(); standardContext.addLifecycleListener(contextConfig); standardContext.setPath("/" + webApp.contextRoot); standardContext.setDocBase(webApp.codebase); standardContext.setParentClassLoader(classLoader); standardContext.setDelegate(true); String host = webApp.host; if (host == null) host = "localhost"; HostConfig deployer = deployers.get(host); if (deployer != null) { // host isn't set until we call deployer.manageApp, so pass it ContextInfo contextInfo = addContextInfo(host, standardContext); contextInfo.appInfo = appInfo; contextInfo.deployer = deployer; contextInfo.standardContext = standardContext; deployer.manageApp(standardContext); } } } }
standardContext.setParentClassLoader(containerLoader); standardContext.setParentClassLoader(classLoader); standardContext.setDelegate(true);
standardContext.setParentClassLoader(classLoader); standardContext.setDelegate(true); standardContext.setLoader(new TomEEWebappLoader(appInfo.path, classLoader));
this.tomcatContext.setDelegate(false); this.tomcatContext.addLifecycleListener(new Tomcat.FixContextListener()); this.tomcatContext.setParentClassLoader(classLoader); this.tomcatContext.setSessionTimeout(getSessionTimeout() / 60); this.tomcatContext.addLifecycleListener(new StoreMergedWebXmlListener());
context.setPath(path); context.setDocBase(""); context.setParentClassLoader(classLoader); context.setDelegate(true);
context.setPath(path); context.setDocBase(""); context.setParentClassLoader(classLoader); context.setDelegate(true);
context.setParentClassLoader(loader);