skitching 2004/03/27 22:09:13
Modified: digester/src/java/org/apache/commons/digester/plugins Tag:
DIGESTER_PLUGIN_REFACTORING_BRANCH
PluginDeclarationRule.java
Log:
User-provided xml attributes are now simly stored in a Properties object
on the Declaration rather than being assigned to explicit properties of
a Declaration. This allows an open-ended set of declaration properties
for the RuleFinder objects to inspect, and removes hard-wired English
language names for these attributes.
Revision Changes Path
No revision
No revision
1.10.2.1 +14 -41
jakarta-commons/digester/src/java/org/apache/commons/digester/plugins/PluginDeclarationRule.java
Index: PluginDeclarationRule.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/plugins/PluginDeclarationRule.java,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- PluginDeclarationRule.java 29 Feb 2004 02:22:15 -0000 1.10
+++ PluginDeclarationRule.java 28 Mar 2004 06:09:13 -0000 1.10.2.1
@@ -16,7 +16,7 @@
package org.apache.commons.digester.plugins;
-import java.io.File;
+import java.util.Properties;
import org.apache.commons.digester.Rule;
import org.apache.commons.digester.Digester;
@@ -69,17 +69,7 @@
String id = attributes.getValue("id");
String pluginClassName = attributes.getValue("class");
- String ruleMethodName = attributes.getValue("method");
- String ruleClassName = attributes.getValue("ruleclass");
- String ruleResource = attributes.getValue("resource");
- String ruleFile = attributes.getValue("file");
- String autoSetPropertiesStr = attributes.getValue("setprops");
-
- if (debug) {
- log.debug(
- "mapping id [" + id + "] -> [" + pluginClassName + "]");
- }
-
+
if (id == null) {
throw new PluginInvalidInputException(
"mandatory attribute id not present on tag" +
@@ -92,38 +82,20 @@
" <" + name + ">");
}
- Declaration newDecl = new Declaration(pluginClassName);
- newDecl.setId(id);
-
- if (ruleMethodName != null) {
- newDecl.setRuleMethod(ruleMethodName);
- }
-
- if (ruleClassName != null) {
- Class ruleClass;
- try {
- ruleClass = digester.getClassLoader().loadClass(ruleClassName);
- } catch(ClassNotFoundException cnfe) {
- throw new ClassNotFoundException(
- "Rule class [" + ruleClassName + "] not found.");
+ int nAttrs = attributes.getLength();
+ Properties props = new Properties();
+ for(int i=0; i<nAttrs; ++i) {
+ String key = attributes.getLocalName(i);
+ if ((key == null) || (key.length() == 0)) {
+ key = attributes.getQName(i);
}
- newDecl.setRuleClass(ruleClass);
+ String value = attributes.getValue(i);
+ props.setProperty(key, value);
}
- if (ruleResource != null) {
- newDecl.setRuleResource(ruleResource);
- }
-
- if (ruleFile != null) {
- newDecl.setRuleFile(new File(ruleFile));
- }
-
- if (autoSetPropertiesStr != null) {
- newDecl.setAutoSetProperties(
- Boolean.valueOf(autoSetPropertiesStr).booleanValue());
- }
-
- newDecl.init(digester);
+ Declaration newDecl = new Declaration(pluginClassName);
+ newDecl.setId(id);
+ newDecl.setProperties(props);
PluginRules rc = (PluginRules) digester.getRules();
PluginManager pm = rc.getPluginManager();
@@ -155,6 +127,7 @@
" which has already been mapped by some other id.");
}
+ newDecl.init(digester, pm);
pm.addDeclaration(newDecl);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]