skitching 2004/06/10 20:48:50
Modified: digester/src/java/org/apache/commons/digester/plugins
PluginRules.java
Log:
Add a rulesFactory member. The rulesFactory (if not null) is used to
create the underlying Rules implementation rather than hardwiring
RulesBase as the implementation.
Revision Changes Path
1.18 +34 -6
jakarta-commons/digester/src/java/org/apache/commons/digester/plugins/PluginRules.java
Index: PluginRules.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/plugins/PluginRules.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- PluginRules.java 10 May 2004 06:44:13 -0000 1.17
+++ PluginRules.java 11 Jun 2004 03:48:50 -0000 1.18
@@ -64,6 +64,11 @@
protected Digester digester = null;
/**
+ * The (optional) object which generates new rules instances.
+ */
+ private RulesFactory rulesFactory;
+
+ /**
* The rules implementation that we are "enhancing" with plugins
* functionality, as per the Decorator pattern.
*/
@@ -126,17 +131,24 @@
* to begin.
* @param parent must be non-null.
*/
- PluginRules(String mountPoint, PluginRules parent) {
+ PluginRules(String mountPoint, PluginRules parent, Class pluginClass)
+ throws PluginException {
// no need to set digester or decoratedRules.digester,
// because when Digester.setRules is called, the setDigester
// method on this object will be called.
- decoratedRules = new RulesBase();
- pluginContext = parent.pluginContext;
- pluginManager = new PluginManager(parent.pluginManager);
-
this.mountPoint = mountPoint;
this.parent = parent;
+ this.rulesFactory = parent.rulesFactory;
+
+ if (rulesFactory == null) {
+ decoratedRules = new RulesBase();
+ } else {
+ decoratedRules = rulesFactory.newRules(digester, pluginClass);
+ }
+
+ pluginContext = parent.pluginContext;
+ pluginManager = new PluginManager(parent.pluginManager);
}
// ------------------------------------------------------------- Properties
@@ -208,6 +220,21 @@
pluginContext.setRuleFinders(ruleFinders);
}
+ /**
+ * Return the rules factory object (or null if one has not been specified).
+ */
+ public RulesFactory getRulesFactory() {
+ return rulesFactory;
+ }
+
+ /**
+ * Set the object which is used to generate the new Rules instances created
+ * to hold and process the rules associated with each plugged-in class.
+ */
+ public void setRulesFactory(RulesFactory factory) {
+ rulesFactory = factory;
+ }
+
// --------------------------------------------------------- Public Methods
/**
@@ -360,6 +387,7 @@
// this same path. See PluginCreateRule's begin, body and end
// methods for the reason.
} else {
+ log.debug("delegating to decorated rules.");
matches = decoratedRules.match(namespaceURI, path);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]