// This magic line makes Tomcat look for WAR files in catalinaHome/webapps // and automatically deploy them tomcat.getHost().addLifecycleListener(new HostConfig());
/** * Check status of all webapps. */ protected void check() { if (host.getAutoDeploy()) { // Check for resources modification to trigger redeployment DeployedApplication[] apps = deployed.values().toArray(new DeployedApplication[0]); for (int i = 0; i < apps.length; i++) { if (!isServiced(apps[i].name)) checkResources(apps[i], false); } // Check for old versions of applications that can now be undeployed if (host.getUndeployOldVersions()) { checkUndeploy(); } // Hotdeploy applications deployApps(); } }
/** * Deploy applications for any directories or WAR files that are found * in our "application root" directory. */ protected void deployApps(String name) { File appBase = appBase(); File configBase = configBase(); String baseName = getConfigFile(name); String docBase = getConfigFile(name); // Deploy XML descriptors from configBase File xml = new File(configBase, baseName + ".xml"); if (xml.exists()) deployDescriptor(name, xml, baseName + ".xml"); // Deploy WARs, and loop if additional descriptors are found File war = new File(appBase, docBase + ".war"); if (war.exists()) deployWAR(name, war, docBase + ".war"); // Deploy expanded folders File dir = new File(appBase, docBase); if (dir.exists()) deployDirectory(name, dir, docBase); }
/** * Check status of a specific webapp, for use with stuff like management webapps. */ public void check(String name) { DeployedApplication app = deployed.get(name); if (app != null) { checkResources(app); } else { deployApps(name); } }
/** * Deploy applications for any directories or WAR files that are found * in our "application root" directory. */ protected void deployApps() { File appBase = appBase(); File configBase = configBase(); String[] filteredAppPaths = filterAppPaths(appBase.list()); // Deploy XML descriptors from configBase deployDescriptors(configBase, configBase.list()); // Deploy WARs deployWARs(appBase, filteredAppPaths); // Deploy expanded folders deployDirectories(appBase, filteredAppPaths); }
/** * Deploy webapps. */ protected void check() { if (host.getAutoDeploy()) { // Deploy apps if the Host allows auto deploying deployApps(); // Check for web.xml modification checkContextLastModified(); } }
host = (Host) event.getLifecycle(); if (host instanceof StandardHost) { setCopyXML(((StandardHost) host).isCopyXML()); setDeployXML(((StandardHost) host).isDeployXML()); setUnpackWARs(((StandardHost) host).isUnpackWARs()); setContextClass(((StandardHost) host).getContextClass()); check(); } else if (event.getType().equals(Lifecycle.BEFORE_START_EVENT)) { beforeStart(); } else if (event.getType().equals(Lifecycle.START_EVENT)) { start(); } else if (event.getType().equals(Lifecycle.STOP_EVENT)) { stop();
/** * Process the START event for an associated Host. * * @param event The lifecycle event that has occurred */ public void lifecycleEvent(LifecycleEvent event) { if (event.getType().equals(Lifecycle.PERIODIC_EVENT)) check(); // Identify the host we are associated with try { host = (Host) event.getLifecycle(); if (host instanceof StandardHost) { setDeployXML(((StandardHost) host).isDeployXML()); setUnpackWARs(((StandardHost) host).isUnpackWARs()); setXmlNamespaceAware(((StandardHost) host).getXmlNamespaceAware()); setXmlValidation(((StandardHost) host).getXmlValidation()); } } catch (ClassCastException e) { log.error(sm.getString("hostConfig.cce", event.getLifecycle()), e); return; } // Process the event that has occurred if (event.getType().equals(Lifecycle.START_EVENT)) start(); else if (event.getType().equals(Lifecycle.STOP_EVENT)) stop(); }
/** * Deploy applications for any directories or WAR files that are found * in our "application root" directory. */ protected void deployApps(String name) { File appBase = host.getAppBaseFile(); File configBase = host.getConfigBaseFile(); ContextName cn = new ContextName(name); String baseName = cn.getBaseName(); if (deploymentExists(baseName)) { return; } // Deploy XML descriptor from configBase File xml = new File(configBase, baseName + ".xml"); if (xml.exists()) { deployDescriptor(cn, xml); return; } // Deploy WAR File war = new File(appBase, baseName + ".war"); if (war.exists()) { deployWAR(cn, war); return; } // Deploy expanded folder File dir = new File(appBase, baseName); if (dir.exists()) deployDirectory(cn, dir); }
/** * Deploy applications for any directories or WAR files that are found * in our "application root" directory. */ protected void deployApps() { File appBase = host.getAppBaseFile(); File configBase = host.getConfigBaseFile(); String[] filteredAppPaths = filterAppPaths(appBase.list()); // Deploy XML descriptors from configBase deployDescriptors(configBase, configBase.list()); // Deploy WARs deployWARs(appBase, filteredAppPaths); // Deploy expanded folders deployDirectories(appBase, filteredAppPaths); }
/** * Check status of all webapps. */ protected void check() { if (host.getAutoDeploy()) { // Check for resources modification to trigger redeployment DeployedApplication[] apps = (DeployedApplication[]) deployed.values().toArray(new DeployedApplication[0]); for (int i = 0; i < apps.length; i++) { if (!isServiced(apps[i].name)) checkResources(apps[i]); } // Hotdeploy applications deployApps(); } }
/** * Process the START event for an associated Host. * * @param event The lifecycle event that has occurred */ public void lifecycleEvent(LifecycleEvent event) { if (event.getType().equals(Lifecycle.PERIODIC_EVENT)) check(); // Process the event that has occurred if (event.getType().equals(Lifecycle.START_EVENT)) start(); else if (event.getType().equals(Lifecycle.STOP_EVENT)) stop(); }
if (!validateContextPath(appBase, cn.getBaseName())) { log.error(sm.getString( "hostConfig.illegalWarName", files[i])); if (isServiced(cn.getName())) continue; deployWAR(cn, dir, file);
/** * Deploy XML context descriptors. */ protected void deployDescriptors(File configBase, String[] files) { if (files == null) return; for (int i = 0; i < files.length; i++) { if (files[i].equalsIgnoreCase("META-INF")) continue; if (files[i].equalsIgnoreCase("WEB-INF")) continue; File contextXml = new File(configBase, files[i]); if (files[i].toLowerCase().endsWith(".xml")) { // Calculate the context path and make sure it is unique String nameTmp = files[i].substring(0, files[i].length() - 4); String contextPath = "/" + nameTmp.replace('#', '/'); if (nameTmp.equals("ROOT")) { contextPath = ""; } if (isServiced(contextPath)) continue; String file = files[i]; deployDescriptor(contextPath, contextXml, file); } } }
/** * Process a "start" event for this Host. */ public void start() { if (log.isLoggable(Level.FINE)) log.log(Level.FINE, LogFacade.PROCESSING_START); if (host.getDeployOnStartup()) { deployApps(); } else { // Deploy descriptors anyway (it should be equivalent to being // part of server.xml) File configBase = configBase(); if (configBase.exists() && configBase.isDirectory()) { String configFiles[] = configBase.list(); deployDescriptors(configBase, configFiles); } } }
if (!validateContextPath(appBase, contextPath)) { log.log(Level.SEVERE, LogFacade.INVALID_WAR_NAME_EXCEPTION, files[i]); invalidWars.add(files[i]); jar.close(); jar = null; deployDescriptors(configBase(), configBase.list()); return; if (isUnpackWARs()) {
@Override public void run() { config.deployWAR(cn, war); } }
@Override public void run() { config.deployDescriptor(cn, descriptor); } }
contextPath = ""; if (isServiced(contextPath)) continue; deployWAR(contextPath, dir, file);
@Override protected void deployApps() { super.deployApps(); }