commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1072174 - /commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/DigesterLoader.java
Date Fri, 18 Feb 2011 22:24:50 GMT
Author: simonetripodi
Date: Fri Feb 18 22:24:49 2011
New Revision: 1072174

URL: http://svn.apache.org/viewvc?rev=1072174&view=rev
Log:
added methods to decorate existing Rules and Digester instance with already bound rules

Modified:
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/DigesterLoader.java

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/DigesterLoader.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/DigesterLoader.java?rev=1072174&r1=1072173&r2=1072174&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/DigesterLoader.java
(original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/DigesterLoader.java
Fri Feb 18 22:24:49 2011
@@ -352,14 +352,51 @@ public final class DigesterLoader {
 
         if (!classLoader.equals(this.rulesBinder.getContextClassLoader())) {
             this.rulesBinder.initialize(classLoader);
-            for (RulesModule rulesModule : rulesModules) {
+            for (RulesModule rulesModule : this.rulesModules) {
+                rulesModule.configure(this.rulesBinder);
+            }
+        }
+
+        Digester digester = new DigesterImpl(reader, rules, classLoader, this.substitutor,
this.entityValidator);
+
+        this.rulesBinder.populateRules(rules);
+
+        return digester;
+    }
+
+    /**
+     * Decorates given {@link Rules} with bound rules.
+     *
+     * @param rules The {@link Rules} instance has to be decorated
+     */
+    public void decorate(Rules rules) {
+        if (rules == null) {
+            throw new DigesterLoadingException("Parameter 'rules' must be not null");
+        }
+
+        ClassLoader classLoader = this.classLoader != null ? this.classLoader :
+            (this.useContextClassLoader ? Thread.currentThread().getContextClassLoader()
: this.getClass().getClassLoader());
+
+        if (!classLoader.equals(this.rulesBinder.getContextClassLoader())) {
+            this.rulesBinder.initialize(classLoader);
+            for (RulesModule rulesModule : this.rulesModules) {
                 rulesModule.configure(this.rulesBinder);
             }
         }
 
         this.rulesBinder.populateRules(rules);
+    }
 
-        return new DigesterImpl(reader, rules, classLoader, this.substitutor, this.entityValidator);
+    /**
+     * Decorates given {@link Digester} with bound rules.
+     *
+     * @param digester The {@link Rules} instance has to be decorated
+     */
+    public void decorate(Digester digester) {
+        if (digester == null) {
+            throw new DigesterLoadingException("Parameter 'digester' must be not null");
+        }
+        this.decorate(digester.getRules());
     }
 
 }



Mime
View raw message