From: fhanik
Date: Sun, 19 Apr 2009 22:00:51 +0000 (+0000)
Subject: Allow pluggable property replacement object
X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0a714cc89473da78913f6418c9d4e124c982e25e;p=tomcat7.0
Allow pluggable property replacement object
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@766526 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/java/org/apache/tomcat/util/digester/Digester.java b/java/org/apache/tomcat/util/digester/Digester.java
index 735b307e1..5a55ff401 100644
--- a/java/org/apache/tomcat/util/digester/Digester.java
+++ b/java/org/apache/tomcat/util/digester/Digester.java
@@ -76,10 +76,8 @@ import org.xml.sax.helpers.DefaultHandler;
public class Digester extends DefaultHandler {
-
- // ---------------------------------------------------------- Static Fields
-
-
+
+ // ---------------------------------------------------------- Static Fields
private static class SystemPropertySource
implements IntrospectionUtils.PropertySource {
public String getProperty( String key ) {
@@ -89,6 +87,28 @@ public class Digester extends DefaultHandler {
protected static IntrospectionUtils.PropertySource source[] =
new IntrospectionUtils.PropertySource[] { new SystemPropertySource() };
+
+ static {
+ String className = System.getProperty("org.apache.tomcat.util.digester.PROPERTY_SOURCE");
+ if (className!=null) {
+ IntrospectionUtils.PropertySource[] sources = new IntrospectionUtils.PropertySource[2];
+ sources[1] = source[0];
+ ClassLoader[] cls = new ClassLoader[] {Digester.class.getClassLoader(),Thread.currentThread().getContextClassLoader()};
+ boolean initialized = false;
+ for (int i=0; i clazz = Class.forName(className,true,cls[i]);
+ IntrospectionUtils.PropertySource src = (IntrospectionUtils.PropertySource)clazz.newInstance();
+ sources[0] = src;
+ initialized = true;
+ } catch (Throwable t) {
+ LogFactory.getLog("org.apache.commons.digester.Digester").
+ error("Unable to load property source["+className+"].",t);
+ }
+ }
+ if (initialized) source = sources;
+ }
+ }
// --------------------------------------------------------- Constructors
diff --git a/webapps/docs/config/systemprops.xml b/webapps/docs/config/systemprops.xml
index dcbf89a93..3a25556e8 100644
--- a/webapps/docs/config/systemprops.xml
+++ b/webapps/docs/config/systemprops.xml
@@ -33,7 +33,18 @@
the default Tomcat behaviour.
-
+
+
+
+ Set this to a fully qualified name of a class that implements
+ org.apache.tomcat.util.IntrospectionUtils.PropertySource.
+ Required to have a public constructor with no arguments.
+ Use this to add a property source, that will be invoked when s{parameter}
+ denoted parameters are found in the XML files that tomcat parses.
+
+
+
+