commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1301217 - /commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java
Date Thu, 15 Mar 2012 21:41:36 GMT
Author: simonetripodi
Date: Thu Mar 15 21:41:36 2012
New Revision: 1301217

URL: http://svn.apache.org/viewvc?rev=1301217&view=rev
Log:
less efficient, but that should fix [DIGESTER-163]

Modified:
    commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java

Modified: commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java?rev=1301217&r1=1301216&r2=1301217&view=diff
==============================================================================
--- commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java
(original)
+++ commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/xmlrules/FromXmlRulesModule.java
Thu Mar 15 21:41:36 2012
@@ -29,9 +29,7 @@ import java.io.StringReader;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
-import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 
 import org.apache.commons.digester3.Digester;
@@ -54,8 +52,6 @@ public abstract class FromXmlRulesModule
 
     private final URL xmlRulesDtdUrl = FromXmlRulesModule.class.getResource( DIGESTER_DTD_PATH
);
 
-    private final List<InputSource> inputSource = new ArrayList<InputSource>();
-
     private final Set<String> systemIds = new HashSet<String>();
 
     private String rootPath;
@@ -66,7 +62,7 @@ public abstract class FromXmlRulesModule
     @Override
     protected void configure()
     {
-        if ( !inputSource.isEmpty() )
+        if ( !systemIds.isEmpty() )
         {
             throw new IllegalStateException( "Re-entry is not allowed." );
         }
@@ -74,31 +70,10 @@ public abstract class FromXmlRulesModule
         try
         {
             loadRules();
-
-            XmlRulesModule xmlRulesModule = new XmlRulesModule( new NameSpaceURIRulesBinder(
rulesBinder() ),
-                                                                getSystemIds(), rootPath
);
-            Digester digester = newLoader( xmlRulesModule )
-                    .register( DIGESTER_PUBLIC_ID, xmlRulesDtdUrl.toString() )
-                    .setXIncludeAware( true )
-                    .setValidating( true )
-                    .newDigester();
-
-            for ( InputSource source : inputSource )
-            {
-                try
-                {
-                    digester.parse( source );
-                }
-                catch ( Exception e )
-                {
-                    addError( "Impossible to load XML defined in the InputSource '%s': %s",
source.getSystemId(),
-                              e.getMessage() );
-                }
-            }
         }
         finally
         {
-            inputSource.clear();
+            systemIds.clear();
         }
     }
 
@@ -119,13 +94,29 @@ public abstract class FromXmlRulesModule
             throw new IllegalArgumentException( "Argument 'inputSource' must be not null"
);
         }
 
-        this.inputSource.add( inputSource );
-
         String systemId = inputSource.getSystemId();
         if ( systemId != null && !systemIds.add( systemId ) )
         {
             addError( "XML rules file '%s' already bound", systemId );
         }
+
+        XmlRulesModule xmlRulesModule = new XmlRulesModule( new NameSpaceURIRulesBinder(
rulesBinder() ),
+                                                            getSystemIds(), rootPath );
+        Digester digester = newLoader( xmlRulesModule )
+                .register( DIGESTER_PUBLIC_ID, xmlRulesDtdUrl.toString() )
+                .setXIncludeAware( true )
+                .setValidating( true )
+                .newDigester();
+
+        try
+        {
+            digester.parse( inputSource );
+        }
+        catch ( Exception e )
+        {
+            addError( "Impossible to load XML defined in the InputSource '%s': %s", inputSource.getSystemId(),
+                      e.getMessage() );
+        }
     }
 
     /**



Mime
View raw message