1. This does not belong to Coyote (as you wrote in changelog.xml). 2. Lack of documentation. Listeners are documented in config/listeners.xml. E.g.:
http://tomcat.us.apache.org/tomcat-8.5-doc/config/listeners.html 3. It does not use all property sources used by Digester. (It uses Digester.propertySource, not Digester.source). Generally, this means that it does not perform substitutions of ${system properties} (handled by Digester$SystemPropertySource), but only of those handled by custom property source. Generally, substitution of system properties is a wanted feature, but there are some properties that do not need such replacement, e.g. "common.loader" property. 4. If this feature is configured as a <Listener>, it means that it will be performed only on Tomcat startup, but not on shutdown (where only the root element of server.xml is parsed). Based on #3, #4 I thought tha 5. Update 2017-07-26 15:15 GMT+03:00 <r...@apache.org>: > Author: remm > Date: Wed Jul 26 12:15:45 2017 > New Revision: 1803038 > > URL: http://svn.apache.org/viewvc?rev=1803038&view=rev > Log: > 61345: Add a server listener that can be used to do system property > replacement from the property source configured in the digester. > > Modified: > tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java > tomcat/trunk/java/org/apache/tomcat/util/digester/LocalStrings.properties > tomcat/trunk/webapps/docs/changelog.xml > tomcat/trunk/webapps/docs/config/systemprops.xml > > Modified: tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java > URL: > http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java?rev=1803038&r1=1803037&r2=1803038&view=diff > ============================================================================== > --- tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java (original) > +++ tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java Wed Jul > 26 12:15:45 2017 > @@ -29,12 +29,17 @@ import java.util.EmptyStackException; > import java.util.HashMap; > import java.util.List; > import java.util.Map; > +import java.util.Properties; > import java.util.PropertyPermission; > +import java.util.Set; > > import javax.xml.parsers.ParserConfigurationException; > import javax.xml.parsers.SAXParser; > import javax.xml.parsers.SAXParserFactory; > > +import org.apache.catalina.Lifecycle; > +import org.apache.catalina.LifecycleEvent; > +import org.apache.catalina.LifecycleListener; > import org.apache.juli.logging.Log; > import org.apache.juli.logging.LogFactory; > import org.apache.tomcat.util.ExceptionUtils; > @@ -307,6 +312,35 @@ public class Digester extends DefaultHan > } > } > > + > + public static class SystemPropertyReplacementListener > + implements LifecycleListener { > + protected Log log = LogFactory.getLog(Digester.class); > + protected StringManager sm = > StringManager.getManager(Digester.class); > + @Override > + public void lifecycleEvent(LifecycleEvent event) { > + if (propertySource != null && > Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) { > + IntrospectionUtils.PropertySource[] propertySources = > + new IntrospectionUtils.PropertySource[] { > propertySource }; > + Properties properties = System.getProperties(); > + Set<String> names = properties.stringPropertyNames(); > + for (String name : names) { > + String value = System.getProperty(name); > + if (value != null) { > + try { > + String newValue = > IntrospectionUtils.replaceProperties(value, null, propertySources); > + if (value != newValue) { > + System.setProperty(name, newValue); > + } > + } catch (Exception e) { > + > log.warn(sm.getString("digester.failedToUpdateSystemProperty", name, value), > e); > + } > + } > + } > + } > + } > + } > + > > // ------------------------------------------------------------- > Properties > > > Modified: > tomcat/trunk/java/org/apache/tomcat/util/digester/LocalStrings.properties > URL: > http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/digester/LocalStrings.properties?rev=1803038&r1=1803037&r2=1803038&view=diff > ============================================================================== > --- tomcat/trunk/java/org/apache/tomcat/util/digester/LocalStrings.properties > (original) > +++ tomcat/trunk/java/org/apache/tomcat/util/digester/LocalStrings.properties > Wed Jul 26 12:15:45 2017 > @@ -15,3 +15,4 @@ > > disgester.encodingInvalid=The encoding [{0}] is not recognised by the JRE > and will be ignored > digester.failedToUpdateAttributes=Attribute [{0}] failed to update and > remains [{1}] > +digester.failedToUpdateSystemProperty=System property [{0}] failed to update > and remains [{1}] > > Modified: tomcat/trunk/webapps/docs/changelog.xml > URL: > http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1803038&r1=1803037&r2=1803038&view=diff > ============================================================================== > --- tomcat/trunk/webapps/docs/changelog.xml (original) > +++ tomcat/trunk/webapps/docs/changelog.xml Wed Jul 26 12:15:45 2017 > @@ -52,6 +52,15 @@ > decoded. Identified by FindBugs. (markt)</fix> > </changelog> > </subsection> > + <subsection name="Coyote"> > + <changelog> > + <update> > + <bug>61345</bug>: Add a server listener that can be used to do system > + property replacement from the property source configured in the > + digester. (remm) > + </update> > + </changelog> > + </subsection> > </section> > <section name="Tomcat 9.0.0.M25 (markt)" rtext="release in progress"> > <subsection name="Catalina"> > > Modified: tomcat/trunk/webapps/docs/config/systemprops.xml > URL: > http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/systemprops.xml?rev=1803038&r1=1803037&r2=1803038&view=diff > ============================================================================== > --- tomcat/trunk/webapps/docs/config/systemprops.xml (original) > +++ tomcat/trunk/webapps/docs/config/systemprops.xml Wed Jul 26 12:15:45 2017 > @@ -45,6 +45,10 @@ > Required to have a public constructor with no arguments.</p> > <p>Use this to add a property source, that will be invoked when > <code>${parameter}</code> > denoted parameters are found in the XML files that Tomcat > parses.</p> > + <p>Property replacement from the specified property source on the JVM > + system properties can also be done by adding the > + > <code>org.apache.tomcat.util.digester.Digester$SystemPropertyReplacementListener</code> > + listener as a Server listener in the container.</p> > </property> > </properties> > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org