You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by is...@apache.org on 2018/09/22 20:06:06 UTC
svn commit: r1841692 -
/tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java
Author: isapir
Date: Sat Sep 22 20:06:06 2018
New Revision: 1841692
URL: http://svn.apache.org/viewvc?rev=1841692&view=rev
Log:
Added setter method setAddDefaultWebXmlToWebapp per bz 62755
Modified:
tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java
Modified: tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java?rev=1841692&r1=1841691&r2=1841692&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java Sat Sep 22 20:06:06 2018
@@ -158,6 +158,8 @@ public class Tomcat {
private final Map<String, List<String>> userRoles = new HashMap<>();
private final Map<String, Principal> userPrincipals = new HashMap<>();
+ private boolean addDefaultWebXmlToWebapp = true;
+
public Tomcat() {
ExceptionUtils.preload();
}
@@ -623,12 +625,15 @@ public class Tomcat {
Context ctx = createContext(host, contextPath);
ctx.setPath(contextPath);
ctx.setDocBase(docBase);
- ctx.addLifecycleListener(getDefaultWebXmlListener());
+
+ if (addDefaultWebXmlToWebapp)
+ ctx.addLifecycleListener(getDefaultWebXmlListener());
+
ctx.setConfigFile(getWebappConfigFile(docBase, contextPath));
ctx.addLifecycleListener(config);
- if (config instanceof ContextConfig) {
+ if (addDefaultWebXmlToWebapp && (config instanceof ContextConfig)) {
// prevent it from looking ( if it finds one - it'll have dup error )
((ContextConfig) config).setDefaultWebXml(noDefaultWebXmlPath());
}
@@ -803,6 +808,24 @@ public class Tomcat {
}
+ /**
+ * By default, when calling addWebapp() to create a Context, the settings from
+ * from the default web.xml are added to the context. Calling this method with
+ * a <code>false</code> value prior to calling addWebapp() allows to opt out of
+ * the default settings. In that event you will need to add the configurations
+ * yourself, either programmatically or by using web.xml deployment descriptors.
+ * @param addDefaultWebXmlToWebapp <code>false</code> will prevent the class from
+ * automatically adding the default settings when
+ * calling addWebapp().
+ * <code>true</code> will add the default settings
+ * and is the default behavior.
+ * @see #addWebapp(Host, String, String, LifecycleListener)
+ */
+ public void setAddDefaultWebXmlToWebapp(boolean addDefaultWebXmlToWebapp){
+ this.addDefaultWebXmlToWebapp = addDefaultWebXmlToWebapp;
+ }
+
+
/*
* Uses essentially the same logic as {@link ContainerBase#logName()}.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org