Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 326DB200CD2 for ; Thu, 27 Jul 2017 10:25:57 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 30D9416A7A3; Thu, 27 Jul 2017 08:25:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5059C16A7A2 for ; Thu, 27 Jul 2017 10:25:56 +0200 (CEST) Received: (qmail 6923 invoked by uid 500); 27 Jul 2017 08:25:50 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 6913 invoked by uid 99); 27 Jul 2017 08:25:50 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Jul 2017 08:25:50 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id E8D673A05C0 for ; Thu, 27 Jul 2017 08:25:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1803135 - in /tomcat/trunk: java/org/apache/catalina/util/SystemPropertyReplacerListener.java java/org/apache/tomcat/util/digester/Digester.java webapps/docs/config/listeners.xml webapps/docs/config/systemprops.xml Date: Thu, 27 Jul 2017 08:25:46 -0000 To: dev@tomcat.apache.org From: remm@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170727082548.E8D673A05C0@svn01-us-west.apache.org> archived-at: Thu, 27 Jul 2017 08:25:57 -0000 Author: remm Date: Thu Jul 27 08:25:46 2017 New Revision: 1803135 URL: http://svn.apache.org/viewvc?rev=1803135&view=rev Log: Avoid circular dependency. Added: tomcat/trunk/java/org/apache/catalina/util/SystemPropertyReplacerListener.java (with props) Modified: tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java tomcat/trunk/webapps/docs/config/listeners.xml tomcat/trunk/webapps/docs/config/systemprops.xml Added: tomcat/trunk/java/org/apache/catalina/util/SystemPropertyReplacerListener.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/SystemPropertyReplacerListener.java?rev=1803135&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/catalina/util/SystemPropertyReplacerListener.java (added) +++ tomcat/trunk/java/org/apache/catalina/util/SystemPropertyReplacerListener.java Thu Jul 27 08:25:46 2017 @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.catalina.util; + + +import org.apache.catalina.Lifecycle; +import org.apache.catalina.LifecycleEvent; +import org.apache.catalina.LifecycleListener; +import org.apache.tomcat.util.digester.Digester; + + +/** + * Helper class used to do property replacement on system properties. + */ +public class SystemPropertyReplacerListener + implements LifecycleListener { + + + // ---------------------------------------------- LifecycleListener Methods + + + @Override + public void lifecycleEvent(LifecycleEvent event) { + if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) { + Digester.replace(); + } + } + + +} Propchange: tomcat/trunk/java/org/apache/catalina/util/SystemPropertyReplacerListener.java ------------------------------------------------------------------------------ svn:eol-style = native 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=1803135&r1=1803134&r2=1803135&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java Thu Jul 27 08:25:46 2017 @@ -37,9 +37,6 @@ import javax.xml.parsers.ParserConfigura 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; @@ -298,7 +295,7 @@ public class Digester extends DefaultHan * The Log to which most logging calls will be made. */ protected Log log = LogFactory.getLog(Digester.class); - protected StringManager sm = StringManager.getManager(Digester.class); + protected static StringManager sm = StringManager.getManager(Digester.class); /** * The Log to which all SAX event related logging calls will be made. @@ -313,28 +310,23 @@ 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 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); + public static void replace() { + Log log = LogFactory.getLog(Digester.class); + if (propertySource != null) { + IntrospectionUtils.PropertySource[] propertySources = + new IntrospectionUtils.PropertySource[] { propertySource }; + Properties properties = System.getProperties(); + Set 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); } } } Modified: tomcat/trunk/webapps/docs/config/listeners.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/listeners.xml?rev=1803135&r1=1803134&r2=1803135&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/config/listeners.xml (original) +++ tomcat/trunk/webapps/docs/config/listeners.xml Thu Jul 27 08:25:46 2017 @@ -571,6 +571,15 @@ + + +

This listener performs system property replacement using the property + source configured on the digester. When ${parameter} + denoted parameters are found in the values of system properties, + the property source will be invoked to attempt to replace it.

+ +
+ Modified: tomcat/trunk/webapps/docs/config/systemprops.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/systemprops.xml?rev=1803135&r1=1803134&r2=1803135&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/config/systemprops.xml (original) +++ tomcat/trunk/webapps/docs/config/systemprops.xml Thu Jul 27 08:25:46 2017 @@ -47,7 +47,7 @@ denoted parameters are found in the XML files that Tomcat parses.

Property replacement from the specified property source on the JVM system properties can also be done by adding the - org.apache.tomcat.util.digester.Digester$SystemPropertyReplacementListener + org.apache.catalina.util.SystemPropertyReplacerListener listener as a Server listener in the container.

--------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org