MCPcopy Index your code
hub / github.com/apache/tomcat / deployDirectory

Method deployDirectory

java/org/apache/catalina/startup/HostConfig.java:1024–1132  ·  view source on GitHub ↗

Deploy exploded webapp. Note: It is expected that the caller has successfully added the app to servicedSet before calling this method. @param cn The context name @param dir The path to the root folder of the webapp

(ContextName cn, File dir)

Source from the content-addressed store, hash-verified

1022 * @param dir The path to the root folder of the webapp
1023 */
1024 protected void deployDirectory(ContextName cn, File dir) {
1025
1026 // Check for directories with /../ /./ or similar sequences in the name
1027 if (!cn.isPathValid()) {
1028 log.error(sm.getString("hostConfig.illegalDirName", dir.getName()));
1029 invalidDirectories.add(dir.getName());
1030 return;
1031 }
1032
1033 long startTime = 0;
1034 // Deploy the application in this directory
1035 if (log.isInfoEnabled()) {
1036 startTime = System.currentTimeMillis();
1037 log.info(sm.getString("hostConfig.deployDir", dir.getAbsolutePath()));
1038 }
1039
1040 Context context = null;
1041 File xml = new File(dir, Constants.ApplicationContextXml);
1042 File xmlCopy = new File(host.getConfigBaseFile(), cn.getBaseName() + ".xml");
1043
1044 DeployedApplication deployedApp;
1045 boolean copyThisXml = isCopyXML();
1046 boolean deployThisXML = this.deployXML;
1047
1048 try {
1049 if (deployThisXML && xml.exists()) {
1050 synchronized (digesterLock) {
1051 try {
1052 context = (Context) digester.parse(xml);
1053 } catch (Exception e) {
1054 log.error(sm.getString("hostConfig.deployDescriptor.error", xml), e);
1055 context = new FailedContext();
1056 } finally {
1057 digester.reset();
1058 if (context == null) {
1059 context = new FailedContext();
1060 }
1061 }
1062 }
1063
1064 if (!copyThisXml && context instanceof StandardContext) {
1065 // Host is using default value. Context may override it.
1066 copyThisXml = ((StandardContext) context).getCopyXML();
1067 }
1068
1069 if (copyThisXml) {
1070 Files.copy(xml.toPath(), xmlCopy.toPath());
1071 context.setConfigFile(xmlCopy.toURI().toURL());
1072 } else {
1073 context.setConfigFile(xml.toURI().toURL());
1074 }
1075 } else if (!deployThisXML && xml.exists()) {
1076 // Block deployment as META-INF/context.xml may contain security
1077 // configuration necessary for a secure deployment.
1078 log.error(sm.getString("hostConfig.deployDescriptor.blocked", cn.getPath(), xml, xmlCopy));
1079 context = new FailedContext();
1080 } else {
1081 context = (Context) Class.forName(contextClass).getConstructor().newInstance();

Callers 2

deployAppsMethod · 0.95
runMethod · 0.80

Calls 15

isCopyXMLMethod · 0.95
setConfigFileMethod · 0.95
setPathMethod · 0.95
setWebappVersionMethod · 0.95
setDocBaseMethod · 0.95
handleThrowableMethod · 0.95
addWatchedResourcesMethod · 0.95
isPathValidMethod · 0.80
getCopyXMLMethod · 0.80
forNameMethod · 0.80
errorMethod · 0.65

Tested by

no test coverage detected