bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r992489 [1/2] - in /incubator/bval/sandbox/lang3-work: ./ bval-core/ bval-core/src/main/java/org/apache/bval/ bval-core/src/main/java/org/apache/bval/model/ bval-jsr303/src/main/java/ bval-jsr303/src/main/java/org/apache/bval/jsr303/ bval-j...
Date Fri, 03 Sep 2010 21:48:15 GMT
Author: mbenson
Date: Fri Sep  3 21:48:14 2010
New Revision: 992489

URL: http://svn.apache.org/viewvc?rev=992489&view=rev
Log:
merge r992420 from trunk

Modified:
    incubator/bval/sandbox/lang3-work/   (props changed)
    incubator/bval/sandbox/lang3-work/bval-core/pom.xml
    incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java
    incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/FeaturesCapable.java
    incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/MetaBean.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/   (props changed)
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheFactoryContext.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidationProvider.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorFactory.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ClassValidator.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintDescriptorImpl.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintValidation.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultMessageInterpolator.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303MetaBeanFactory.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/NestedMetaProperty.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorImpl.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorMetaBeanFactory.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/ParameterAccess.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/ReturnAccess.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/resolver/DefaultTraversableResolver.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ClassHelper.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/SecureActions.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/DecimalMinMaxValidatorsTest.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/HasStringValidator.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/MinMaxValidatorsForNumberTest.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/DefaultMessageInterpolatorTest.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/TckReproducerTest.java
    incubator/bval/sandbox/lang3-work/bval-tck/pom.xml
    incubator/bval/sandbox/lang3-work/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanBuilder.java
    incubator/bval/sandbox/lang3-work/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
    incubator/bval/sandbox/lang3-work/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManager.java
    incubator/bval/sandbox/lang3-work/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaElement.java
    incubator/bval/sandbox/lang3-work/bval-xstream/src/test/java/org/apache/bval/xml/XMLMetaBeanManagerTest.java
    incubator/bval/sandbox/lang3-work/pom.xml

Propchange: incubator/bval/sandbox/lang3-work/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep  3 21:48:14 2010
@@ -1 +1 @@
-/incubator/bval/trunk:992143
+/incubator/bval/trunk:992143,992401,992406,992412

Modified: incubator/bval/sandbox/lang3-work/bval-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-core/pom.xml?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-core/pom.xml (original)
+++ incubator/bval/sandbox/lang3-work/bval-core/pom.xml Fri Sep  3 21:48:14 2010
@@ -38,10 +38,6 @@
 
     <dependencies>
         <dependency>
-            <groupId>commons-lang</groupId>
-            <artifactId>commons-lang</artifactId>
-        </dependency>
-        <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         </dependency>

Modified: incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java Fri Sep  3 21:48:14 2010
@@ -18,7 +18,7 @@ package org.apache.bval;
 
 
 import org.apache.bval.model.MetaBean;
