Author: fhanik
Date: Sun Apr 19 22:00:51 2009
New Revision: 766526
URL: http://svn.apache.org/viewvc?rev=766526&view=rev
Log:
Allow pluggable property replacement object
Modified:
tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java
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=766526&r1=766525&r2=766526&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java Sun Apr 19
22:00:51 2009
@@ -76,10 +76,8 @@
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 @@
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<cls.length && (!initialized); i++) {
+ try {
+ Class<?> 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
Modified: tomcat/trunk/webapps/docs/config/systemprops.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/systemprops.xml?rev=766526&r1=766525&r2=766526&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/systemprops.xml (original)
+++ tomcat/trunk/webapps/docs/config/systemprops.xml Sun Apr 19 22:00:51 2009
@@ -33,7 +33,18 @@
the default Tomcat behaviour.</p>
</section>
-
+<section name="Property replacements">
+ <properties>
+ <property name="org.apache.tomcat.util.digester. PROPERTY_SOURCE">
+ <p>Set this to a fully qualified name of a class that implements
+ <code>org.apache.tomcat.util.IntrospectionUtils.PropertySource</code>.
+ Required to have a public constructor with no arguments.</p>
+ <p>Use this to add a property source, that will be invoked when
<code>s{parameter}</code>
+ denoted parameters are found in the XML files that tomcat parses.</p>
+ </property>
+ </properties>
+
+</section>
<section name="Clustering">
<properties>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]