commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1127243 - /commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/xmlrules/metaparser/IncludeRule.java
Date Tue, 24 May 2011 19:51:21 GMT
Author: simonetripodi
Date: Tue May 24 19:51:21 2011
New Revision: 1127243

URL: http://svn.apache.org/viewvc?rev=1127243&view=rev
Log:
IncludeRule now uses new FromXmlRulesModule APIs

Modified:
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/xmlrules/metaparser/IncludeRule.java

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/xmlrules/metaparser/IncludeRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/xmlrules/metaparser/IncludeRule.java?rev=1127243&r1=1127242&r2=1127243&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/xmlrules/metaparser/IncludeRule.java
(original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/xmlrules/metaparser/IncludeRule.java
Tue May 24 19:51:21 2011
@@ -56,7 +56,7 @@ final class IncludeRule
         throws Exception
     {
         // The path attribute gives the URI to another digester rules xml file
-        String fileName = attributes.getValue( "url" );
+        final String fileName = attributes.getValue( "url" );
         if ( fileName != null && fileName.length() > 0 )
         {
             FromXmlRulesModule fromXmlRulesModule = null;
@@ -68,40 +68,58 @@ final class IncludeRule
                 {
                     path = path.substring( 1 );
                 }
-                URL classPathResource = this.targetRulesBinder.getContextClassLoader().getResource(
path );
+                final URL classPathResource = this.targetRulesBinder.getContextClassLoader().getResource(
path );
                 if ( classPathResource == null )
                 {
-                    this.targetRulesBinder.addError( "Resource '%s' not found, please make
sure it is in the classpath",
+                    targetRulesBinder.addError( "Resource '%s' not found, please make sure
it is in the classpath",
                                                      path );
                 }
                 else
                 {
-                    fromXmlRulesModule = new FromXmlRulesModule( classPathResource );
+                    fromXmlRulesModule = new FromXmlRulesModule()
+                    {
+
+                        @Override
+                        protected void loadRules()
+                        {
+                            loadXMLRules( classPathResource );
+                        }
+
+                    };
                 }
             }
             else
             {
                 try
                 {
-                    fromXmlRulesModule = new FromXmlRulesModule( new URL( fileName ) );
+                    fromXmlRulesModule = new FromXmlRulesModule()
+                    {
+
+                        @Override
+                        protected void loadRules()
+                        {
+                            loadXMLRules( fileName );
+                        }
+
+                    };
                 }
                 catch ( Exception e )
                 {
-                    this.targetRulesBinder.addError( "An error occurred while inculing file
from '%s': %s", fileName,
-                                                     e.getMessage() );
+                    targetRulesBinder.addError( "An error occurred while inculing file from
'%s': %s", fileName,
+                                                e.getMessage() );
                 }
             }
 
             if ( fromXmlRulesModule != null )
             {
-                if ( !this.memoryRulesBinder.getIncludedFiles().add( fromXmlRulesModule.getSystemId()
) )
+                if ( !memoryRulesBinder.getIncludedFiles().add( fromXmlRulesModule.getSystemId()
) )
                 {
-                    this.targetRulesBinder.addError( "Circular file inclusion detected for
XML rules: %s",
-                                                     fromXmlRulesModule.getSystemId() );
+                    targetRulesBinder.addError( "Circular file inclusion detected for XML
rules: %s",
+                                                fromXmlRulesModule.getSystemId() );
                 }
                 else
                 {
-                    this.install( fromXmlRulesModule );
+                    install( fromXmlRulesModule );
                 }
             }
         }
@@ -116,19 +134,19 @@ final class IncludeRule
                 Class<?> cls = Class.forName( className );
                 if ( !RulesModule.class.isAssignableFrom( cls ) )
                 {
-                    this.targetRulesBinder.addError( "Class '%s' if not a '%s' implementation",
className,
-                                                     RulesModule.class.getName() );
+                    targetRulesBinder.addError( "Class '%s' if not a '%s' implementation",
className,
+                                                RulesModule.class.getName() );
                     return;
                 }
 
                 RulesModule rulesSource = (RulesModule) cls.newInstance();
 
-                this.install( rulesSource );
+                install( rulesSource );
             }
             catch ( Exception e )
             {
-                this.targetRulesBinder.addError( "Impossible to include programmatic rules
from class '%s': %s",
-                                                 className, e.getMessage() );
+                targetRulesBinder.addError( "Impossible to include programmatic rules from
class '%s': %s", className,
+                                            e.getMessage() );
             }
         }
     }
@@ -136,8 +154,8 @@ final class IncludeRule
     private void install( RulesModule rulesModule )
     {
         // that's an hack, shall not be taken in consideration!!! :)
-        rulesModule.configure( new PrefixedRulesBinder( this.targetRulesBinder,
-                                                        this.memoryRulesBinder.getPatternStack().toString()
) );
+        rulesModule.configure( new PrefixedRulesBinder( targetRulesBinder,
+                                                        memoryRulesBinder.getPatternStack().toString()
) );
     }
 
 }



Mime
View raw message