Commits

rgielen  committed 0740d6b

Issue number: XW-344
Obtained from:
Submitted by: Claus Ibsen
Reviewed by: Rene Gielen
Improved exception handling and javadoc

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@847e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits 9c67b5b

Comments (0)

Files changed (1)

File src/java/com/opensymphony/xwork/validator/ValidatorFactory.java

 
     /**
      * Get a Validator that matches the given configuration.
+     *
+     * @param cfg  the configurator.
+     * @return  the validator.
      */
     public static Validator getValidator(ValidatorConfig cfg) {
 
             //todo - can this use the ThreadLocal?
             validator = ObjectFactory.getObjectFactory().buildValidator(className, cfg.getParams(), null); // ActionContext.getContext().getContextMap());
         } catch (Exception e) {
-            e.printStackTrace();
-            throw new IllegalArgumentException("There was a problem creating a Validator of type " + className);
+            final String msg = "There was a problem creating a Validator of type " + className + " : caused by " + e.getMessage();
+            LOG.error(msg, e);
+            throw new IllegalArgumentException(msg, e);
         }
 
         // set other configured properties
         return validator;
     }
 
+    /**
+     * Registers the given validator to the existing map of validators.
+     * This will <b>add</b> to the existing list.
+     *
+     * @param name    name of validator to add.
+     * @param className   the FQ classname of the validator.
+     */
     public static void registerValidator(String name, String className) {
         if (LOG.isDebugEnabled()) {
             LOG.debug("Registering validator of class " + className + " with name " + name);
         validators.put(name, className);
     }
 
+    /**
+     * Lookup to get the FQ classname of the given validator name.
+     *
+     * @param name   name of validator to lookup.
+     * @return  the found FQ classname
+     * @throws IllegalArgumentException is thrown if the name is not found.
+     */
     public static String lookupRegisteredValidatorType(String name) {
         // lookup the validator class mapped to the type name
         String className = (String) validators.get(name);