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

Method deployDescriptor

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

Deploy specified context descriptor. Note: It is expected that the caller has successfully added the app to servicedSet before calling this method. @param cn The context name @param contextXml The descriptor

(ContextName cn, File contextXml)

Source from the content-addressed store, hash-verified

543 * @param contextXml The descriptor
544 */
545 protected void deployDescriptor(ContextName cn, File contextXml) {
546
547 // Check for descriptors with /../ /./ or similar sequences in the name
548 if (!cn.isPathValid()) {
549 log.error(sm.getString("hostConfig.illegalDescriptorName", contextXml.getName()));
550 invalidDescriptors.add(contextXml.getName());
551 return;
552 }
553
554 DeployedApplication deployedApp = new DeployedApplication(cn.getName(), true);
555
556 long startTime = 0;
557 // Assume this is a configuration descriptor and deploy it
558 if (log.isInfoEnabled()) {
559 startTime = System.currentTimeMillis();
560 log.info(sm.getString("hostConfig.deployDescriptor", contextXml.getAbsolutePath()));
561 }
562
563 Context context = null;
564 boolean isExternalWar = false;
565 boolean isExternal = false;
566 File expandedDocBase;
567
568 try {
569 synchronized (digesterLock) {
570 try (FileInputStream fis = new FileInputStream(contextXml)) {
571 context = (Context) digester.parse(fis);
572 } catch (Exception e) {
573 log.error(sm.getString("hostConfig.deployDescriptor.error", contextXml.getAbsolutePath()), e);
574 } finally {
575 digester.reset();
576 if (context == null) {
577 context = new FailedContext();
578 }
579 }
580 }
581
582 if (context.getPath() != null) {
583 log.warn(sm.getString("hostConfig.deployDescriptor.path", context.getPath(),
584 contextXml.getAbsolutePath()));
585 }
586
587 Class<?> clazz = Class.forName(host.getConfigClass());
588 LifecycleListener listener = (LifecycleListener) clazz.getConstructor().newInstance();
589 context.addLifecycleListener(listener);
590
591 context.setConfigFile(contextXml.toURI().toURL());
592 context.setName(cn.getName());
593 context.setPath(cn.getPath());
594 context.setWebappVersion(cn.getVersion());
595 // Add the associated docBase to the redeployed list if it's a WAR
596 if (context.getDocBase() != null) {
597 File docBase = new File(context.getDocBase());
598 if (!docBase.isAbsolute()) {
599 docBase = new File(host.getAppBaseFile(), context.getDocBase());
600 }
601 // If external docBase, register .xml as redeploy first
602 if (!docBase.getCanonicalFile().toPath().startsWith(host.getAppBaseFile().toPath())) {

Callers 2

deployAppsMethod · 0.95
runMethod · 0.80

Calls 15

getPathMethod · 0.95
setConfigFileMethod · 0.95
setPathMethod · 0.95
setWebappVersionMethod · 0.95
getDocBaseMethod · 0.95
setDocBaseMethod · 0.95
handleThrowableMethod · 0.95
addWatchedResourcesMethod · 0.95
isPathValidMethod · 0.80
forNameMethod · 0.80
endsWithMethod · 0.80

Tested by

no test coverage detected