> > 
> > i'm also a bit confused why PluginDeclarationRule throws 
> > ClassNotFoundException's when require attributes are missing from the xml.
> >   this seems a wrong to me. (i've left these for the moment since it's 
> > easier for people to examine the code when it's in cvs.) there are also a 
> > few Exception's thrown. i'd prefer specific subclasses to be thrown since 
> > this allows users (if they wish) to diagnose the original problem.
> 
> Well, I chose ClassNotFound partly because the result of these mandatory
> attributes being missing is that we don't know which class to
> instantiate. Isn't that sort of like ClassNotFound? :-)
> 
> Any suggestions for superior options are welcome. I agree it could be
> improved. This code was written before the PluginInvalidInputException
> class existed; would this be more appropriate?
> 
> If there are any raw "Exception" classes being thrown, these are just
> remnants of code before cleanup and should definitely be fixed.

Attached is a patch to fix the locations where ClassNotFoundException
and Exception are being thrown. Class PluginInvalidInputException is
thrown instead.

Patch is based from digester root directory.

Regards,

Simon
Index: src/java/org/apache/commons/digester/plugins/Declaration.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/digester/src/java/org/apache/commons/digester/plugins/Declaration.java,v
retrieving revision 1.2
diff -u -r1.2 Declaration.java
--- src/java/org/apache/commons/digester/plugins/Declaration.java	5 Oct 2003 15:05:38 -0000	1.2
+++ src/java/org/apache/commons/digester/plugins/Declaration.java	6 Oct 2003 00:00:11 -0000
@@ -126,8 +126,7 @@
     /**
      * Constructor.
      */
-    public Declaration(String pluginClassName) 
-    throws ClassNotFoundException {
+    public Declaration(String pluginClassName) {
         pluginClassName_ = pluginClassName;
     }
     
Index: src/java/org/apache/commons/digester/plugins/PluginCreateRule.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/digester/src/java/org/apache/commons/digester/plugins/PluginCreateRule.java,v
retrieving revision 1.2
diff -u -r1.2 PluginCreateRule.java
--- src/java/org/apache/commons/digester/plugins/PluginCreateRule.java	5 Oct 2003 15:05:30 -0000	1.2
+++ src/java/org/apache/commons/digester/plugins/PluginCreateRule.java	6 Oct 2003 00:00:11 -0000
@@ -354,7 +354,7 @@
                 currDeclaration = pluginManager.getDeclarationById(pluginId);
                 
                 if (currDeclaration == null) {
-                    throw new Exception(
+                    throw new PluginInvalidInputException(
                         "Plugin id [" + pluginId + "] is not defined.");
                 }
             }
Index: src/java/org/apache/commons/digester/plugins/PluginDeclarationRule.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/digester/src/java/org/apache/commons/digester/plugins/PluginDeclarationRule.java,v
retrieving revision 1.2
diff -u -r1.2 PluginDeclarationRule.java
--- src/java/org/apache/commons/digester/plugins/PluginDeclarationRule.java	5 Oct 2003 15:05:30 -0000	1.2
+++ src/java/org/apache/commons/digester/plugins/PluginDeclarationRule.java	6 Oct 2003 00:00:11 -0000
@@ -128,13 +128,13 @@
         }
 
         if (id == null) {
-            throw new ClassNotFoundException(
+            throw new PluginInvalidInputException(
                     "mandatory attribute id not present on tag"
                      + " <" + name + ">");
         }
 
         if (pluginClassName == null) {
-            throw new ClassNotFoundException(
+            throw new PluginInvalidInputException(
                     "mandatory attribute class not present on tag"
                      + " <" + name + ">");
         }
@@ -187,7 +187,8 @@
                 log.debug("plugin redeclaration is identical: ignoring");
                 return;
             } else {
-                throw new Exception("Plugin id [" + id + "] is not unique");
+                throw new PluginInvalidInputException(
+                    "Plugin id [" + id + "] is not unique");
             }
         }
 
@@ -195,7 +196,7 @@
         // name. It might be nice someday to allow this but lets keep it
         // simple for now.
         if (pm.getDeclarationByClass(pluginClassName) != null) {
-            throw new Exception(
+            throw new PluginInvalidInputException(
                     "Plugin id [" + id + "] maps to class [" + pluginClassName + "]"
                      + " which has already been mapped by some other id.");
         }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to