-import org.apache.commons.lang.ClassUtils;
+import org.apache.commons.lang3.ClassUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -26,7 +26,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 /**
- * Description: internal implementation class to construct 
+ * Description: internal implementation class to construct
  * metabeans with factories<br/>
  */
 public class MetaBeanBuilder {
@@ -78,35 +78,6 @@ public class MetaBeanBuilder {
     throw new IllegalArgumentException("MetaBean " + beanInfoId + " not found");
   }
 
-/*
-    *//* convenience method *//*
-    public void addLastFactory(MetaBeanFactory metaBeanFactory) {
-        if (factories == null) factories = new MetaBeanFactory[1];
-        else {
-            MetaBeanFactory[] facold = factories;
-            factories = new MetaBeanFactory[facold.length + 1];
-            System.arraycopy(facold, 0, factories, 0, facold.length);
-        }
-        factories[factories.length - 1] = metaBeanFactory;
-        updateXmlFactory();
-    }
-
-    */
-
-  /*
-   * convenience method
-   *//*
-    public void addFirstFactory(MetaBeanFactory metaBeanFactory) {
-        if (factories == null) factories = new MetaBeanFactory[1];
-        else {
-            MetaBeanFactory[] facold = factories;
-            factories = new MetaBeanFactory[facold.length + 1];
-            System.arraycopy(facold, 0, factories, 1, facold.length);
-        }
-        factories[0] = metaBeanFactory;
-        updateXmlFactory();
-    }*/
-
   /**
    * Build beans for all known ids.  Default implementation returns an empty map.
    * @return Map of String : MetaBean

Modified: incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/FeaturesCapable.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/FeaturesCapable.java?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/FeaturesCapable.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/FeaturesCapable.java Fri Sep  3 21:48:14 2010
@@ -17,7 +17,7 @@
 package org.apache.bval.model;
 
 import org.apache.commons.collections.FastHashMap;
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
 
 import java.io.Serializable;
 import java.util.Map;

Modified: incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/MetaBean.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/MetaBean.java?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/MetaBean.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/MetaBean.java Fri Sep  3 21:48:14 2010
@@ -16,7 +16,7 @@
  */
 package org.apache.bval.model;
 
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
 
 /**
  * Description: the meta description of a bean or class.

Propchange: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Sep  3 21:48:14 2010
@@ -0,0 +1 @@
+/incubator/bval/trunk/bval-jsr303/src/main/java:992330-992353,992401,992406,992412

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheFactoryContext.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheFactoryContext.java?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheFactoryContext.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheFactoryContext.java Fri Sep  3 21:48:14 2010
@@ -28,171 +28,178 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
- * Description: Represents the context that is used to create <code>ClassValidator</code>
- * instances.<br/>
+ * Description: Represents the context that is used to create
+ * <code>ClassValidator</code> instances.<br/>
  */
 public class ApacheFactoryContext implements ValidatorContext {
-  private final ApacheValidatorFactory factory;
-  private final MetaBeanFinder metaBeanFinder;
+    private final ApacheValidatorFactory factory;
+    private final MetaBeanFinder metaBeanFinder;
 
-  private MessageInterpolator messageInterpolator;
-  private TraversableResolver traversableResolver;
-  private ConstraintValidatorFactory constraintValidatorFactory;
-
-  /**
-   * Create a new ApacheFactoryContext instance.
-   * @param factory
-   */
-  public ApacheFactoryContext(ApacheValidatorFactory factory) {
-    this.factory = factory;
-    this.metaBeanFinder = buildMetaBeanManager();
-  }
-
-  /**
-   * Create a new ApacheFactoryContext instance.
-   * @param factory
-   * @param metaBeanFinder
-   */
-  protected ApacheFactoryContext(ApacheValidatorFactory factory,
-                                 MetaBeanFinder metaBeanFinder) {
-    this.factory = factory;
-    this.metaBeanFinder = metaBeanFinder;
-  }
-
-  /**
-   * Get the {@link ApacheValidatorFactory} used by this {@link ApacheFactoryContext}.
-   * @return {@link ApacheValidatorFactory}
-   */
-  public ApacheValidatorFactory getFactory() {
-    return factory;
-  }
-
-  /**
-   * Get the metaBeanFinder.
-   * @return {@link MetaBeanFinder}
-   */
-  public final MetaBeanFinder getMetaBeanFinder() {
-    return metaBeanFinder;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ValidatorContext messageInterpolator(MessageInterpolator messageInterpolator) {
-    this.messageInterpolator = messageInterpolator;
-    return this;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ValidatorContext traversableResolver(TraversableResolver traversableResolver) {
-    this.traversableResolver = traversableResolver;
-    return this;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ValidatorContext constraintValidatorFactory(
-      ConstraintValidatorFactory constraintValidatorFactory) {
-    this.constraintValidatorFactory = constraintValidatorFactory;
-    return this;
-  }
-
-  /**
-   * Get the {@link ConstraintValidatorFactory}.
-   * @return {@link ConstraintValidatorFactory}
-   */
-  public ConstraintValidatorFactory getConstraintValidatorFactory() {
-    return constraintValidatorFactory == null ? factory.getConstraintValidatorFactory() :
-        constraintValidatorFactory;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public Validator getValidator() {
-    ClassValidator validator = new ClassValidator(this);
-    if (Boolean.getBoolean(factory.getProperties().get(
-        ApacheValidatorConfiguration.Properties.TREAT_MAPS_LIKE_BEANS))) {
-      validator.setTreatMapsLikeBeans(true);
-    }
-    return validator;
-  }
-
-  /**
-   * Get the {@link MessageInterpolator}.
-   * @return {@link MessageInterpolator}
-   */
-  public MessageInterpolator getMessageInterpolator() {
-    return messageInterpolator == null ? factory.getMessageInterpolator() :
-        messageInterpolator;
-  }
-
-  /**
-   * Get the {@link TraversableResolver}.
-   * @return {@link TraversableResolver}
-   */
-  public TraversableResolver getTraversableResolver() {
-    return traversableResolver == null ? factory.getTraversableResolver() :
-        traversableResolver;
-  }
-
-  /**
-   * Create MetaBeanManager that
-   * uses JSR303-XML + JSR303-Annotations
-   * to build meta-data from.
-   *
-   * @return a new instance of MetaBeanManager with adequate MetaBeanFactories
-   */
-  @SuppressWarnings("deprecation")
-  protected MetaBeanManager buildMetaBeanManager() {
-    // this is relevant: xml before annotations
-    // (because ignore-annotations settings in xml)
-    List<MetaBeanFactory> builders = new ArrayList<MetaBeanFactory>(3);
-    if (Boolean.parseBoolean(factory.getProperties().get(
-        ApacheValidatorConfiguration.Properties.ENABLE_INTROSPECTOR))) {
-      builders.add(new IntrospectorMetaBeanFactory());
-    }
-    builders.add(new Jsr303MetaBeanFactory(this));
-    // as long as we support both: jsr303 and xstream-xml metabeans:
-    if (Boolean.parseBoolean(factory.getProperties().get(
-        ApacheValidatorConfiguration.Properties.ENABLE_METABEANS_XML))) {
-      return XMLMetaBeanManagerCreator.createXMLMetaBeanManager(builders);
-    } else {
-      return createMetaBeanManager(builders);
-    }
-  }
-
-  /**
-   * Create a {@link MetaBeanManager} using the specified builders.
-   * @param builders {@link MetaBeanFactory} {@link List}
-   * @return {@link MetaBeanManager}
-   */
-  protected MetaBeanManager createMetaBeanManager(List<MetaBeanFactory> builders) {
-    return new MetaBeanManager(
-        new MetaBeanBuilder(builders.toArray(new MetaBeanFactory[builders.size()])));
-  }
-
-  /**
-   * separate class to prevent the classloader to immediately load
-   * optional classes: XMLMetaBeanManager, XMLMetaBeanFactory, XMLMetaBeanBuilder
-   * that might not be available in the classpath
-   */
-  private static class XMLMetaBeanManagerCreator {
+    private MessageInterpolator messageInterpolator;
+    private TraversableResolver traversableResolver;
+    private ConstraintValidatorFactory constraintValidatorFactory;
 
     /**
-     * Create the {@link MetaBeanManager} to process JSR303 XML.  Requires bval-xstream at RT.
+     * Create a new ApacheFactoryContext instance.
+     * 
+     * @param factory
+     */
+    public ApacheFactoryContext(ApacheValidatorFactory factory) {
+        this.factory = factory;
+        this.metaBeanFinder = buildMetaBeanManager();
+    }
+
+    /**
+     * Create a new ApacheFactoryContext instance.
+     * 
+     * @param factory
+     * @param metaBeanFinder
+     */
+    protected ApacheFactoryContext(ApacheValidatorFactory factory, MetaBeanFinder metaBeanFinder) {
+        this.factory = factory;
+        this.metaBeanFinder = metaBeanFinder;
+    }
+
+    /**
+     * Get the {@link ApacheValidatorFactory} used by this
+     * {@link ApacheFactoryContext}.
+     * 
+     * @return {@link ApacheValidatorFactory}
+     */
+    public ApacheValidatorFactory getFactory() {
+        return factory;
+    }
+
+    /**
+     * Get the metaBeanFinder.
+     * 
+     * @return {@link MetaBeanFinder}
+     */
+    public final MetaBeanFinder getMetaBeanFinder() {
+        return metaBeanFinder;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ValidatorContext messageInterpolator(MessageInterpolator messageInterpolator) {
+        this.messageInterpolator = messageInterpolator;
+        return this;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ValidatorContext traversableResolver(TraversableResolver traversableResolver) {
+        this.traversableResolver = traversableResolver;
+        return this;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ValidatorContext constraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory) {
+        this.constraintValidatorFactory = constraintValidatorFactory;
+        return this;
+    }
+
+    /**
+     * Get the {@link ConstraintValidatorFactory}.
+     * 
+     * @return {@link ConstraintValidatorFactory}
+     */
+    public ConstraintValidatorFactory getConstraintValidatorFactory() {
+        return constraintValidatorFactory == null ? factory.getConstraintValidatorFactory()
+            : constraintValidatorFactory;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Validator getValidator() {
+        ClassValidator validator = new ClassValidator(this);
+        if (Boolean.getBoolean(factory.getProperties().get(
+            ApacheValidatorConfiguration.Properties.TREAT_MAPS_LIKE_BEANS))) {
+            validator.setTreatMapsLikeBeans(true);
+        }
+        return validator;
+    }
+
+    /**
+     * Get the {@link MessageInterpolator}.
+     * 
+     * @return {@link MessageInterpolator}
+     */
+    public MessageInterpolator getMessageInterpolator() {
+        return messageInterpolator == null ? factory.getMessageInterpolator() : messageInterpolator;
+    }
+
+    /**
+     * Get the {@link TraversableResolver}.
+     * 
+     * @return {@link TraversableResolver}
+     */
+    public TraversableResolver getTraversableResolver() {
+        return traversableResolver == null ? factory.getTraversableResolver() : traversableResolver;
+    }
+
+    /**
+     * Create MetaBeanManager that uses JSR303-XML + JSR303-Annotations to build
+     * meta-data from.
+     * 
+     * @return a new instance of MetaBeanManager with adequate MetaBeanFactories
+     */
+    @SuppressWarnings("deprecation")
+    protected MetaBeanManager buildMetaBeanManager() {
+        // this is relevant: xml before annotations
+        // (because ignore-annotations settings in xml)
+        List<MetaBeanFactory> builders = new ArrayList<MetaBeanFactory>(3);
+        if (Boolean.parseBoolean(factory.getProperties().get(
+            ApacheValidatorConfiguration.Properties.ENABLE_INTROSPECTOR))) {
+            builders.add(new IntrospectorMetaBeanFactory());
+        }
+        builders.add(new Jsr303MetaBeanFactory(this));
+        // as long as we support both: jsr303 and xstream-xml metabeans:
+        if (Boolean.parseBoolean(factory.getProperties().get(
+            ApacheValidatorConfiguration.Properties.ENABLE_METABEANS_XML))) {
+            return XMLMetaBeanManagerCreator.createXMLMetaBeanManager(builders);
+        } else {
+            return createMetaBeanManager(builders);
+        }
+    }
+
+    /**
+     * Create a {@link MetaBeanManager} using the specified builders.
+     * 
      * @param builders
+     *            {@link MetaBeanFactory} {@link List}
      * @return {@link MetaBeanManager}
      */
-    // NOTE - We return MetaBeanManager instead of XMLMetaBeanManager to keep
-    //        bval-xstream an optional module.
-    protected static MetaBeanManager createXMLMetaBeanManager(List<MetaBeanFactory> builders) {
-      builders.add(new XMLMetaBeanFactory());
-      return new XMLMetaBeanManager(
-          new XMLMetaBeanBuilder(builders.toArray(new MetaBeanFactory[builders.size()])));
+    protected MetaBeanManager createMetaBeanManager(List<MetaBeanFactory> builders) {
+        return new MetaBeanManager(new MetaBeanBuilder(builders.toArray(new MetaBeanFactory[builders.size()])));
+    }
+
+    /**
+     * separate class to prevent the classloader to immediately load optional
+     * classes: XMLMetaBeanManager, XMLMetaBeanFactory, XMLMetaBeanBuilder that
+     * might not be available in the classpath
+     */
+    private static class XMLMetaBeanManagerCreator {
+
+        /**
+         * Create the {@link MetaBeanManager} to process JSR303 XML. Requires
+         * bval-xstream at RT.
+         * 
+         * @param builders
+         * @return {@link MetaBeanManager}
+         */
+        // NOTE - We return MetaBeanManager instead of XMLMetaBeanManager to
+        // keep
+        // bval-xstream an optional module.
+        protected static MetaBeanManager createXMLMetaBeanManager(List<MetaBeanFactory> builders) {
+            builders.add(new XMLMetaBeanFactory());
+            return new XMLMetaBeanManager(
+                new XMLMetaBeanBuilder(builders.toArray(new MetaBeanFactory[builders.size()])));
+        }
     }
-  }
 }

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidationProvider.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidationProvider.java?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidationProvider.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidationProvider.java Fri Sep  3 21:48:14 2010
@@ -47,7 +47,7 @@ public class ApacheValidationProvider
     /**
      * {@inheritDoc}
      */
-    public ConfigurationImpl createSpecializedConfiguration(BootstrapState state) {
+    public ApacheValidatorConfiguration createSpecializedConfiguration(BootstrapState state) {
         return new ConfigurationImpl(state, this);
     }
 

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorFactory.java?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorFactory.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorFactory.java Fri Sep  3 21:48:14 2010
@@ -41,7 +41,7 @@ import org.apache.bval.jsr303.xml.Annota
 import org.apache.bval.jsr303.xml.MetaConstraint;
 import org.apache.bval.jsr303.xml.ValidationMappingParser;
 import org.apache.bval.util.AccessStrategy;
-import org.apache.commons.lang.ClassUtils;
+import org.apache.commons.lang3.ClassUtils;
 
 /**
  * Description: a factory is a complete configurated object that can create
@@ -232,7 +232,6 @@ public class ApacheValidatorFactory impl
      * @throws ValidationException
      *             if the provider does not support the call.
      */
-    @SuppressWarnings("unchecked")
     public <T> T unwrap(Class<T> type) {
         if (type.isInstance(this)) {
             @SuppressWarnings("unchecked")

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ClassValidator.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ClassValidator.java?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ClassValidator.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ClassValidator.java Fri Sep  3 21:48:14 2010
@@ -41,7 +41,7 @@ import org.apache.bval.model.MetaBean;
 import org.apache.bval.model.MetaProperty;
 import org.apache.bval.util.AccessStrategy;
 import org.apache.bval.util.ValidationHelper;
-import org.apache.commons.lang.ClassUtils;
+import org.apache.commons.lang3.ClassUtils;
 
 // TODO: centralize treatMapsLikeBeans
 
@@ -362,7 +362,6 @@ public class ClassValidator implements V
      * @throws ValidationException
      *             if the provider does not support the call.
      */
-    @SuppressWarnings("unchecked")
     // @Override - not allowed in 1.5 for Interface methods
     public <T> T unwrap(Class<T> type) {
         if (type.isAssignableFrom(getClass())) {

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintDescriptorImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintDescriptorImpl.java?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintDescriptorImpl.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintDescriptorImpl.java Fri Sep  3 21:48:14 2010
@@ -27,103 +27,106 @@ import java.util.Map;
 import java.util.Set;
 
 /**
- * Description: immutable, serializable implementation of ConstraintDescriptor interface of JSR303<br>
+ * Description: immutable, serializable implementation of ConstraintDescriptor
+ * interface of JSR303<br>
  * User: roman.stumm<br>
  * Date: 22.04.2010<br>
  * Time: 10:21:23<br>
  */
 public class ConstraintDescriptorImpl<T extends Annotation> implements ConstraintDescriptor<T>, Serializable {
-  /** Serialization version */
-  private static final long serialVersionUID = 1L;
+    /** Serialization version */
+    private static final long serialVersionUID = 1L;
 
-  private final T annotation;
-  private final Set<Class<?>> groups;
-  private final Set<Class<? extends javax.validation.Payload>> payload;
-  private final List<java.lang.Class<? extends javax.validation.ConstraintValidator<T, ?>>> constraintValidatorClasses;
-  private final Map<String, Object> attributes;
-  private final Set<ConstraintDescriptor<?>> composingConstraints;
-  private final boolean reportAsSingleViolation;
-
-  /**
-   * Create a new ConstraintDescriptorImpl instance.
-   * @param descriptor
-   */
-  public ConstraintDescriptorImpl(ConstraintDescriptor<T> descriptor) {
-    this(descriptor.getAnnotation(), descriptor.getGroups(), descriptor.getPayload(),
-        descriptor.getConstraintValidatorClasses(),
-        descriptor.getAttributes(), descriptor.getComposingConstraints(), descriptor.isReportAsSingleViolation());
-  }
-
-  /**
-   * Create a new ConstraintDescriptorImpl instance.
-   * @param annotation
-   * @param groups
-   * @param payload
-   * @param constraintValidatorClasses
-   * @param attributes
-   * @param composingConstraints
-   * @param reportAsSingleViolation
-   */
-  public ConstraintDescriptorImpl(T annotation, Set<Class<?>> groups,
-                                  Set<Class<? extends javax.validation.Payload>> payload,
-                                  List<java.lang.Class<? extends javax.validation.ConstraintValidator<T, ?>>> constraintValidatorClasses,
-                                  Map<String, Object> attributes,
-                                  Set<ConstraintDescriptor<?>> composingConstraints, boolean reportAsSingleViolation) {
-    this.annotation = annotation;
-    this.groups = groups;
-    this.payload = payload;
-    this.constraintValidatorClasses = constraintValidatorClasses;
-    this.attributes = attributes;
-    this.composingConstraints = composingConstraints;
-    this.reportAsSingleViolation = reportAsSingleViolation;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public T getAnnotation() {
-    return annotation;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public Set<Class<?>> getGroups() {
-    return groups;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public Set<Class<? extends Payload>> getPayload() {
-    return payload;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public List<java.lang.Class<? extends javax.validation.ConstraintValidator<T, ?>>> getConstraintValidatorClasses() {
-    return constraintValidatorClasses;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public Map<String, Object> getAttributes() {
-    return attributes;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public Set<ConstraintDescriptor<?>> getComposingConstraints() {
-    return composingConstraints;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public boolean isReportAsSingleViolation() {
-    return reportAsSingleViolation;
-  }
+    private final T annotation;
+    private final Set<Class<?>> groups;
+    private final Set<Class<? extends javax.validation.Payload>> payload;
+    private final List<java.lang.Class<? extends javax.validation.ConstraintValidator<T, ?>>> constraintValidatorClasses;
+    private final Map<String, Object> attributes;
+    private final Set<ConstraintDescriptor<?>> composingConstraints;
+    private final boolean reportAsSingleViolation;
+
+    /**
+     * Create a new ConstraintDescriptorImpl instance.
+     * 
+     * @param descriptor
+     */
+    public ConstraintDescriptorImpl(ConstraintDescriptor<T> descriptor) {
+        this(descriptor.getAnnotation(), descriptor.getGroups(), descriptor.getPayload(), descriptor
+            .getConstraintValidatorClasses(), descriptor.getAttributes(), descriptor.getComposingConstraints(),
+            descriptor.isReportAsSingleViolation());
+    }
+
+    /**
+     * Create a new ConstraintDescriptorImpl instance.
+     * 
+     * @param annotation
+     * @param groups
+     * @param payload
+     * @param constraintValidatorClasses
+     * @param attributes
+     * @param composingConstraints
+     * @param reportAsSingleViolation
+     */
+    public ConstraintDescriptorImpl(T annotation, Set<Class<?>> groups,
+        Set<Class<? extends javax.validation.Payload>> payload,
+        List<java.lang.Class<? extends javax.validation.ConstraintValidator<T, ?>>> constraintValidatorClasses,
+        Map<String, Object> attributes, Set<ConstraintDescriptor<?>> composingConstraints,
+        boolean reportAsSingleViolation) {
+        this.annotation = annotation;
+        this.groups = groups;
+        this.payload = payload;
+        this.constraintValidatorClasses = constraintValidatorClasses;
+        this.attributes = attributes;
+        this.composingConstraints = composingConstraints;
+        this.reportAsSingleViolation = reportAsSingleViolation;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public T getAnnotation() {
+        return annotation;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Set<Class<?>> getGroups() {
+        return groups;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Set<Class<? extends Payload>> getPayload() {
+        return payload;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<java.lang.Class<? extends javax.validation.ConstraintValidator<T, ?>>> getConstraintValidatorClasses() {
+        return constraintValidatorClasses;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Map<String, Object> getAttributes() {
+        return attributes;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Set<ConstraintDescriptor<?>> getComposingConstraints() {
+        return composingConstraints;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isReportAsSingleViolation() {
+        return reportAsSingleViolation;
+    }
 }

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintValidation.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintValidation.java?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintValidation.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintValidation.java Fri Sep  3 21:48:14 2010
@@ -18,7 +18,6 @@
  */
 package org.apache.bval.jsr303;
 
-
 import org.apache.bval.jsr303.util.NodeImpl;
 import org.apache.bval.jsr303.util.PathImpl;
 import org.apache.bval.model.Validation;
@@ -40,327 +39,348 @@ import java.util.*;
  * Description: Adapter between Constraint (JSR303) and Validation (Core)<br/>
  * this instance is immutable!<br/>
  */
-public class ConstraintValidation<T extends Annotation>
-    implements Validation, ConstraintDescriptor<T> {
-  private static final String ANNOTATION_MESSAGE = "message";
-
-  private final ConstraintValidator<T, ?> validator;
-  private T annotation; // for metadata request API
-  private final AccessStrategy access;
-  private final boolean reportFromComposite;
-  private final Map<String, Object> attributes;
-
-  private Set<ConstraintValidation<?>> composedConstraints;
-
-  /**
-   * the owner is the type where the validation comes from.
-   * it is used to support implicit grouping.
-   */
-  private final Class<?> owner;
-  private Set<Class<?>> groups;
-  private Set<Class<? extends Payload>> payload;
-  private Class<? extends ConstraintValidator<T, ?>>[] validatorClasses;
-
-  /**
-   * Create a new ConstraintValidation instance.
-   * @param validatorClasses
-   * @param validator  - the constraint validator
-   * @param annotation - the annotation of the constraint
-   * @param owner      - the type where the annotated element is placed
-   *                   (class, interface, annotation type)
-   * @param access     - how to access the value
-   * @param reportFromComposite
-   */
-  public ConstraintValidation(
-      Class<? extends ConstraintValidator<T, ?>>[] validatorClasses,
-      ConstraintValidator<T, ?> validator, T annotation, Class<?> owner,
-      AccessStrategy access, boolean reportFromComposite) {
-    this.attributes = new HashMap<String, Object>();
-    this.validatorClasses = validatorClasses;
-    this.validator = validator;
-    this.annotation = annotation;
-    this.owner = owner;
-    this.access = access;
-    this.reportFromComposite = reportFromComposite;
-  }
-
-  /**
-   * Return a {@link Serializable} {@link ConstraintDescriptor} capturing a snapshot of current state.
-   * @return {@link ConstraintDescriptor}
-   */
-  public ConstraintDescriptor<T> asSerializableDescriptor() {
-    return new ConstraintDescriptorImpl<T>(this);
-  }
-
-  /**
-   * Set the applicable validation groups.
-   * @param groups
-   */
-  void setGroups(Set<Class<?>> groups) {
-    this.groups = groups;
-    this.attributes.put("groups", groups.toArray(new Class[groups.size()]));
-  }
-
-  /**
-   * Set the payload.
-   * @param payload
-   */
-  void setPayload(Set<Class<? extends Payload>> payload) {
-    this.payload = payload;
-    this.attributes.put("payload", payload.toArray(new Class[payload.size()]));
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public boolean isReportAsSingleViolation() {
-    return reportFromComposite;
-  }
-
-  /**
-   * Add a composing constraint.
-   * @param aConstraintValidation to add
-   */
-  public void addComposed(ConstraintValidation<?> aConstraintValidation) {
-    if (composedConstraints == null) {
-      composedConstraints = new HashSet<ConstraintValidation<?>>();
-    }
-    composedConstraints.add(aConstraintValidation);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public <L extends ValidationListener> void validate(ValidationContext<L> context) {
-    validate((GroupValidationContext<?>) context);
-  }
-
-  /**
-   * Validate a {@link GroupValidationContext}.
-   * @param context root
-   */
-  public void validate(GroupValidationContext<?> context) {
-    context.setConstraintValidation(this);
-    /**
-     * execute unless the given validation constraint has already been processed
-     * during this validation routine (as part of a previous group match)
-     */
-    if (!isMemberOf(context.getCurrentGroup().getGroup())) {
-      return; // do not validate in the current group
-    }
-    if (context.getCurrentOwner() != null && this.owner != context.getCurrentOwner()) {
-      return;
-    }
-    if (validator != null && !context.collectValidated(validator))
-      return; // already done
-
-    if (context.getMetaProperty() != null && !isReachable(context)) {
-      return;
-    }
-
-    // process composed constraints
-    if (isReportAsSingleViolation()) {
-      ConstraintValidationListener<?> listener = context.getListener();
-      listener.beginReportAsSingle();
-
-      boolean failed = false;
-      try {
-          // stop validating when already failed and ReportAsSingleInvalidConstraint = true ?
-          for (Iterator<ConstraintValidation<?>> composed = getComposingValidations().iterator(); !failed && composed.hasNext();) {
-              composed.next().validate(context);
-              failed = listener.hasViolations();
-          }
-      } finally {
-          listener.endReportAsSingle();
-          // Restore current constraint validation
-          context.setConstraintValidation(this);
-      }
-
-      if (failed) {
-        // TODO RSt - how should the composed constraint error report look like?
-        ConstraintValidatorContextImpl jsrContext =
-            new ConstraintValidatorContextImpl(context, this);
-        addErrors(context, jsrContext); // add defaultErrorMessage only*/
-        return;
-      }
-    } else {
-      for (ConstraintValidation<?> composed : getComposingValidations()) {
-        composed.validate(context);
-      }
-
-      // Restore current constraint validation
-      context.setConstraintValidation(this);
-    }
-
-    if (validator != null) {
-      ConstraintValidatorContextImpl jsrContext =
-          new ConstraintValidatorContextImpl(context, this);
-      @SuppressWarnings("unchecked")
-      final ConstraintValidator<T, Object> objectValidator = (ConstraintValidator<T, Object>) validator;
-      if (!objectValidator.isValid(context.getValidatedValue(), jsrContext)) {
-        addErrors(context, jsrContext);
-      }
-    }
-  }
-
-  /**
-   * Initialize the validator (if not <code>null</code>) with the stored
-   * annotation.
-   */
-  public void initialize() {
-    if (null != validator) {
-      try {
-        validator.initialize(annotation);
-      } catch (RuntimeException e) {
-        // Either a "legit" problem initializing the validator or a
-        // ClassCastException if the validator associated annotation is
-        // not a supertype of the validated annotation.
-        throw new ConstraintDefinitionException(
-            "Incorrect validator [" + validator.getClass().getCanonicalName() + "] for annotation " +
-                annotation.annotationType().getCanonicalName(), e);
-      }
-    }
-  }
-
-  private boolean isReachable(GroupValidationContext<?> context) {
-    PathImpl path = context.getPropertyPath();
-    NodeImpl node = path.getLeafNode();
-    PathImpl beanPath = path.getPathWithoutLeafNode();
-    if (beanPath == null) {
-      beanPath = PathImpl.create(null);
-    }
-    try {
-      if (!context.getTraversableResolver()
-          .isReachable(context.getBean(), node,
-              context.getRootMetaBean().getBeanClass(), beanPath,
-              access.getElementType())) return false;
-    } catch (RuntimeException e) {
-      throw new ValidationException(
-          "Error in TraversableResolver.isReachable() for " + context.getBean(), e);
-    }
-
-    return true;
-  }
-
-  private void addErrors(GroupValidationContext<?> context,
-                         ConstraintValidatorContextImpl jsrContext) {
-    for (ValidationListener.Error each : jsrContext.getErrorMessages()) {
-      context.getListener().addError(each, context);
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public String toString() {
-    return "ConstraintValidation{" + validator + '}';
-  }
-
-  /**
-   * Get the message template used by this constraint.
-   * @return String
-   */
-  public String getMessageTemplate() {
-    return (String) attributes.get(ANNOTATION_MESSAGE);
-  }
-
-  /**
-   * Get the {@link ConstraintValidator} invoked by this {@link ConstraintValidation}.
-   * @return
-   */
-  public ConstraintValidator<T, ?> getValidator() {
-    return validator;
-  }
-
-  /**
-   * Learn whether this {@link ConstraintValidation} belongs to the specified group.
-   * @param reqGroup
-   * @return boolean
-   */
-  protected boolean isMemberOf(Class<?> reqGroup) {
-    return groups.contains(reqGroup);
-  }
-
-  /**
-   * Get the owning class of this {@link ConstraintValidation}.
-   * @return Class
-   */
-  public Class<?> getOwner() {
-    return owner;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public T getAnnotation() {
-    return annotation;
-  }
-
-  /**
-   * Get the {@link AccessStrategy} used by this {@link ConstraintValidation}.
-   * @return {@link AccessStrategy}
-   */
-  public AccessStrategy getAccess() {
-    return access;
-  }
-
-  /**
-   * Override the Annotation set at construction.
-   * @param annotation
-   */
-  public void setAnnotation(T annotation) {
-    this.annotation = annotation;
-  }
-
-  /////////////////////////// ConstraintDescriptor implementation
-
-  /**
-   * {@inheritDoc}
-   */
-  public Map<String, Object> getAttributes() {
-    return attributes;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @SuppressWarnings("unchecked")
-  public Set<ConstraintDescriptor<?>> getComposingConstraints() {
-    return composedConstraints == null ? Collections.EMPTY_SET : composedConstraints;
-  }
-
-  /**
-   * Get the composing {@link ConstraintValidation} objects.  This is effectively
-   * an implementation-specific analogue to {@link #getComposingConstraints()}.
-   * @return {@link Set} of {@link ConstraintValidation}
-   */
-  @SuppressWarnings("unchecked")
-  Set<ConstraintValidation<?>> getComposingValidations() {
-    return composedConstraints == null ? Collections.EMPTY_SET : composedConstraints;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public Set<Class<?>> getGroups() {
-    return groups;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public Set<Class<? extends Payload>> getPayload() {
-    return payload;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public List<Class<? extends ConstraintValidator<T, ?>>> getConstraintValidatorClasses() {
-    if (validatorClasses == null) {
-      return Collections.emptyList();
+public class ConstraintValidation<T extends Annotation> implements Validation, ConstraintDescriptor<T> {
+    private static final String ANNOTATION_MESSAGE = "message";
+
+    private final ConstraintValidator<T, ?> validator;
+    private T annotation; // for metadata request API
+    private final AccessStrategy access;
+    private final boolean reportFromComposite;
+    private final Map<String, Object> attributes;
+
+    private Set<ConstraintValidation<?>> composedConstraints;
+
+    /**
+     * the owner is the type where the validation comes from. it is used to
+     * support implicit grouping.
+     */
+    private final Class<?> owner;
+    private Set<Class<?>> groups;
+    private Set<Class<? extends Payload>> payload;
+    private Class<? extends ConstraintValidator<T, ?>>[] validatorClasses;
+
+    /**
+     * Create a new ConstraintValidation instance.
+     * 
+     * @param validatorClasses
+     * @param validator
+     *            - the constraint validator
+     * @param annotation
+     *            - the annotation of the constraint
+     * @param owner
+     *            - the type where the annotated element is placed (class,
+     *            interface, annotation type)
+     * @param access
+     *            - how to access the value
+     * @param reportFromComposite
+     */
+    public ConstraintValidation(Class<? extends ConstraintValidator<T, ?>>[] validatorClasses,
+        ConstraintValidator<T, ?> validator, T annotation, Class<?> owner, AccessStrategy access,
+        boolean reportFromComposite) {
+        this.attributes = new HashMap<String, Object>();
+        this.validatorClasses = validatorClasses;
+        this.validator = validator;
+        this.annotation = annotation;
+        this.owner = owner;
+        this.access = access;
+        this.reportFromComposite = reportFromComposite;
+    }
+
+    /**
+     * Return a {@link Serializable} {@link ConstraintDescriptor} capturing a
+     * snapshot of current state.
+     * 
+     * @return {@link ConstraintDescriptor}
+     */
+    public ConstraintDescriptor<T> asSerializableDescriptor() {
+        return new ConstraintDescriptorImpl<T>(this);
+    }
+
+    /**
+     * Set the applicable validation groups.
+     * 
+     * @param groups
+     */
+    void setGroups(Set<Class<?>> groups) {
+        this.groups = groups;
+        this.attributes.put("groups", groups.toArray(new Class[groups.size()]));
+    }
+
+    /**
+     * Set the payload.
+     * 
+     * @param payload
+     */
+    void setPayload(Set<Class<? extends Payload>> payload) {
+        this.payload = payload;
+        this.attributes.put("payload", payload.toArray(new Class[payload.size()]));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isReportAsSingleViolation() {
+        return reportFromComposite;
+    }
+
+    /**
+     * Add a composing constraint.
+     * 
+     * @param aConstraintValidation
+     *            to add
+     */
+    public void addComposed(ConstraintValidation<?> aConstraintValidation) {
+        if (composedConstraints == null) {
+            composedConstraints = new HashSet<ConstraintValidation<?>>();
+        }
+        composedConstraints.add(aConstraintValidation);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public <L extends ValidationListener> void validate(ValidationContext<L> context) {
+        validate((GroupValidationContext<?>) context);
+    }
+
+    /**
+     * Validate a {@link GroupValidationContext}.
+     * 
+     * @param context
+     *            root
+     */
+    public void validate(GroupValidationContext<?> context) {
+        context.setConstraintValidation(this);
+        /**
+         * execute unless the given validation constraint has already been
+         * processed during this validation routine (as part of a previous group
+         * match)
+         */
+        if (!isMemberOf(context.getCurrentGroup().getGroup())) {
+            return; // do not validate in the current group
+        }
+        if (context.getCurrentOwner() != null && this.owner != context.getCurrentOwner()) {
+            return;
+        }
+        if (validator != null && !context.collectValidated(validator))
+            return; // already done
+
+        if (context.getMetaProperty() != null && !isReachable(context)) {
+            return;
+        }
+
+        // process composed constraints
+        if (isReportAsSingleViolation()) {
+            ConstraintValidationListener<?> listener = context.getListener();
+            listener.beginReportAsSingle();
+
+            boolean failed = false;
+            try {
+                // stop validating when already failed and
+                // ReportAsSingleInvalidConstraint = true ?
+                for (Iterator<ConstraintValidation<?>> composed = getComposingValidations().iterator(); !failed
+                    && composed.hasNext();) {
+                    composed.next().validate(context);
+                    failed = listener.hasViolations();
+                }
+            } finally {
+                listener.endReportAsSingle();
+                // Restore current constraint validation
+                context.setConstraintValidation(this);
+            }
+
+            if (failed) {
+                // TODO RSt - how should the composed constraint error report
+                // look like?
+                ConstraintValidatorContextImpl jsrContext = new ConstraintValidatorContextImpl(context, this);
+                addErrors(context, jsrContext); // add defaultErrorMessage
+                                                // only*/
+                return;
+            }
+        } else {
+            for (ConstraintValidation<?> composed : getComposingValidations()) {
+                composed.validate(context);
+            }
+
+            // Restore current constraint validation
+            context.setConstraintValidation(this);
+        }
+
+        if (validator != null) {
+            ConstraintValidatorContextImpl jsrContext = new ConstraintValidatorContextImpl(context, this);
+            @SuppressWarnings("unchecked")
+            final ConstraintValidator<T, Object> objectValidator = (ConstraintValidator<T, Object>) validator;
+            if (!objectValidator.isValid(context.getValidatedValue(), jsrContext)) {
+                addErrors(context, jsrContext);
+            }
+        }
+    }
+
+    /**
+     * Initialize the validator (if not <code>null</code>) with the stored
+     * annotation.
+     */
+    public void initialize() {
+        if (null != validator) {
+            try {
+                validator.initialize(annotation);
+            } catch (RuntimeException e) {
+                // Either a "legit" problem initializing the validator or a
+                // ClassCastException if the validator associated annotation is
+                // not a supertype of the validated annotation.
+                throw new ConstraintDefinitionException("Incorrect validator ["
+                    + validator.getClass().getCanonicalName() + "] for annotation "
+                    + annotation.annotationType().getCanonicalName(), e);
+            }
+        }
+    }
+
+    private boolean isReachable(GroupValidationContext<?> context) {
+        PathImpl path = context.getPropertyPath();
+        NodeImpl node = path.getLeafNode();
+        PathImpl beanPath = path.getPathWithoutLeafNode();
+        if (beanPath == null) {
+            beanPath = PathImpl.create(null);
+        }
+        try {
+            if (!context.getTraversableResolver().isReachable(context.getBean(), node,
+                context.getRootMetaBean().getBeanClass(), beanPath, access.getElementType()))
+                return false;
+        } catch (RuntimeException e) {
+            throw new ValidationException("Error in TraversableResolver.isReachable() for " + context.getBean(), e);
+        }
+
+        return true;
+    }
+
+    private void addErrors(GroupValidationContext<?> context, ConstraintValidatorContextImpl jsrContext) {
+        for (ValidationListener.Error each : jsrContext.getErrorMessages()) {
+            context.getListener().addError(each, context);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString() {
+        return "ConstraintValidation{" + validator + '}';
+    }
+
+    /**
+     * Get the message template used by this constraint.
+     * 
+     * @return String
+     */
+    public String getMessageTemplate() {
+        return (String) attributes.get(ANNOTATION_MESSAGE);
+    }
+
+    /**
+     * Get the {@link ConstraintValidator} invoked by this
+     * {@link ConstraintValidation}.
+     * 
+     * @return
+     */
+    public ConstraintValidator<T, ?> getValidator() {
+        return validator;
+    }
+
+    /**
+     * Learn whether this {@link ConstraintValidation} belongs to the specified
+     * group.
+     * 
+     * @param reqGroup
+     * @return boolean
+     */
+    protected boolean isMemberOf(Class<?> reqGroup) {
+        return groups.contains(reqGroup);
+    }
+
+    /**
+     * Get the owning class of this {@link ConstraintValidation}.
+     * 
+     * @return Class
+     */
+    public Class<?> getOwner() {
+        return owner;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public T getAnnotation() {
+        return annotation;
+    }
+
+    /**
+     * Get the {@link AccessStrategy} used by this {@link ConstraintValidation}.
+     * 
+     * @return {@link AccessStrategy}
+     */
+    public AccessStrategy getAccess() {
+        return access;
+    }
+
+    /**
+     * Override the Annotation set at construction.
+     * 
+     * @param annotation
+     */
+    public void setAnnotation(T annotation) {
+        this.annotation = annotation;
+    }
+
+    // ///////////////////////// ConstraintDescriptor implementation
+
+    /**
+     * {@inheritDoc}
+     */
+    public Map<String, Object> getAttributes() {
+        return attributes;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public Set<ConstraintDescriptor<?>> getComposingConstraints() {
+        return composedConstraints == null ? Collections.EMPTY_SET : composedConstraints;
+    }
+
+    /**
+     * Get the composing {@link ConstraintValidation} objects. This is
+     * effectively an implementation-specific analogue to
+     * {@link #getComposingConstraints()}.
+     * 
+     * @return {@link Set} of {@link ConstraintValidation}
+     */
+    @SuppressWarnings("unchecked")
+    Set<ConstraintValidation<?>> getComposingValidations() {
+        return composedConstraints == null ? Collections.EMPTY_SET : composedConstraints;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Set<Class<?>> getGroups() {
+        return groups;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Set<Class<? extends Payload>> getPayload() {
+        return payload;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Class<? extends ConstraintValidator<T, ?>>> getConstraintValidatorClasses() {
+        if (validatorClasses == null) {
+            return Collections.emptyList();
+        }
+        return Arrays.asList(validatorClasses);
     }
-    return Arrays.asList(validatorClasses);
-  }
 
 }

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultMessageInterpolator.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultMessageInterpolator.java?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultMessageInterpolator.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultMessageInterpolator.java Fri Sep  3 21:48:14 2010
@@ -16,7 +16,7 @@
  */
 package org.apache.bval.jsr303;
 
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -141,10 +141,10 @@ public class DefaultMessageInterpolator 
         // resolve annotation attributes (step 4)
         resolvedMessage =
               replaceAnnotationAttributes(resolvedMessage, annotationParameters);
-        
+
         // curly braces need to be scaped in the original msg, so unescape them now
         resolvedMessage = resolvedMessage.replace( "\\{", "{" ).replace( "\\}", "}" ).replace( "\\\\", "\\" );
-        
+
         return resolvedMessage;
     }
 
@@ -283,11 +283,11 @@ public class DefaultMessageInterpolator 
     public void setLocale(Locale locale) {
         defaultLocale = locale;
     }
-    
+
     /**
      * Escapes the string to comply with
      * {@link Matcher#appendReplacement(StringBuffer, String)} requirements.
-     * 
+     *
      * @param src
      *            The original string.
      * @return The sanitized string.

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303MetaBeanFactory.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303MetaBeanFactory.java?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303MetaBeanFactory.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303MetaBeanFactory.java Fri Sep  3 21:48:14 2010
@@ -14,7 +14,7 @@
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License.    
+ * under the License.
  */
 package org.apache.bval.jsr303;
 
@@ -32,8 +32,8 @@ import org.apache.bval.model.MetaPropert
 import org.apache.bval.util.AccessStrategy;
 import org.apache.bval.util.FieldAccess;
 import org.apache.bval.util.MethodAccess;
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.ClassUtils;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.ClassUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -97,7 +97,7 @@ public class Jsr303MetaBeanFactory imple
                 processClass(eachClass, metabean);
                 processGroupSequence(eachClass, metabean, "{GroupSequence:"+eachClass.getCanonicalName()+"}");
             }
-            
+
         } catch (IllegalAccessException e) {
             throw new IllegalArgumentException(e);
         } catch (InvocationTargetException e) {
@@ -114,10 +114,10 @@ public class Jsr303MetaBeanFactory imple
      */
     private void processClass(Class<?> beanClass, MetaBean metabean)
           throws IllegalAccessException, InvocationTargetException {
-        
+
         // if NOT ignore class level annotations
         if (!factoryContext.getFactory().getAnnotationIgnores()
-              .isIgnoreAnnotations(beanClass)) { 
+              .isIgnoreAnnotations(beanClass)) {
             processAnnotations(null, beanClass, beanClass, null,
                   new AppendValidationToMeta(metabean));
         }
@@ -194,7 +194,7 @@ public class Jsr303MetaBeanFactory imple
             return true;
         }
         boolean ret = false;
-        
+
         // Check in case it is a multivalued constraint
         Object value = null;
         try {
@@ -204,7 +204,7 @@ public class Jsr303MetaBeanFactory imple
         } catch (InvocationTargetException e) {
             // Swallow it
         }
-        
+
         if ( value instanceof Annotation[] ) {
             for (Annotation annot2 : (Annotation[])value ) {
                 if ( true == (ret = hasValidationConstraintsDefined(annot2)) ) {
@@ -212,7 +212,7 @@ public class Jsr303MetaBeanFactory imple
                 }
             }
         }
-        
+
         return ret;
     }
 
@@ -369,7 +369,7 @@ public class Jsr303MetaBeanFactory imple
     private void processGroupSequence(Class<?> beanClass, MetaBean metabean) {
         processGroupSequence(beanClass, metabean, Jsr303Features.Bean.GROUP_SEQUENCE);
     }
-    
+
     private void processGroupSequence(Class<?> beanClass, MetaBean metabean, String key) {
         GroupSequence annotation = beanClass.getAnnotation(GroupSequence.class);
         List<Group> groupSeq = metabean.getFeature(key);
@@ -487,11 +487,11 @@ public class Jsr303MetaBeanFactory imple
             builder.getConstraintValidation().setGroups(avb.getInheritedGroups());
             builder.getConstraintValidation().setPayload(avb.getInheritedPayload());
         }
-        
+
         // process composed constraints:
         // here are not other superclasses possible, because annotations do not inherit!
         processAnnotations(prop, owner, annotation.annotationType(), access, new AppendValidationToBuilder(builder));
-        
+
         // Even if the validator is null, it must be added to mimic the RI impl
         appender.append(builder.getConstraintValidation());
         return true;

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/NestedMetaProperty.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/NestedMetaProperty.java?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/NestedMetaProperty.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/NestedMetaProperty.java Fri Sep  3 21:48:14 2010
@@ -14,15 +14,16 @@
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License.    
+ * under the License.
  */
 package org.apache.bval.jsr303;
 
 
+import org.apache.bval.jsr303.util.NestedPathNavigator;
 import org.apache.bval.model.MetaBean;
 import org.apache.bval.model.MetaProperty;
 import org.apache.bval.util.PropertyAccess;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 
 import javax.validation.ValidationException;
 import java.lang.reflect.*;
@@ -30,6 +31,7 @@ import java.util.*;
 
 /**
  * Description: handle nested property paths <br/>
+ * @deprecated in favor of {@link NestedPathNavigator}
  */
 final class NestedMetaProperty {
     private MetaBean metaBean;

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorImpl.java?rev=992489&r1=992488&r2=992489&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorImpl.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorImpl.java Fri Sep  3 21:48:14 2010
@@ -37,291 +37,287 @@ import java.util.Set;
  * Description: experimental implementation of method-level-validation <br/>
  */
 class MethodValidatorImpl extends ClassValidator implements MethodValidator {
-  /**
-   * Create a new MethodValidatorImpl instance.
-   * @param factoryContext
-   */
-  public MethodValidatorImpl(ApacheFactoryContext factoryContext) {
-    super(factoryContext);
-    patchFactoryContextForMethodValidation(factoryContext);
-  }
-
-  /**
-   * experimental: replace the Jsr303MetaBeanFactory with a MethodValidatorMetaBeanFactory in the factoryContext.
-   * @param factoryContext
-   */
-  private void patchFactoryContextForMethodValidation(ApacheFactoryContext factoryContext) {
-    MetaBeanFactory[] factories = ((MetaBeanManager) getMetaBeanFinder()).getBuilder().getFactories();
-    for (int i = 0; i < factories.length; i++) {
-      if (factories[i] instanceof Jsr303MetaBeanFactory && !(factories[i] instanceof MethodValidatorMetaBeanFactory)) {
-        factories[i] = new MethodValidatorMetaBeanFactory(factoryContext);
-      }
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  protected BeanDescriptorImpl createBeanDescriptor(MetaBean metaBean) {
-    MethodBeanDescriptorImpl descriptor = new MethodBeanDescriptorImpl(factoryContext,
-        metaBean, metaBean.getValidations());
-    MethodValidatorMetaBeanFactory factory =
-        new MethodValidatorMetaBeanFactory(factoryContext);
-    factory.buildMethodDescriptor(descriptor);
-    return descriptor;
-  }
-
-  /**
-   * {@inheritDoc}
-   * enhancement: method-level-validation not yet completly implemented
-   * <pre>example:
-   * <code>
-   * public @NotNull String saveItem(@Valid @NotNull Item item, @Max(23) BigDecimal
-   * </code></pre>
-   * spec:
-   * The constraints declarations evaluated are the constraints hosted on the
-   * parameters of the method or constructor. If @Valid is placed on a parameter,
-   * constraints declared on the object itself are considered.
-   *
-   * @throws IllegalArgumentException enhancement: if the method does not belong to <code>T</code>
-   *                                  or if the Object[] does not match the method signature
-   */
-  public <T> Set<ConstraintViolation<T>> validateParameters(Class<T> clazz, Method method,
-                                                            Object[] parameters,
-                                                            Class<?>... groupArray) {
-    MethodBeanDescriptorImpl beanDesc =
-        (MethodBeanDescriptorImpl) getConstraintsForClass(clazz);
-    MethodDescriptorImpl methodDescriptor =
-        (MethodDescriptorImpl) beanDesc.getConstraintsForMethod(method);
-    if ( methodDescriptor == null ) {
-        throw new ValidationException("Method " + method + " doesn't belong to class " + clazz);
-    }
-    return validateParameters(methodDescriptor.getMetaBean(),
-        methodDescriptor.getParameterDescriptors(), parameters, groupArray);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public <T> Set<ConstraintViolation<T>> validateParameter(Class<T> clazz, Method method,
-                                                           Object parameter,
-                                                           int parameterIndex,
-                                                           Class<?>... groupArray) {
-    MethodBeanDescriptorImpl beanDesc =
-        (MethodBeanDescriptorImpl) getConstraintsForClass(clazz);
-    MethodDescriptorImpl methodDescriptor =
-        (MethodDescriptorImpl) beanDesc.getConstraintsForMethod(method);
-    if ( methodDescriptor == null ) {
-        throw new ValidationException("Method " + method + " doesn't belong to class " + clazz);
-    }
-    ParameterDescriptorImpl paramDesc = (ParameterDescriptorImpl) methodDescriptor
-        .getParameterDescriptors().get(parameterIndex);
-    return validateParameter(paramDesc, parameter, groupArray);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public <T> Set<ConstraintViolation<T>> validateParameters(Class<T> clazz,
-                                                            Constructor<T> constructor,
-                                                            Object[] parameters,
-                                                            Class<?>... groupArray) {
-    MethodBeanDescriptorImpl beanDesc =
-        (MethodBeanDescriptorImpl) getConstraintsForClass(clazz);
-    ConstructorDescriptorImpl constructorDescriptor =
-        (ConstructorDescriptorImpl) beanDesc.getConstraintsForConstructor(constructor);
-    if ( constructorDescriptor == null ) {
-        throw new ValidationException("Constructor " + constructor + " doesn't belong to class " + clazz);
-    }
-    return validateParameters(constructorDescriptor.getMetaBean(),
-        constructorDescriptor.getParameterDescriptors(), parameters, groupArray);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public <T> Set<ConstraintViolation<T>> validateParameter(Class<T> clazz,
-                                                           Constructor<T> constructor,
-                                                           Object parameter,
-                                                           int parameterIndex,
-                                                           Class<?>... groupArray) {
-    MethodBeanDescriptorImpl beanDesc =
-        (MethodBeanDescriptorImpl) getConstraintsForClass(clazz);
-    ConstructorDescriptorImpl constructorDescriptor =
-        (ConstructorDescriptorImpl) beanDesc.getConstraintsForConstructor(constructor);
-    if ( constructorDescriptor == null ) {
-        throw new ValidationException("Constructor " + constructor + " doesn't belong to class " + clazz);
-    }
-    ParameterDescriptorImpl paramDesc = (ParameterDescriptorImpl) constructorDescriptor
-        .getParameterDescriptors().get(parameterIndex);
-    return validateParameter(paramDesc, parameter, groupArray);
-  }
-
-  /**
-   * {@inheritDoc}
-   * If @Valid  is placed on the method, the constraints declared on the object
-   * itself are considered.
-   */
-  @SuppressWarnings("unchecked")
-  public <T> Set<ConstraintViolation<T>> validateReturnedValue(Class<T> clazz, Method method,
-                                                               Object returnedValue,
-                                                               Class<?>... groupArray) {
-    MethodBeanDescriptorImpl beanDesc =
-        (MethodBeanDescriptorImpl) getConstraintsForClass(clazz);
-    MethodDescriptorImpl methodDescriptor =
-        (MethodDescriptorImpl) beanDesc.getConstraintsForMethod(method);
-    if ( methodDescriptor == null ) {
-        throw new ValidationException("Method " + method + " doesn't belong to class " + clazz);
-    }
-    final GroupValidationContext<Object> context =
-        createContext(methodDescriptor.getMetaBean(), returnedValue, null, groupArray);
-    validateReturnedValueInContext(context, methodDescriptor);
-    ConstraintValidationListener<T> result = (ConstraintValidationListener<T>) context.getListener();
-    return result.getConstraintViolations();
-  }
-
-  @SuppressWarnings("unchecked")
-  private <T> Set<ConstraintViolation<T>> validateParameters(MetaBean metaBean,
-                                                             List<ParameterDescriptor> paramDescriptors,
-                                                             Object[] parameters,
-                                                             Class<?>... groupArray) {
-    if (parameters == null) throw new IllegalArgumentException("cannot validate null");
-    if (parameters.length > 0) {
-      try {
-        GroupValidationContext<ConstraintValidationListener<Object[]>> context =
-            createContext(metaBean, null, null, groupArray);
-        for (int i = 0; i < parameters.length; i++) {
-          ParameterDescriptorImpl paramDesc =
-              (ParameterDescriptorImpl) paramDescriptors.get(i);
-          context.setBean(parameters[i]);
-          validateParameterInContext(context, paramDesc);
+    /**
+     * Create a new MethodValidatorImpl instance.
+     * 
+     * @param factoryContext
+     */
+    public MethodValidatorImpl(ApacheFactoryContext factoryContext) {
+        super(factoryContext);
+        patchFactoryContextForMethodValidation(factoryContext);
+    }
+
+    /**
+     * experimental: replace the Jsr303MetaBeanFactory with a
+     * MethodValidatorMetaBeanFactory in the factoryContext.
+     * 
+     * @param factoryContext
+     */
+    private void patchFactoryContextForMethodValidation(ApacheFactoryContext factoryContext) {
+        MetaBeanFactory[] factories = ((MetaBeanManager) getMetaBeanFinder()).getBuilder().getFactories();
+        for (int i = 0; i < factories.length; i++) {
+            if (factories[i] instanceof Jsr303MetaBeanFactory
+                && !(factories[i] instanceof MethodValidatorMetaBeanFactory)) {
+                factories[i] = new MethodValidatorMetaBeanFactory(factoryContext);
+            }
         }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected BeanDescriptorImpl createBeanDescriptor(MetaBean metaBean) {
+        MethodBeanDescriptorImpl descriptor =
+            new MethodBeanDescriptorImpl(factoryContext, metaBean, metaBean.getValidations());
+        MethodValidatorMetaBeanFactory factory = new MethodValidatorMetaBeanFactory(factoryContext);
+        factory.buildMethodDescriptor(descriptor);
+        return descriptor;
+    }
+
+    /**
+     * {@inheritDoc} enhancement: method-level-validation not yet completly
+     * implemented
+     * 
+     * <pre>
+     * example:
+     * <code>
+     * public @NotNull String saveItem(@Valid @NotNull Item item, @Max(23) BigDecimal
+     * </code>
+     * </pre>
+     * 
+     * spec: The constraints declarations evaluated are the constraints hosted
+     * on the parameters of the method or constructor. If @Valid is placed on a
+     * parameter, constraints declared on the object itself are considered.
+     * 
+     * @throws IllegalArgumentException
+     *             enhancement: if the method does not belong to <code>T</code>
+     *             or if the Object[] does not match the method signature
+     */
+    public <T> Set<ConstraintViolation<T>> validateParameters(Class<T> clazz, Method method, Object[] parameters,
+        Class<?>... groupArray) {
+        MethodBeanDescriptorImpl beanDesc = (MethodBeanDescriptorImpl) getConstraintsForClass(clazz);
+        MethodDescriptorImpl methodDescriptor = (MethodDescriptorImpl) beanDesc.getConstraintsForMethod(method);
+        if (methodDescriptor == null) {
+            throw new ValidationException("Method " + method + " doesn't belong to class " + clazz);
+        }
+        return validateParameters(methodDescriptor.getMetaBean(), methodDescriptor.getParameterDescriptors(),
+            parameters, groupArray);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public <T> Set<ConstraintViolation<T>> validateParameter(Class<T> clazz, Method method, Object parameter,
+        int parameterIndex, Class<?>... groupArray) {
+        MethodBeanDescriptorImpl beanDesc = (MethodBeanDescriptorImpl) getConstraintsForClass(clazz);
+        MethodDescriptorImpl methodDescriptor = (MethodDescriptorImpl) beanDesc.getConstraintsForMethod(method);
+        if (methodDescriptor == null) {
+            throw new ValidationException("Method " + method + " doesn't belong to class " + clazz);
+        }
+        ParameterDescriptorImpl paramDesc =
+            (ParameterDescriptorImpl) methodDescriptor.getParameterDescriptors().get(parameterIndex);
+        return validateParameter(paramDesc, parameter, groupArray);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public <T> Set<ConstraintViolation<T>> validateParameters(Class<T> clazz, Constructor<T> constructor,
+        Object[] parameters, Class<?>... groupArray) {
+        MethodBeanDescriptorImpl beanDesc = (MethodBeanDescriptorImpl) getConstraintsForClass(clazz);
+        ConstructorDescriptorImpl constructorDescriptor =
+            (ConstructorDescriptorImpl) beanDesc.getConstraintsForConstructor(constructor);
+        if (constructorDescriptor == null) {
+            throw new ValidationException("Constructor " + constructor + " doesn't belong to class " + clazz);
+        }
+        return validateParameters(constructorDescriptor.getMetaBean(), constructorDescriptor.getParameterDescriptors(),
+            parameters, groupArray);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public <T> Set<ConstraintViolation<T>> validateParameter(Class<T> clazz, Constructor<T> constructor,
+        Object parameter, int parameterIndex, Class<?>... groupArray) {
+        MethodBeanDescriptorImpl beanDesc = (MethodBeanDescriptorImpl) getConstraintsForClass(clazz);
+        ConstructorDescriptorImpl constructorDescriptor =
+            (ConstructorDescriptorImpl) beanDesc.getConstraintsForConstructor(constructor);
+        if (constructorDescriptor == null) {
+            throw new ValidationException("Constructor " + constructor + " doesn't belong to class " + clazz);
+        }
+        ParameterDescriptorImpl paramDesc =
+            (ParameterDescriptorImpl) constructorDescriptor.getParameterDescriptors().get(parameterIndex);
+        return validateParameter(paramDesc, parameter, groupArray);
+    }
+
+    /**
+     * {@inheritDoc} If @Valid is placed on the method, the constraints declared
+     * on the object itself are considered.
+     */
+    @SuppressWarnings("unchecked")
+    public <T> Set<ConstraintViolation<T>> validateReturnedValue(Class<T> clazz, Method method, Object returnedValue,
+        Class<?>... groupArray) {
+        MethodBeanDescriptorImpl beanDesc = (MethodBeanDescriptorImpl) getConstraintsForClass(clazz);
+        MethodDescriptorImpl methodDescriptor = (MethodDescriptorImpl) beanDesc.getConstraintsForMethod(method);
+        if (methodDescriptor == null) {
+            throw new ValidationException("Method " + method + " doesn't belong to class " + clazz);
+        }
+        final GroupValidationContext<Object> context =
+            createContext(methodDescriptor.getMetaBean(), returnedValue, null, groupArray);
+        validateReturnedValueInContext(context, methodDescriptor);
         ConstraintValidationListener<T> result = (ConstraintValidationListener<T>) context.getListener();
         return result.getConstraintViolations();
-      } catch (RuntimeException ex) {
-        throw unrecoverableValidationError(ex, parameters);
-      }
-    } else {
-      return Collections.<ConstraintViolation<T>> emptySet();
-    }
-  }
-
-  @SuppressWarnings("unchecked")
-  private <T> Set<ConstraintViolation<T>> validateParameter(
-      ParameterDescriptorImpl paramDesc, Object parameter, Class<?>... groupArray) {
-    try {
-      final GroupValidationContext<Object> context =
-          createContext(paramDesc.getMetaBean(), parameter, null, groupArray);
-      final ConstraintValidationListener<T> result = (ConstraintValidationListener<T>) context.getListener();
-      validateParameterInContext(context, paramDesc);
-      return result.getConstraintViolations();
-    } catch (RuntimeException ex) {
-      throw unrecoverableValidationError(ex, parameter);
-    }
-  }
-
-  /**
-   * validate constraints hosted on parameters of a method
-   */
-  private <T> void validateParameterInContext(
-      GroupValidationContext<T> context,
-      ParameterDescriptorImpl paramDesc) {
-
-    final Groups groups = context.getGroups();
-
-    for (ConstraintDescriptor<?> consDesc : paramDesc.getConstraintDescriptors()) {
-      ConstraintValidation<?> validation = (ConstraintValidation<?>) consDesc;
-      // 1. process groups
-      for (Group current : groups.getGroups()) {
-        context.setCurrentGroup(current);
-        validation.validate(context);
-      }
-      // 2. process sequences
-      for (List<Group> eachSeq : groups.getSequences()) {
-        for (Group current : eachSeq) {
-          context.setCurrentGroup(current);
-          validation.validate(context);
-          /**
-           * if one of the group process in the sequence leads to one or more validation failure,
-           * the groups following in the sequence must not be processed
-           */
-          if (!context.getListener().isEmpty()) break;
-        }
-      }
-    }
-    if (paramDesc.isCascaded() && context.getValidatedValue() != null) {
-      context.setMetaBean(factoryContext.getMetaBeanFinder().
-          findForClass(context.getValidatedValue().getClass()));
-      // 1. process groups
-      for (Group current : groups.getGroups()) {
-        context.setCurrentGroup(current);
-        ValidationHelper.validateContext(context, new Jsr303ValidationCallback(context), isTreatMapsLikeBeans());
-      }
-      // 2. process sequences
-      for (List<Group> eachSeq : groups.getSequences()) {
-        for (Group current : eachSeq) {
-          context.setCurrentGroup(current);
-          ValidationHelper.validateContext(context, new Jsr303ValidationCallback(context), isTreatMapsLikeBeans());
-          /**
-           * if one of the group process in the sequence leads to one or more validation failure,
-           * the groups following in the sequence must not be processed
-           */
-          if (!context.getListener().isEmpty()) break;
-        }
-      }
-    }
-  }
-
-  /**
-   * validate constraints hosted on parameters of a method
-   */
-  private <T> void validateReturnedValueInContext(
-      GroupValidationContext<T> context,
-      MethodDescriptorImpl methodDescriptor) {
-
-    final Groups groups = context.getGroups();
-
-    for (ConstraintDescriptor<?> consDesc : methodDescriptor.getConstraintDescriptors()) {
-      ConstraintValidation<?> validation = (ConstraintValidation<?>) consDesc;
-      // 1. process groups
-      for (Group current : groups.getGroups()) {
-        context.setCurrentGroup(current);
-        validation.validate(context);
-      }
-      // 2. process sequences
-      for (List<Group> eachSeq : groups.getSequences()) {
-        for (Group current : eachSeq) {
-          context.setCurrentGroup(current);
-          validation.validate(context);
-          /**
-           * if one of the group process in the sequence leads to one or more validation failure,
-           * the groups following in the sequence must not be processed
-           */
-          if (!context.getListener().isEmpty()) break;
-        }
-      }
-    }
-    if (methodDescriptor.isCascaded() && context.getValidatedValue() != null) {
-      context.setMetaBean(factoryContext.getMetaBeanFinder().
-          findForClass(context.getValidatedValue().getClass()));
-      // 1. process groups
-      for (Group current : groups.getGroups()) {
-        context.setCurrentGroup(current);
-        ValidationHelper.validateContext(context, new Jsr303ValidationCallback(context), isTreatMapsLikeBeans());
-      }
-      // 2. process sequences
-      for (List<Group> eachSeq : groups.getSequences()) {
-        for (Group current : eachSeq) {
-          context.setCurrentGroup(current);
-          ValidationHelper.validateContext(context, new Jsr303ValidationCallback(context), isTreatMapsLikeBeans());
-          /**
-           * if one of the group process in the sequence leads to one or more validation failure,
-           * the groups following in the sequence must not be processed
-           */
-          if (!context.getListener().isEmpty()) break;
+    }
+
+    @SuppressWarnings("unchecked")
+    private <T> Set<ConstraintViolation<T>> validateParameters(MetaBean metaBean,
+        List<ParameterDescriptor> paramDescriptors, Object[] parameters, Class<?>... groupArray) {
+        if (parameters == null)
+            throw new IllegalArgumentException("cannot validate null");
+        if (parameters.length > 0) {
+            try {
+                GroupValidationContext<ConstraintValidationListener<Object[]>> context =
+                    createContext(metaBean, null, null, groupArray);
+                for (int i = 0; i < parameters.length; i++) {
+                    ParameterDescriptorImpl paramDesc = (ParameterDescriptorImpl) paramDescriptors.get(i);
+                    context.setBean(parameters[i]);
+                    validateParameterInContext(context, paramDesc);
+                }
+                ConstraintValidationListener<T> result = (ConstraintValidationListener<T>) context.getListener();
+                return result.getConstraintViolations();
+            } catch (RuntimeException ex) {
+                throw unrecoverableValidationError(ex, parameters);
+            }
+        } else {
+            return Collections.<ConstraintViolation<T>> emptySet();
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private <T> Set<ConstraintViolation<T>> validateParameter(ParameterDescriptorImpl paramDesc, Object parameter,
+        Class<?>... groupArray) {
+        try {
+            final GroupValidationContext<Object> context =
+                createContext(paramDesc.getMetaBean(), parameter, null, groupArray);
+            final ConstraintValidationListener<T> result = (ConstraintValidationListener<T>) context.getListener();
+            validateParameterInContext(context, paramDesc);
+            return result.getConstraintViolations();
+        } catch (RuntimeException ex) {
+            throw unrecoverableValidationError(ex, parameter);
+        }
+    }
+
+    /**
+     * validate constraints hosted on parameters of a method
+     */
+    private <T> void validateParameterInContext(GroupValidationContext<T> context, ParameterDescriptorImpl paramDesc) {
+
+        final Groups groups = context.getGroups();
+
+        for (ConstraintDescriptor<?> consDesc : paramDesc.getConstraintDescriptors()) {
+            ConstraintValidation<?> validation = (ConstraintValidation<?>) consDesc;
+            // 1. process groups
+            for (Group current : groups.getGroups()) {
+                context.setCurrentGroup(current);
+                validation.validate(context);
+            }
+            // 2. process sequences
+            for (List<Group> eachSeq : groups.getSequences()) {
+                for (Group current : eachSeq) {
+                    context.setCurrentGroup(current);
+                    validation.validate(context);
+                    /**
+                     * if one of the group process in the sequence leads to one
+                     * or more validation failure, the groups following in the
+                     * sequence must not be processed
+                     */
+                    if (!context.getListener().isEmpty())
+                        break;
+                }
+            }
+        }
+        if (paramDesc.isCascaded() && context.getValidatedValue() != null) {
+            context
+                .setMetaBean(factoryContext.getMetaBeanFinder().findForClass(context.getValidatedValue().getClass()));
+            // 1. process groups
+            for (Group current : groups.getGroups()) {
+                context.setCurrentGroup(current);
+                ValidationHelper
+                    .validateContext(context, new Jsr303ValidationCallback(context), isTreatMapsLikeBeans());
+            }
+            // 2. process sequences
+            for (List<Group> eachSeq : groups.getSequences()) {
+                for (Group current : eachSeq) {
+                    context.setCurrentGroup(current);
+                    ValidationHelper.validateContext(context, new Jsr303ValidationCallback(context),
+                        isTreatMapsLikeBeans());
+                    /**
+                     * if one of the group process in the sequence leads to one
+                     * or more validation failure, the groups following in the
+                     * sequence must not be processed
+                     */
+                    if (!context.getListener().isEmpty())
+                        break;
+                }
+            }
+        }
+    }
+
+    /**
+     * validate constraints hosted on parameters of a method
+     */
+    private <T> void validateReturnedValueInContext(GroupValidationContext<T> context,
+        MethodDescriptorImpl methodDescriptor) {
+
+        final Groups groups = context.getGroups();
+
+        for (ConstraintDescriptor<?> consDesc : methodDescriptor.getConstraintDescriptors()) {
+            ConstraintValidation<?> validation = (ConstraintValidation<?>) consDesc;
+            // 1. process groups
+            for (Group current : groups.getGroups()) {
+                context.setCurrentGroup(current);
+                validation.validate(context);
+            }
+            // 2. process sequences
+            for (List<Group> eachSeq : groups.getSequences()) {
+                for (Group current : eachSeq) {
+                    context.setCurrentGroup(current);
+                    validation.validate(context);
+                    /**
+                     * if one of the group process in the sequence leads to one
+                     * or more validation failure, the groups following in the
+                     * sequence must not be processed
+                     */
+                    if (!context.getListener().isEmpty())
+                        break;
+                }
+            }
+        }
+        if (methodDescriptor.isCascaded() && context.getValidatedValue() != null) {
+            context
+                .setMetaBean(factoryContext.getMetaBeanFinder().findForClass(context.getValidatedValue().getClass()));
+            // 1. process groups
+            for (Group current : groups.getGroups()) {
+                context.setCurrentGroup(current);
+                ValidationHelper
+                    .validateContext(context, new Jsr303ValidationCallback(context), isTreatMapsLikeBeans());
+            }
+            // 2. process sequences
+            for (List<Group> eachSeq : groups.getSequences()) {
+                for (Group current : eachSeq) {
+                    context.setCurrentGroup(current);
+                    ValidationHelper.validateContext(context, new Jsr303ValidationCallback(context),
+                        isTreatMapsLikeBeans());
+                    /**
+                     * if one of the group process in the sequence leads to one
+                     * or more validation failure, the groups following in the
+                     * sequence must not be processed
+                     */
+                    if (!context.getListener().isEmpty())
+                        break;
+                }
+            }
         }
-      }
     }
-  }
 }



Mime
View raw message