You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sk...@apache.org on 2005/02/25 13:15:37 UTC

svn commit: r155325 - jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginCreateAction.java

Author: skitching
Date: Fri Feb 25 04:15:35 2005
New Revision: 155325

URL: http://svn.apache.org/viewcvs?view=rev&rev=155325
Log:
Call PluginDeclarationScope methods beginScope and endScope as appropriate,
so that any plugin declarations occuring as a result of a PluginCreateAction
can be discarded when the plugin goes out of scope.

Modified:
    jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginCreateAction.java

Modified: jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginCreateAction.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginCreateAction.java?view=diff&r1=155324&r2=155325
==============================================================================
--- jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginCreateAction.java (original)
+++ jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/plugins/PluginCreateAction.java Fri Feb 25 04:15:35 2005
@@ -254,8 +254,24 @@
                   " match=[" + path + "]");
         }
 
-        // load any custom rules associated with the plugin
-        PluginDeclarationScope pds = PluginDeclarationScope.getInstance(context);
+        // Create a new declaration scope to ensure that:
+        // * if this xml tag uses "plugin-class=...", ie the declaration is
+        //   inline, then the declaration goes out-of-scope at the end of
+        //   the current xml element
+        // * any declarations occurring within the plugin (ie if a plugin
+        //   supports nested plugins) then those declarations don't overwrite
+        //   declarations made previously, but instead just "shadow" them until
+        //   the end method of this instance (ie the end of the current xml
+        //   element) causes the new scope to be discarded.
+        //
+        // Note that this code is fundamentally flawed; scope should be
+        // related directly to xml element depth, and not to whether a
+        // PluginCreateAction has been triggered or not. But as digester
+        // currently has no ability to invoke an operation when the *parent*
+        // element of the one which triggered an action occurs, this is
+        // a rough approximation of the correct behavior. See comments on
+        // the PluginDeclarationScope class for more info.
+        PluginDeclarationScope pds = PluginDeclarationScope.beginScope(context);
 
         // and get the cached info calculated at startParse time...
         PluginAttrNames pluginAttrNames = (PluginAttrNames)
@@ -447,6 +463,11 @@
         // and get rid of the instance of the plugin class from the
         // digester object stack.
         context.pop();
+        
+        // finally, get rid of the implicit declaration (if any) which
+        // was performed in begin, and get rid of any declarations that
+        // occurred due to custom rules associated with the current plugin.
+        PluginDeclarationScope.endScope(context);
     }
 
     /**
@@ -615,6 +636,8 @@
     }
     
     private static Properties attributesToProperties(org.xml.sax.Attributes attrs) {
+        // TODO: use prop names of form "{ns}name" if the attribute has a 
+        // namespace.
         int nAttrs = attrs.getLength();
         Properties props = new Properties();
         for(int i=0; i<nAttrs; ++i) {



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org