bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1498347 [4/7] - in /bval/branches/bval-11: ./ bval-core/src/main/java/org/apache/bval/ bval-core/src/main/java/org/apache/bval/model/ bval-core/src/main/java/org/apache/bval/util/ bval-extras/ bval-guice/ bval-guice/src/main/java/org/apach...
Date Mon, 01 Jul 2013 10:06:21 GMT
Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultConstraintValidatorFactory.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultConstraintValidatorFactory.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultConstraintValidatorFactory.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultConstraintValidatorFactory.java Mon Jul  1 10:06:18 2013
@@ -18,15 +18,22 @@
  */
 package org.apache.bval.jsr303;
 
+import org.apache.bval.cdi.BValExtension;
+
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorFactory;
 import javax.validation.ValidationException;
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 
 /**
  * Description: create constraint instances with the default / no-arg constructor <br/>
  */
-public class DefaultConstraintValidatorFactory implements ConstraintValidatorFactory {
+public class DefaultConstraintValidatorFactory implements ConstraintValidatorFactory, Closeable {
+    private final Collection< BValExtension.Releasable<?>> releasables = new CopyOnWriteArrayList<BValExtension.Releasable<?>>();
 
     /**
      * Instantiate a Constraint.
@@ -34,17 +41,32 @@ public class DefaultConstraintValidatorF
      * @return Returns a new Constraint instance
      *         The ConstraintFactory is <b>not</b> responsible for calling Constraint#initialize
      */
-    public <T extends ConstraintValidator<?, ?>> T getInstance(final Class<T> constraintClass)
-    {
-      // 2011-03-27 jw: Do not use PrivilegedAction.
-      // Otherwise any user code would be executed with the privileges of this class.
-      try
-      {
-        return constraintClass.newInstance();
-      }
-      catch (final Exception ex)
-      {
-        throw new ValidationException("Cannot instantiate : " + constraintClass, ex);
-      }
+    public <T extends ConstraintValidator<?, ?>> T getInstance(final Class<T> constraintClass) {
+        // 2011-03-27 jw: Do not use PrivilegedAction.
+        // Otherwise any user code would be executed with the privileges of this class.
+        try {
+            try {
+                return BValExtension.inject(constraintClass).getInstance();
+            } catch (final Exception e) {
+                return constraintClass.newInstance();
+            } catch (final NoClassDefFoundError error) {
+                return constraintClass.newInstance();
+            }
+        } catch (final Exception ex) {
+            throw new ValidationException("Cannot instantiate : " + constraintClass, ex);
+        }
+    }
+
+    public void releaseInstance(final ConstraintValidator<?, ?> instance) {
+        // no-op
+    }
+
+    public void close() throws IOException {
+        for (final BValExtension.Releasable<?> releasable : releasables) {
+            // ensure to call this callback
+            releaseInstance(ConstraintValidator.class.cast(releasable.getInstance()));
+            releasable.release();
+        }
+        releasables.clear();
     }
 }

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultMessageInterpolator.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultMessageInterpolator.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultMessageInterpolator.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultMessageInterpolator.java Mon Jul  1 10:06:18 2013
@@ -16,8 +16,32 @@
  */
 package org.apache.bval.jsr303;
 
+import org.apache.bval.jsr303.util.SecureActions;
+import org.apache.commons.lang3.ArrayUtils;
+
+import javax.el.ArrayELResolver;
+import javax.el.BeanELResolver;
+import javax.el.CompositeELResolver;
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.FunctionMapper;
+import javax.el.ListELResolver;
+import javax.el.MapELResolver;
+import javax.el.MethodNotFoundException;
+import javax.el.PropertyNotWritableException;
+import javax.el.ResourceBundleELResolver;
+import javax.el.ValueExpression;
+import javax.el.VariableMapper;
+import javax.validation.MessageInterpolator;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.Formatter;
+import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 import java.util.MissingResourceException;
@@ -28,11 +52,6 @@ import java.util.logging.Logger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import javax.validation.MessageInterpolator;
-
-import org.apache.bval.jsr303.util.SecureActions;
-import org.apache.commons.lang3.ArrayUtils;
-
 /**
  * Description: Resource bundle backed message interpolator.
  * This message resolver resolve message descriptors
@@ -40,14 +59,23 @@ import org.apache.commons.lang3.ArrayUti
  * This class is threadsafe.<br/>
  */
 public class DefaultMessageInterpolator implements MessageInterpolator {
+    private static final ExpressionFactory EXPRESSION_FACTORY;
+    static {
+        ExpressionFactory ef;
+        try {
+            ef = ExpressionFactory.newInstance();
+        } catch (final Exception e) {
+            ef = null;
+        }
+        EXPRESSION_FACTORY = ef;
+    }
+
     private static final Logger log = Logger.getLogger(DefaultMessageInterpolator.class.getName());
-    private static final String DEFAULT_VALIDATION_MESSAGES =
-          "org.apache.bval.jsr303.ValidationMessages";
+    private static final String DEFAULT_VALIDATION_MESSAGES = "org.apache.bval.jsr303.ValidationMessages";
     private static final String USER_VALIDATION_MESSAGES = "ValidationMessages";
 
     /** Regular expression used to do message interpolation. */
-    private static final Pattern messageParameterPattern =
-          Pattern.compile("(\\{[\\w\\.]+\\})");
+    private static final Pattern messageParameterPattern = Pattern.compile("(\\{[\\w\\.]+\\})");
 
     /** The default locale for the current user. */
     private Locale defaultLocale;
@@ -57,8 +85,7 @@ public class DefaultMessageInterpolator 
           new ConcurrentHashMap<Locale, ResourceBundle>();
 
     /** Builtin resource bundles hashed against their locale. */
-    private final Map<Locale, ResourceBundle> defaultBundlesMap =
-          new ConcurrentHashMap<Locale, ResourceBundle>();
+    private final Map<Locale, ResourceBundle> defaultBundlesMap = new ConcurrentHashMap<Locale, ResourceBundle>();
 
     /**
      * Create a new DefaultMessageInterpolator instance.
@@ -72,7 +99,6 @@ public class DefaultMessageInterpolator 
      * @param resourceBundle
      */
     public DefaultMessageInterpolator(ResourceBundle resourceBundle) {
-
         defaultLocale = Locale.getDefault();
 
         if (resourceBundle == null) {
@@ -89,6 +115,121 @@ public class DefaultMessageInterpolator 
               ResourceBundle.getBundle(DEFAULT_VALIDATION_MESSAGES, defaultLocale));
     }
 
+    private static ELResolver initResolver() {
+        final CompositeELResolver resolver = new CompositeELResolver();
+        resolver.add(new MapELResolver());
+        resolver.add(new ListELResolver());
+        resolver.add(new ArrayELResolver());
+        resolver.add(new ResourceBundleELResolver());
+        resolver.add(new BeanELResolver() {
+            @Override // patched because G l API contains a bug with array used by formatter usage, when fixed just update the API and remove this method
+            public Object invoke(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] params) {
+                if (context == null) {
+                    throw new NullPointerException("ELContext could not be nulll");
+                }
+                // Why static invocation is not supported
+                if(base == null || method == null) {
+                    return null;
+                }
+                if (params == null) {
+                    params = new Object[0];
+                }
+                String methodName = (String) EXPRESSION_FACTORY.coerceToType(method, String.class);
+                if (methodName.length() == 0) {
+                    throw new MethodNotFoundException("The parameter method could not be zero-length");
+                }
+                Class<?> targetClass = base.getClass();
+                if (methodName.equals("<init>") || methodName.equals("<cinit>")) {
+                    throw new MethodNotFoundException(method + " is not found in target class " + targetClass.getName());
+                }
+                Method targetMethod = null;
+                if (paramTypes == null) {
+                    int paramsNumber = params.length;
+                    for (final Method m : targetClass.getMethods()) {
+                        if (m.getName().equals(methodName) && m.getParameterTypes().length == paramsNumber) {
+                            targetMethod = m;
+                            break;
+                        }
+                    }
+                    if (targetMethod == null) {
+                        for (final Method m : targetClass.getMethods()) {
+                            if (m.getName().equals(methodName) && m.isVarArgs() && paramsNumber >= (m.getParameterTypes().length - 1)) {
+                                targetMethod = m;
+                                break;
+                            }
+                        }
+                    }
+                } else {
+                    try {
+                        targetMethod = targetClass.getMethod(methodName, paramTypes);
+                    } catch (SecurityException e) {
+                        throw new ELException(e);
+                    } catch (NoSuchMethodException e) {
+                        throw new MethodNotFoundException(e);
+                    }
+                }
+                if (targetMethod == null) {
+                    throw new MethodNotFoundException(method + " is not found in target class " + targetClass.getName());
+                }
+                if (paramTypes == null) {
+                    paramTypes = targetMethod.getParameterTypes();
+                }
+                //Initial check whether the types and parameter values length
+                if (targetMethod.isVarArgs()) {
+                    if (paramTypes.length - 1 > params.length) {
+                        throw new IllegalArgumentException("Inconsistent number between argument types and values");
+                    }
+                } else if (paramTypes.length != params.length) {
+                    throw new IllegalArgumentException("Inconsistent number between argument types and values");
+                }
+                try {
+                    Object[] finalParamValues = new Object[paramTypes.length];
+                    //Only do the parameter conversion while the method is not a non-parameter one
+                    if (paramTypes.length > 0) {
+                        int iCurrentIndex = 0;
+                        for (int iLoopSize = paramTypes.length - 1; iCurrentIndex < iLoopSize; iCurrentIndex++) {
+                            finalParamValues[iCurrentIndex] = EXPRESSION_FACTORY.coerceToType(params[iCurrentIndex], paramTypes[iCurrentIndex]);
+                        }
+                        /**
+                         * Not sure it is over-designed. Do not find detailed description about how the parameter values are passed if the method is of variable arguments.
+                         * It might be an array directly passed or each parameter value passed one by one.
+                         */
+                        if (targetMethod.isVarArgs()) {
+                            // varArgsClassType should be an array type
+                            Class<?> varArgsClassType = paramTypes[iCurrentIndex];
+                            // 1. If there is no parameter value left for the variable argument, create a zero-length array
+                            // 2. If there is only one parameter value left for the variable argument, and it has the same array type with the varArgsClass, pass in directly
+                            // 3. Else, create an array of varArgsClass type, and add all the left coerced parameter values
+                            if (iCurrentIndex == params.length) {
+                                finalParamValues[iCurrentIndex] = Array.newInstance(varArgsClassType.getComponentType(), 0);
+                            } else if (iCurrentIndex == params.length - 1 && varArgsClassType == params[iCurrentIndex].getClass()
+                                    && varArgsClassType.getClassLoader() == params[iCurrentIndex].getClass().getClassLoader()) {
+                                finalParamValues[iCurrentIndex] = params[iCurrentIndex];
+                            } else {
+                                Object targetArray = Array.newInstance(varArgsClassType.getComponentType(), params.length - iCurrentIndex);
+                                Class<?> componentClassType = varArgsClassType.getComponentType();
+                                for (int i = 0, iLoopSize = params.length - iCurrentIndex; i < iLoopSize; i++) {
+                                    Array.set(targetArray, i, EXPRESSION_FACTORY.coerceToType(params[iCurrentIndex + i], componentClassType));
+                                }
+                                finalParamValues[iCurrentIndex] = targetArray;
+                            }
+                        } else {
+                            finalParamValues[iCurrentIndex] = EXPRESSION_FACTORY.coerceToType(params[iCurrentIndex], paramTypes[iCurrentIndex]);
+                        }
+                    }
+                    Object retValue = targetMethod.invoke(base, finalParamValues);
+                    context.setPropertyResolved(true);
+                    return retValue;
+                }  catch (IllegalAccessException e) {
+                    throw new ELException(e);
+                } catch (InvocationTargetException e) {
+                    throw new ELException(e.getCause());
+                }
+            }
+        });
+        return resolver;
+    }
+
     /** {@inheritDoc} */
     public String interpolate(String message, Context context) {
         // probably no need for caching, but it could be done by parameters since the map
@@ -99,7 +240,7 @@ public class DefaultMessageInterpolator 
     /** {@inheritDoc} */
     public String interpolate(String message, Context context, Locale locale) {
         return interpolateMessage(message,
-              context.getConstraintDescriptor().getAttributes(), locale);
+              context.getConstraintDescriptor().getAttributes(), locale, context.getValidatedValue());
     }
 
     /**
@@ -116,7 +257,7 @@ public class DefaultMessageInterpolator 
      */
     private String interpolateMessage(String message,
                                       Map<String, Object> annotationParameters,
-                                      Locale locale) {
+                                      Locale locale, Object validatedValue) {
         ResourceBundle userResourceBundle = findUserResourceBundle(locale);
         ResourceBundle defaultResourceBundle = findDefaultResourceBundle(locale);
 
@@ -143,11 +284,27 @@ public class DefaultMessageInterpolator 
         } while (true);
 
         // resolve annotation attributes (step 4)
-        resolvedMessage =
-              replaceAnnotationAttributes(resolvedMessage, annotationParameters);
+        resolvedMessage = replaceAnnotationAttributes(resolvedMessage, annotationParameters);
+
+        final ELResolver resolver = initResolver();
+        final BValELContext context = new BValELContext(resolver);
+        final VariableMapper variables = context.getVariableMapper();
+        for (final Map.Entry<String, Object> var : annotationParameters.entrySet()) {
+            variables.setVariable(var.getKey(), new ValueExpressionLiteral(var.getValue()));
+        }
+        variables.setVariable("validatedValue", new ValueExpressionLiteral(validatedValue));
+
+        try {
+            if (EXPRESSION_FACTORY != null) {
+                final String tmp = resolvedMessage.replace("#{", "\\#{"); // shouldn't be evaluated
+                resolvedMessage = EXPRESSION_FACTORY.createValueExpression(context, tmp, String.class).getValue(context).toString();
+            }
+        } catch (final Exception e) {
+            // no-op
+        }
 
         // curly braces need to be scaped in the original msg, so unescape them now
-        resolvedMessage = resolvedMessage.replace( "\\{", "{" ).replace( "\\}", "}" ).replace( "\\\\", "\\" );
+        resolvedMessage = resolvedMessage.replace( "\\{", "{" ).replace( "\\}", "}" ).replace( "\\\\", "\\" ).replace( "\\$", "$" );
 
         return resolvedMessage;
     }
@@ -200,11 +357,11 @@ public class DefaultMessageInterpolator 
 
     private String replaceVariables(String message, ResourceBundle bundle, Locale locale,
                                     boolean recurse) {
-        Matcher matcher = messageParameterPattern.matcher(message);
-        StringBuffer sb = new StringBuffer(64);
+        final Matcher matcher = messageParameterPattern.matcher(message);
+        final StringBuffer sb = new StringBuffer(64);
         String resolvedParameterValue;
         while (matcher.find()) {
-            String parameter = matcher.group(1);
+            final String parameter = matcher.group(1);
             resolvedParameterValue = resolveParameter(parameter, bundle, locale, recurse);
 
             matcher.appendReplacement(sb, sanitizeForAppendReplacement(resolvedParameterValue));
@@ -213,8 +370,8 @@ public class DefaultMessageInterpolator 
         return sb.toString();
     }
 
-    private String replaceAnnotationAttributes(String message,
-                                               Map<String, Object> annotationParameters) {
+    private String replaceAnnotationAttributes(final String message,
+                                               final Map<String, Object> annotationParameters) {
         Matcher matcher = messageParameterPattern.matcher(message);
         StringBuffer sb = new StringBuffer(64);
         while (matcher.find()) {
@@ -243,16 +400,16 @@ public class DefaultMessageInterpolator 
             if (bundle != null) {
                 parameterValue = bundle.getString(removeCurlyBrace(parameterName));
                 if (recurse) {
-                    parameterValue =
-                          replaceVariables(parameterValue, bundle, locale, recurse);
+                    parameterValue = replaceVariables(parameterValue, bundle, locale, recurse);
                 }
             } else {
                 parameterValue = parameterName;
             }
-        } catch (MissingResourceException e) {
+        } catch (final MissingResourceException e) {
             // return parameter itself
             parameterValue = parameterName;
         }
+
         return parameterValue;
     }
 
@@ -320,4 +477,123 @@ public class DefaultMessageInterpolator 
         }
     }
 
+    private static class BValELContext extends ELContext {
+        private final ELResolver resolver;
+        private final FunctionMapper functions;
+        private final VariableMapper variables;
+
+        public BValELContext(final ELResolver resolver) {
+            this.resolver = resolver;
+            this.variables = new BValVariableMapper();
+            this.functions = new BValFunctionMapper();
+        }
+
+        @Override
+        public ELResolver getELResolver() {
+            return resolver;
+        }
+
+        @Override
+        public FunctionMapper getFunctionMapper() {
+            return functions;
+        }
+
+        @Override
+        public VariableMapper getVariableMapper() {
+            return variables;
+        }
+    }
+
+    private static class BValFunctionMapper extends FunctionMapper {
+        @Override
+        public Method resolveFunction(final String prefix, final String localName) {
+            return null;
+        }
+    }
+
+    private static class BValVariableMapper extends VariableMapper {
+        private final Map<String, ValueExpression> variables = new HashMap<String, ValueExpression>();
+
+        @Override
+        public ValueExpression resolveVariable(final String variable) {
+            if ("formatter".equals(variable)) {
+                return new ValueExpressionLiteral(new BValFormatter());
+            }
+            return variables.get(variable);
+        }
+
+        @Override
+        public ValueExpression setVariable(final String variable, final ValueExpression expression) {
+            variables.put(variable, expression);
+            return expression;
+        }
+    }
+
+    // used to not expose all method and avoid ambiguity with format(Local, String, Object...) in EL
+    public static class BValFormatter {
+        private final Formatter formatter = new Formatter();
+
+        public Formatter format(final String format, final Object ... args) {
+            return formatter.format(format, args);
+        }
+    }
+
+    private static final class ValueExpressionLiteral extends ValueExpression {
+        private final Object value;
+
+        public ValueExpressionLiteral(final Object value) {
+            this.value = value;
+        }
+
+        @Override
+        public Object getValue(final ELContext context) {
+            return value;
+        }
+
+        @Override
+        public void setValue(final ELContext context, final Object value) {
+            throw new PropertyNotWritableException(value.toString());
+        }
+
+        @Override
+        public boolean isReadOnly(final ELContext context) {
+            return true;
+        }
+
+        @Override
+        public Class<?> getType(final ELContext context) {
+            return (this.value != null) ? this.value.getClass() : null;
+        }
+
+        @Override
+        public Class<?> getExpectedType() {
+            return String.class;
+        }
+
+        @Override
+        public String getExpressionString() {
+            return (this.value != null) ? this.value.toString() : null;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            return (obj instanceof ValueExpressionLiteral && this
+                    .equals((ValueExpressionLiteral) obj));
+        }
+
+        public boolean equals(final ValueExpressionLiteral ve) {
+            return (ve != null && (this.value != null && ve.value != null && (this.value == ve.value || this.value
+                    .equals(ve.value))));
+        }
+
+        @Override
+        public int hashCode() {
+            return (this.value != null) ? this.value.hashCode() : 0;
+        }
+
+        @Override
+        public boolean isLiteralText() {
+            return true;
+        }
+    }
 }

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java Mon Jul  1 10:06:18 2013
@@ -16,19 +16,27 @@
  */
 package org.apache.bval.jsr303;
 
+import org.apache.bval.jsr303.groups.Group;
 import org.apache.bval.model.MetaBean;
 import org.apache.bval.model.Validation;
 
+import javax.validation.ConstraintDeclarationException;
 import javax.validation.metadata.ConstraintDescriptor;
 import javax.validation.metadata.ElementDescriptor;
+import javax.validation.metadata.GroupConversionDescriptor;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
 
 /**
  * Description: MetaData class<br/>
  */
 public abstract class ElementDescriptorImpl implements ElementDescriptor {
+    private final Set<GroupConversionDescriptor> groupConversions = new CopyOnWriteArraySet<GroupConversionDescriptor>();
+    private boolean cascaded;
 
     /**
      * Get a set of {@link ConstraintDescriptor}s from the specified array of
@@ -55,6 +63,8 @@ public abstract class ElementDescriptorI
 
     private Set<ConstraintDescriptor<?>> constraintDescriptors;
 
+    private final Map<Group, Group> groupMapping = new HashMap<Group, Group>();
+
     /**
      * Create a new ElementDescriptorImpl instance.
      * 
@@ -70,7 +80,7 @@ public abstract class ElementDescriptorI
 
     /**
      * Create a new ElementDescriptorImpl instance.
-     * 
+     *
      * @param elementClass
      * @param validations
      */
@@ -108,7 +118,7 @@ public abstract class ElementDescriptorI
      * 
      * @return Set of {@link ConstraintDescriptor}
      */
-    protected Set<ConstraintDescriptor<?>> getMutableConstraintDescriptors() {
+    public Set<ConstraintDescriptor<?>> getMutableConstraintDescriptors() {
         return constraintDescriptors;
     }
 
@@ -138,4 +148,37 @@ public abstract class ElementDescriptorI
     public MetaBean getMetaBean() {
         return metaBean;
     }
+
+    public void addGroupMapping(final Group from, final Group to) {
+        groupMapping.put(from, to);
+    }
+
+    public Group mapGroup(final Group current) {
+        final Group mapping = groupMapping.get(current);
+        if (mapping != null) {
+            return mapping;
+        }
+        return current;
+    }
+
+    public Set<GroupConversionDescriptor> getGroupConversions() {
+        return groupConversions;
+    }
+
+    public void addGroupConversion(final GroupConversionDescriptor descriptor) {
+        groupConversions.add(descriptor);
+        final Group from = new Group(descriptor.getFrom());
+        if (mapGroup(from) != from) { // ref == is fine
+            throw new ConstraintDeclarationException("You can't map twice from the same group");
+        }
+        addGroupMapping(from, new Group(descriptor.getTo()));
+    }
+
+    public boolean isCascaded() {
+        return cascaded;
+    }
+
+    public void setCascaded(final boolean cascaded) {
+        this.cascaded = cascaded;
+    }
 }

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/GroupValidationContext.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/GroupValidationContext.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/GroupValidationContext.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/GroupValidationContext.java Mon Jul  1 10:06:18 2013
@@ -24,8 +24,13 @@ import org.apache.bval.model.MetaBean;
 import org.apache.bval.model.ValidationContext;
 
 import javax.validation.ConstraintValidator;
+import javax.validation.ElementKind;
 import javax.validation.MessageInterpolator;
+import javax.validation.ParameterNameProvider;
+import javax.validation.Path;
 import javax.validation.TraversableResolver;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
 
 /**
  * Description: JSR-303 {@link ValidationContext} extension. <br/>
@@ -39,6 +44,8 @@ public interface GroupValidationContext<
      */
     Groups getGroups();
 
+    void setCurrentGroups(Groups groups);
+
     /**
      * Set the current {@link Group}.
      * @param group to set
@@ -119,4 +126,27 @@ public interface GroupValidationContext<
      */
     void setCurrentOwner(Class<?> currentOwner);
 
+    void setKind(ElementKind type);
+
+    ElementKind getElementKind();
+
+    Object getReturnValue();
+
+    Object[] getParameters();
+
+    void setParameters(Object[] parameters);
+
+    void setReturnValue(Object returnValue);
+
+    ParameterNameProvider getParameterNameProvider();
+
+    void setMethod(Method method);
+
+    Method getMethod();
+
+    void setConstructor(Constructor<?> method);
+
+    Constructor<?> getConstructor();
+
+    void moveDown(Path.Node node);
 }

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/GroupValidationContextImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/GroupValidationContextImpl.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/GroupValidationContextImpl.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/GroupValidationContextImpl.java Mon Jul  1 10:06:18 2013
@@ -27,9 +27,15 @@ import org.apache.bval.model.MetaPropert
 import org.apache.bval.util.AccessStrategy;
 
 import javax.validation.ConstraintValidator;
+import javax.validation.ElementKind;
 import javax.validation.MessageInterpolator;
+import javax.validation.ParameterNameProvider;
+import javax.validation.Path;
 import javax.validation.TraversableResolver;
+import javax.validation.ValidationException;
 import javax.validation.metadata.ConstraintDescriptor;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Set;
@@ -43,6 +49,7 @@ final class GroupValidationContextImpl<T
     private final MessageInterpolator messageResolver;
     private final PathImpl path;
     private final MetaBean rootMetaBean;
+    private final ParameterNameProvider parameterNameProvider;
 
     /**
      * the groups in the sequence of validation to take place
@@ -64,23 +71,30 @@ final class GroupValidationContextImpl<T
     private ConstraintValidation<?> constraintValidation;
     private final TraversableResolver traversableResolver;
 
+    private Object[] parameters;
+    private Object returnValue;
+    private Method method;
+    private Constructor<?> constructor;
+
     /**
      * Create a new GroupValidationContextImpl instance.
-     * 
+     *
      * @param listener
      * @param aMessageResolver
      * @param traversableResolver
+     * @param parameterNameProvider
      * @param rootMetaBean
      */
     public GroupValidationContextImpl(ConstraintValidationListener<T> listener, MessageInterpolator aMessageResolver,
-        TraversableResolver traversableResolver, MetaBean rootMetaBean) {
+                                      TraversableResolver traversableResolver, ParameterNameProvider parameterNameProvider, MetaBean rootMetaBean) {
         // inherited variable 'validatedObjects' is of type:
         // HashMap<GraphBeanIdentity, Set<PathImpl>> in this class
         super(listener, new HashMap<GraphBeanIdentity, Set<PathImpl>>());
         this.messageResolver = aMessageResolver;
         this.traversableResolver = CachingTraversableResolver.cacheFor(traversableResolver);
+        this.parameterNameProvider = parameterNameProvider;
         this.rootMetaBean = rootMetaBean;
-        this.path = PathImpl.create(null);
+        this.path = PathImpl.create();
     }
 
     /**
@@ -109,15 +123,28 @@ final class GroupValidationContextImpl<T
         }
     }
 
+    public void setKind(final ElementKind type) {
+        path.getLeafNode().setKind(type);
+    }
+
     /**
      * {@inheritDoc}
      */
     @Override
     public void moveDown(MetaProperty prop, AccessStrategy access) {
-        path.addProperty(prop.getName());
+        moveDown(prop.getName());
         super.moveDown(prop, access);
     }
 
+    @Override
+    public void moveDown(final String prop) {
+        path.addProperty(prop);
+    }
+
+    public void moveDown(final Path.Node node) {
+        path.addNode(node);
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -215,6 +242,10 @@ final class GroupValidationContextImpl<T
         return groups;
     }
 
+    public void setCurrentGroups(final Groups g) {
+        groups = g;
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -261,6 +292,13 @@ final class GroupValidationContextImpl<T
         }
     }
 
+    public <T> T unwrap(Class<T> type) {
+        if (type.isInstance(this)) {
+            return type.cast(this);
+        }
+        throw new ValidationException("Type " + type + " not supported");
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -288,4 +326,44 @@ final class GroupValidationContextImpl<T
     public void setCurrentOwner(Class<?> currentOwner) {
         this.currentOwner = currentOwner;
     }
+
+    public ElementKind getElementKind() {
+        return path.getLeafNode().getKind();
+    }
+
+    public Object getReturnValue() {
+        return returnValue;
+    }
+
+    public Object[] getParameters() {
+        return parameters;
+    }
+
+    public void setParameters(final Object[] parameters) {
+        this.parameters = parameters;
+    }
+
+    public void setReturnValue(final Object returnValue) {
+        this.returnValue = returnValue;
+    }
+
+    public ParameterNameProvider getParameterNameProvider() {
+        return parameterNameProvider;
+    }
+
+    public void setMethod(final Method method) {
+        this.method = method;
+    }
+
+    public Method getMethod() {
+        return method;
+    }
+
+    public Constructor<?> getConstructor() {
+        return constructor;
+    }
+
+    public void setConstructor(final Constructor<?> constructor) {
+        this.constructor = constructor;
+    }
 }

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/InvocableElementDescriptor.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/InvocableElementDescriptor.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/InvocableElementDescriptor.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/InvocableElementDescriptor.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,102 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "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.
+ */
+package org.apache.bval.jsr303;
+
+import org.apache.bval.model.MetaBean;
+import org.apache.bval.model.Validation;
+
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.metadata.CrossParameterDescriptor;
+import javax.validation.metadata.ElementDescriptor;
+import javax.validation.metadata.ParameterDescriptor;
+import javax.validation.metadata.ReturnValueDescriptor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+public class InvocableElementDescriptor extends ElementDescriptorImpl implements ProcedureDescriptor {
+    private static final CopyOnWriteArraySet<ConstraintValidation<?>> NO_CONSTRAINTS = new CopyOnWriteArraySet<ConstraintValidation<?>>();
+
+    private ReturnValueDescriptor returnValueDescriptor;
+    private CrossParameterDescriptor crossParameterDescriptor;
+    private final List<ParameterDescriptor> parameterDescriptors = new ArrayList<ParameterDescriptor>();
+
+    protected InvocableElementDescriptor(final MetaBean metaBean, final Class<?> elementClass, final Validation[] validations) {
+        super(metaBean, elementClass, validations);
+    }
+
+    protected InvocableElementDescriptor(final Class<?> elementClass, final Validation[] validations) {
+        super(elementClass, validations);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<ParameterDescriptor> getParameterDescriptors() {
+        // index aligned
+        return parameterDescriptors;
+    }
+
+    public void setReturnValueDescriptor(final ReturnValueDescriptor returnValueDescriptor) {
+        this.returnValueDescriptor = returnValueDescriptor;
+    }
+
+    public CrossParameterDescriptor getCrossParameterDescriptor() {
+        return crossParameterDescriptor;
+    }
+
+    public void setCrossParameterDescriptor(final CrossParameterDescriptor crossParameterDescriptor) {
+        this.crossParameterDescriptor = crossParameterDescriptor;
+    }
+
+    /**
+     * Add the specified validations to this {@link org.apache.bval.jsr303.MethodDescriptorImpl}.
+     * @param validations
+     */
+    void addValidations(Collection<ConstraintValidation<?>> validations) {
+        getMutableConstraintDescriptors().addAll(validations);
+    }
+
+    protected boolean hasConstrainedParameters() {
+        for (final ParameterDescriptor pd : getParameterDescriptors()) {
+            if (pd.isCascaded() || !pd.getConstraintDescriptors().isEmpty()) {
+                return true;
+            }
+        }
+        return getCrossParameterDescriptor().hasConstraints();
+    }
+
+    public ReturnValueDescriptor getReturnValueDescriptor() {
+        return returnValueDescriptor;
+    }
+
+    protected boolean hasConstrainedReturnValue() {
+        return getReturnValueDescriptor().isCascaded() || !getReturnValueDescriptor().getConstraintDescriptors().isEmpty();
+    }
+
+    @Override
+    public ElementDescriptor.ConstraintFinder findConstraints() {
+        return new ConstraintFinderImpl(metaBean, NO_CONSTRAINTS);
+    }
+
+    @Override
+    public Set<ConstraintDescriptor<?>> getConstraintDescriptors() {
+        return Set.class.cast(NO_CONSTRAINTS);
+    }
+}

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303Features.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303Features.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303Features.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303Features.java Mon Jul  1 10:06:18 2013
@@ -28,6 +28,14 @@ import org.apache.bval.model.Features;
  * @see org.apache.bval.model.Features
  */
 public interface Jsr303Features {
+    interface Method extends Features.Property {
+        String MethodDescriptor = "MethodDescriptor";
+    }
+
+    interface Constructor extends Features.Property {
+        String ConstructorDescriptor = "ConstructorDescriptor";
+    }
+
     /**
      * JSR303 Property features
      */
@@ -38,6 +46,9 @@ public interface Jsr303Features {
          * INFO: Class[] with the groups to validate a REF_CASCADE
          */
         String REF_GROUPS = "refGroups";
+
+        // Collection<Annotation>
+        String ANNOTATIONS_TO_PROCESS = "annotationToProcess";
     }
 
     /**

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303MetaBeanFactory.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303MetaBeanFactory.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303MetaBeanFactory.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303MetaBeanFactory.java Mon Jul  1 10:06:18 2013
@@ -18,34 +18,43 @@
  */
 package org.apache.bval.jsr303;
 
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.validation.Constraint;
-import javax.validation.GroupDefinitionException;
-import javax.validation.GroupSequence;
-import javax.validation.ValidationException;
-import javax.validation.groups.Default;
-
 import org.apache.bval.MetaBeanFactory;
 import org.apache.bval.jsr303.groups.Group;
 import org.apache.bval.jsr303.util.ClassHelper;
 import org.apache.bval.jsr303.util.SecureActions;
 import org.apache.bval.jsr303.xml.MetaConstraint;
+import org.apache.bval.model.Meta;
 import org.apache.bval.model.MetaBean;
+import org.apache.bval.model.MetaConstructor;
+import org.apache.bval.model.MetaMethod;
+import org.apache.bval.model.MetaParameter;
 import org.apache.bval.model.MetaProperty;
 import org.apache.bval.util.AccessStrategy;
 import org.apache.bval.util.FieldAccess;
 import org.apache.bval.util.MethodAccess;
 
+import javax.validation.Constraint;
+import javax.validation.ConstraintDeclarationException;
+import javax.validation.GroupDefinitionException;
+import javax.validation.GroupSequence;
+import javax.validation.groups.ConvertGroup;
+import javax.validation.groups.Default;
+import javax.validation.metadata.PropertyDescriptor;
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
 /**
  * Description: process the class annotations for JSR303 constraint validations to build the MetaBean with information
  * from annotations and JSR303 constraint mappings (defined in xml)<br/>
@@ -92,6 +101,10 @@ public class Jsr303MetaBeanFactory imple
             // time of processing
             for (int i = classSequence.size() - 1; i >= 0; i--) {
                 Class<?> eachClass = classSequence.get(i);
+                if (eachClass == Serializable.class || eachClass == Cloneable.class) {
+                    continue;
+                }
+
                 processClass(eachClass, metabean);
                 processGroupSequence(eachClass, metabean, "{GroupSequence:" + eachClass.getCanonicalName() + "}");
             }
@@ -116,12 +129,13 @@ public class Jsr303MetaBeanFactory imple
 
         // if NOT ignore class level annotations
         if (!factoryContext.getFactory().getAnnotationIgnores().isIgnoreAnnotations(beanClass)) {
-            annotationProcessor.processAnnotations(null, beanClass, beanClass, null, new AppendValidationToMeta(
-                metabean));
+            annotationProcessor.processAnnotations(null, beanClass, beanClass, null, new AppendValidationToMeta(metabean));
         }
 
+        final Collection<String> missingValid = new ArrayList<String>();
+
         final Field[] fields = doPrivileged(SecureActions.getDeclaredFields(beanClass));
-        for (Field field : fields) {
+        for (final Field field : fields) {
             MetaProperty metaProperty = metabean.getProperty(field.getName());
             // create a property for those fields for which there is not yet a
             // MetaProperty
@@ -135,10 +149,14 @@ public class Jsr303MetaBeanFactory imple
                     new AppendValidationToMeta(metaProperty)) && create) {
                     metabean.putProperty(metaProperty.getName(), null);
                 }
+
+                if (field.getAnnotation(ConvertGroup.class) != null) {
+                    missingValid.add(field.getName());
+                }
             }
         }
         final Method[] methods = doPrivileged(SecureActions.getDeclaredMethods(beanClass));
-        for (Method method : methods) {
+        for (final Method method : methods) {
             String propName = null;
             if (method.getParameterTypes().length == 0) {
                 propName = MethodAccess.getPropertyName(method);
@@ -158,12 +176,18 @@ public class Jsr303MetaBeanFactory imple
                         metabean.putProperty(propName, null);
                     }
                 }
-            } else if (hasValidationConstraintsDefined(method)) {
-                throw new ValidationException("Property " + method.getName() + " does not follow javabean conventions.");
             }
         }
 
         addXmlConstraints(beanClass, metabean);
+
+        for (final String name : missingValid) {
+            final MetaProperty metaProperty = metabean.getProperty(name);
+            if (metaProperty != null && metaProperty.getFeature(Jsr303Features.Property.REF_CASCADE) == null) {
+                throw new ConstraintDeclarationException("@ConvertGroup needs @Valid");
+            }
+        }
+        missingValid.clear();
     }
 
     /**
@@ -212,26 +236,76 @@ public class Jsr303MetaBeanFactory imple
      */
     private void addXmlConstraints(Class<?> beanClass, MetaBean metabean) throws IllegalAccessException,
         InvocationTargetException {
-        for (MetaConstraint<?, ? extends Annotation> meta : factoryContext.getFactory().getMetaConstraints(beanClass)) {
-            MetaProperty metaProperty;
-            AccessStrategy access = meta.getAccessStrategy();
+        for (final MetaConstraint<?, ? extends Annotation> metaConstraint : factoryContext.getFactory().getMetaConstraints(beanClass)) {
+            Meta meta;
+            AccessStrategy access = metaConstraint.getAccessStrategy();
             boolean create = false;
             if (access == null) { // class level
-                metaProperty = null;
+                meta = null;
+            } else if (access.getElementType() == ElementType.METHOD && !metaConstraint.getMember().getName().startsWith("get")) { // TODO: better getter test
+                final Method method = Method.class.cast(metaConstraint.getMember());
+                meta = metabean.getMethod(method);
+                final MetaMethod metaMethod;
+                if (meta == null) {
+                    meta = new MetaMethod(metabean, method);
+                    metaMethod = MetaMethod.class.cast(meta);
+                    metabean.addMethod(method, metaMethod);
+                } else {
+                    metaMethod = MetaMethod.class.cast(meta);
+                }
+                final Integer index = metaConstraint.getIndex();
+                if (index != null && index >= 0) {
+                    MetaParameter param = metaMethod.getParameter(index);
+                    if (param == null) {
+                        param = new MetaParameter(metaMethod, index);
+                        metaMethod.addParameter(index, param);
+                    }
+                    param.addAnnotation(metaConstraint.getAnnotation());
+                } else {
+                    metaMethod.addAnnotation(metaConstraint.getAnnotation());
+                }
+                continue;
+            } else if (access.getElementType() == ElementType.CONSTRUCTOR){
+                final Constructor<?> constructor = Constructor.class.cast(metaConstraint.getMember());
+                meta = metabean.getConstructor(constructor);
+                final MetaConstructor metaConstructor;
+                if (meta == null) {
+                    meta = new MetaConstructor(metabean, constructor);
+                    metaConstructor = MetaConstructor.class.cast(meta);
+                    metabean.addConstructor(constructor, metaConstructor);
+                } else {
+                    metaConstructor = MetaConstructor.class.cast(meta);
+                }
+                final Integer index = metaConstraint.getIndex();
+                if (index != null && index >= 0) {
+                    MetaParameter param = metaConstructor.getParameter(index);
+                    if (param == null) {
+                        param = new MetaParameter(metaConstructor, index);
+                        metaConstructor.addParameter(index, param);
+                    }
+                    param.addAnnotation(metaConstraint.getAnnotation());
+                } else {
+                    metaConstructor.addAnnotation(metaConstraint.getAnnotation());
+                }
+                continue;
             } else { // property level
-                metaProperty = metabean.getProperty(access.getPropertyName());
-                create = metaProperty == null;
+                meta = metabean.getProperty(access.getPropertyName());
+                create = meta == null;
                 if (create) {
-                    metaProperty = addMetaProperty(metabean, access);
+                    meta = addMetaProperty(metabean, access);
                 }
             }
-            if (!annotationProcessor.processAnnotation(meta.getAnnotation(), metaProperty, beanClass,
-                meta.getAccessStrategy(), new AppendValidationToMeta(metaProperty == null ? metabean : metaProperty))
+            if (!annotationProcessor.processAnnotation(metaConstraint.getAnnotation(), meta, beanClass,
+                metaConstraint.getAccessStrategy(), new AppendValidationToMeta(meta == null ? metabean : meta), false)
                 && create) {
                 metabean.putProperty(access.getPropertyName(), null);
             }
         }
-        for (AccessStrategy access : factoryContext.getFactory().getValidAccesses(beanClass)) {
+        for (final AccessStrategy access : factoryContext.getFactory().getValidAccesses(beanClass)) {
+            if (access.getElementType() == ElementType.PARAMETER) {
+                continue;
+            }
+
             MetaProperty metaProperty = metabean.getProperty(access.getPropertyName());
             boolean create = metaProperty == null;
             if (create) {
@@ -264,7 +338,7 @@ public class Jsr303MetaBeanFactory imple
             }
         }
         boolean containsDefault = false;
-        for (Class<?> groupClass : groupClasses) {
+        for (final Class<?> groupClass : groupClasses) {
             if (groupClass.getName().equals(beanClass.getName())) {
                 groupSeq.add(Group.DEFAULT);
                 containsDefault = true;

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/MethodDescriptor.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/MethodDescriptor.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/MethodDescriptor.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/MethodDescriptor.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,40 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "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.
+ */
+package org.apache.bval.jsr303;
+
+import javax.validation.metadata.ElementDescriptor;
+import javax.validation.metadata.ParameterDescriptor;
+import java.util.List;
+
+/**
+ * Description: This class will disappear when such
+ * functionality is part of the JSR303 specification.<br/>
+ */
+public interface MethodDescriptor extends ElementDescriptor {
+    /**
+     * Get the {@link javax.validation.metadata.ParameterDescriptor}s for this {@link org.apache.bval.jsr303.MethodDescriptor}.
+     * @return {@link java.util.List} of {@link javax.validation.metadata.ParameterDescriptor}
+     */
+    List<ParameterDescriptor> getParameterDescriptors(); //index aligned
+
+    /**
+     * Learn whether the referenced method should be validated.
+     * @return boolean
+     */
+    boolean isCascaded();
+
+}

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/MethodDescriptorImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/MethodDescriptorImpl.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/MethodDescriptorImpl.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/MethodDescriptorImpl.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,59 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "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.
+ */
+package org.apache.bval.jsr303;
+
+import org.apache.bval.model.Features;
+import org.apache.bval.model.MetaBean;
+import org.apache.bval.model.MetaMethod;
+import org.apache.bval.model.Validation;
+
+import java.lang.reflect.Method;
+
+/**
+ * Description: {@link MethodDescriptor} implementation.<br/>
+ */
+public class MethodDescriptorImpl extends InvocableElementDescriptor implements javax.validation.metadata.MethodDescriptor, ProcedureDescriptor {
+    private final String name;
+
+    protected MethodDescriptorImpl(final MetaBean metaBean, final Validation[] validations, final Method method) {
+        super(metaBean, method.getReturnType(), validations);
+        name = method.getName();
+    }
+
+    public MethodDescriptorImpl(final MetaBean bean, final MetaMethod metaMethod) {
+        super(bean, metaMethod.getMethod().getReturnType(), new Validation[0]);
+        setCascaded(false);
+        this.name = metaMethod.getMethod().getName();
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public boolean hasConstrainedParameters() {
+        return super.hasConstrainedParameters();
+    }
+
+    public boolean hasConstrainedReturnValue() {
+        return super.hasConstrainedReturnValue();
+    }
+
+    @Override
+    public boolean hasConstraints() {
+        return false;
+    }
+}

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/NodeBuilderCustomizableContextImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/NodeBuilderCustomizableContextImpl.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/NodeBuilderCustomizableContextImpl.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/NodeBuilderCustomizableContextImpl.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "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.
+ */
+package org.apache.bval.jsr303;
+
+import org.apache.bval.jsr303.util.LeafNodeBuilderCustomizableContextImpl;
+import org.apache.bval.jsr303.util.NodeImpl;
+import org.apache.bval.jsr303.util.PathImpl;
+
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ElementKind;
+
+public class NodeBuilderCustomizableContextImpl implements ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext {
+    private final PathImpl path;
+    private final ConstraintValidatorContextImpl context;
+    private final String template;
+
+    public NodeBuilderCustomizableContextImpl(final ConstraintValidatorContextImpl parent, final String messageTemplate, final PathImpl propertyPath) {
+        context = parent;
+        template = messageTemplate;
+        path = propertyPath;
+    }
+
+    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeContextBuilder inIterable() {
+        path.getLeafNode().setInIterable(true);
+        return new NodeContextBuilderImpl(context, template, path);
+    }
+
+    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext addNode(String name) {
+        path.addNode(new NodeImpl(name));
+        return this;
+    }
+
+    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext addPropertyNode(String name) {
+        final NodeImpl node = new NodeImpl.PropertyNodeImpl(name);
+        node.setKind(ElementKind.PROPERTY);
+        path.addNode(node);
+        return this;
+    }
+
+    public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext addBeanNode() {
+        final NodeImpl node = new NodeImpl.BeanNodeImpl();
+        node.setKind(ElementKind.BEAN);
+        path.addNode(node);
+        return new LeafNodeBuilderCustomizableContextImpl(context, template, path);
+    }
+
+    public ConstraintValidatorContext addConstraintViolation() {
+        context.addError(template, path);
+        return context;
+    }
+}

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/NodeContextBuilderImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/NodeContextBuilderImpl.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/NodeContextBuilderImpl.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/NodeContextBuilderImpl.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "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.
+ */
+package org.apache.bval.jsr303;
+
+import org.apache.bval.jsr303.util.LeafNodeBuilderCustomizableContextImpl;
+import org.apache.bval.jsr303.util.NodeBuilderDefinedContextImpl;
+import org.apache.bval.jsr303.util.NodeImpl;
+import org.apache.bval.jsr303.util.PathImpl;
+
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ElementKind;
+import javax.validation.Path;
+import java.util.Iterator;
+
+public class NodeContextBuilderImpl implements ConstraintValidatorContext.ConstraintViolationBuilder.NodeContextBuilder {
+    private final PathImpl path;
+    private final String template;
+    private final ConstraintValidatorContextImpl context;
+
+    public NodeContextBuilderImpl(final ConstraintValidatorContextImpl context, final String template, final PathImpl path) {
+        this.context = context;
+        this.template = template;
+        this.path = path;
+    }
+
+    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderDefinedContext atKey(Object key) {
+        path.getLeafNode().setKey(key);
+        return new NodeBuilderDefinedContextImpl(context, template, path);
+    }
+
+    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderDefinedContext atIndex(Integer index) {
+        path.getLeafNode().setIndex(index);
+        return new NodeBuilderDefinedContextImpl(context, template, path);
+    }
+
+    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext addNode(String name) {
+        return new NodeBuilderCustomizableContextImpl(context, template, path).addNode(name);
+    }
+
+    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext addPropertyNode(String name) {
+        return new NodeBuilderCustomizableContextImpl(context, template, path).addPropertyNode(name);
+    }
+
+    public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext addBeanNode() {
+        final NodeImpl node = new NodeImpl.BeanNodeImpl();
+        node.setKind(ElementKind.BEAN);
+        path.addNode(node);
+        return new LeafNodeBuilderCustomizableContextImpl(context, template, path);
+    }
+
+    public ConstraintValidatorContext addConstraintViolation() {
+        context.addError(template, path);
+        return context;
+    }
+}

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ParameterAccess.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ParameterAccess.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ParameterAccess.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ParameterAccess.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,80 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "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.
+ */
+
+package org.apache.bval.jsr303;
+
+import org.apache.bval.util.AccessStrategy;
+
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Type;
+
+
+/**
+ * Implementation of {@link org.apache.bval.util.AccessStrategy} for method parameters.
+ *
+ * @author Carlos Vara
+ */
+public class ParameterAccess extends AccessStrategy {
+
+    private Type paramType;
+    private int paramIdx;
+
+    /**
+     * Create a new ParameterAccess instance.
+     * @param paramType
+     * @param paramIdx
+     */
+    public ParameterAccess(Type paramType, int paramIdx ) {
+        this.paramType = paramType;
+        this.paramIdx = paramIdx;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Object get(Object instance) {
+        throw new UnsupportedOperationException("Obtaining a parameter value not yet implemented");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ElementType getElementType() {
+        return ElementType.PARAMETER;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Type getJavaType() {
+        return this.paramType;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getPropertyName() {
+        return "" + paramIdx;
+    }
+
+}

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ParameterDescriptorImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ParameterDescriptorImpl.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ParameterDescriptorImpl.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ParameterDescriptorImpl.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,89 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "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.
+ */
+package org.apache.bval.jsr303;
+
+import org.apache.bval.jsr303.groups.Group;
+import org.apache.bval.jsr303.groups.GroupConversionDescriptorImpl;
+import org.apache.bval.model.MetaBean;
+import org.apache.bval.model.Validation;
+
+import javax.validation.ParameterNameProvider;
+import javax.validation.metadata.GroupConversionDescriptor;
+import javax.validation.metadata.ParameterDescriptor;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+
+/**
+ * Description: {@link javax.validation.metadata.ParameterDescriptor} implementation.<br/>
+ */
+public class ParameterDescriptorImpl extends ElementDescriptorImpl implements ParameterDescriptor {
+    private final Set<GroupConversionDescriptor> groupConversions = new CopyOnWriteArraySet<GroupConversionDescriptor>();
+    private final String name;
+    private int index;
+
+    /**
+     * Create a new ParameterDescriptorImpl instance.
+     * @param metaBean
+     * @param validations
+     */
+    public ParameterDescriptorImpl(MetaBean metaBean, Validation[] validations, String name) {
+        super(metaBean, metaBean.getBeanClass(), validations);
+        this.name = name;
+    }
+
+    /**
+     * Create a new ParameterDescriptorImpl instance.
+     * @param elementClass
+     * @param validations
+     */
+    public ParameterDescriptorImpl(Class<?> elementClass, Validation[] validations, String name) {
+        super(elementClass, validations);
+        this.name = name;
+    }
+
+    public Set<GroupConversionDescriptor> getGroupConversions() {
+        return groupConversions;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getIndex() {
+        return index;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Set the index of the referenced parameter.
+     * @param index
+     */
+    public void setIndex(int index) {
+        this.index = index;
+    }
+
+    @Override
+    public void addGroupMapping(final Group from, final Group to) {
+        groupConversions.add(new GroupConversionDescriptorImpl(from, to));
+        super.addGroupMapping(from, to);
+    }
+}

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ParametersAccess.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ParametersAccess.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ParametersAccess.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ParametersAccess.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,46 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "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.
+ */
+package org.apache.bval.jsr303;
+
+import org.apache.bval.util.AccessStrategy;
+
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Type;
+
+public class ParametersAccess extends AccessStrategy {
+    @Override
+    public Object get(final Object instance) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public ElementType getElementType() {
+        return ElementType.PARAMETER;
+    }
+
+    @Override
+    public Type getJavaType() {
+        return Object[].class;
+    }
+
+    @Override
+    public String getPropertyName() {
+        return null;
+    }
+}

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ProcedureDescriptor.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ProcedureDescriptor.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ProcedureDescriptor.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ProcedureDescriptor.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,51 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "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.
+ */
+package org.apache.bval.jsr303;
+
+
+import org.apache.bval.jsr303.groups.Group;
+import org.apache.bval.model.MetaBean;
+
+import javax.validation.metadata.ParameterDescriptor;
+import java.util.List;
+
+/**
+ * Description: superinterface of {@link javax.validation.metadata.ConstructorDescriptor} and {@link org.apache.bval.jsr303.MethodDescriptor}.<br/>
+ */
+public interface ProcedureDescriptor {
+    /**
+     * Get the owning metabean.
+     * @return MetaBean
+     */
+    MetaBean getMetaBean();
+
+    /**
+     * Set whether this procedure should be validated.
+     * @param b
+     */
+    void setCascaded(boolean b);
+
+    /**
+     * Get the parameter descriptors of this procedure.
+     * @return {@link java.util.List} of {@link javax.validation.metadata.ParameterDescriptor}
+     */
+    List<ParameterDescriptor> getParameterDescriptors();
+
+    void addGroupMapping(Group from, Group to);
+
+    Group mapGroup(Group current);
+}

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/PropertyDescriptorImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/PropertyDescriptorImpl.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/PropertyDescriptorImpl.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/PropertyDescriptorImpl.java Mon Jul  1 10:06:18 2013
@@ -21,13 +21,16 @@ package org.apache.bval.jsr303;
 import org.apache.bval.model.Features;
 import org.apache.bval.model.MetaProperty;
 
+import javax.validation.metadata.GroupConversionDescriptor;
 import javax.validation.metadata.PropertyDescriptor;
+import java.util.Set;
 
 /**
  * Description: {@link PropertyDescriptor} implementation.<br/>
+ *
+ * TODO: use it instead of MetaProperty!
  */
 class PropertyDescriptorImpl extends ElementDescriptorImpl implements PropertyDescriptor {
-    private boolean cascaded;
     private String propertyPath;
 
     /**
@@ -42,22 +45,6 @@ class PropertyDescriptorImpl extends Ele
     }
 
     /**
-     * Set whether the referenced property is cascaded.
-     * 
-     * @param cascaded
-     */
-    public void setCascaded(boolean cascaded) {
-        this.cascaded = cascaded;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean isCascaded() {
-        return cascaded;
-    }
-
-    /**
      * Set the referenced property path.
      * 
      * @param propertyPath

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ReturnAccess.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ReturnAccess.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ReturnAccess.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ReturnAccess.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,76 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "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.
+ */
+
+package org.apache.bval.jsr303;
+
+import org.apache.bval.util.AccessStrategy;
+
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Type;
+
+/**
+ * Implementation of {@link org.apache.bval.util.AccessStrategy} for method return values.
+ *
+ * @author Carlos Vara
+ */
+public class ReturnAccess extends AccessStrategy {
+
+    private Type returnType;
+
+    /**
+     * Create a new ReturnAccess instance.
+     * @param returnType
+     */
+    public ReturnAccess(Type returnType) {
+        this.returnType = returnType;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Object get(Object instance) {
+        throw new UnsupportedOperationException("Obtaining a method return value not yet implemented");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ElementType getElementType() {
+        return ElementType.METHOD;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Type getJavaType() {
+        return this.returnType;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getPropertyName() {
+        return "Return value";
+    }
+
+}

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ReturnValueDescriptorImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ReturnValueDescriptorImpl.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ReturnValueDescriptorImpl.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/ReturnValueDescriptorImpl.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012-2013, Red Hat, Inc. and/or its affiliates, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "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.
+ */
+package org.apache.bval.jsr303;
+
+import org.apache.bval.model.MetaBean;
+
+import javax.validation.metadata.ReturnValueDescriptor;
+import java.util.Collection;
+
+public class ReturnValueDescriptorImpl extends ElementDescriptorImpl implements ReturnValueDescriptor {
+    public ReturnValueDescriptorImpl(final MetaBean metaBean, Class<?> returnType, final Collection<ConstraintValidation<?>> list, boolean cascaded) {
+        super(metaBean, returnType, list.toArray(new ConstraintValidation<?>[list.size()]));
+        setCascaded(cascaded);
+    }
+
+    public boolean hasConstraints() {
+        return false;
+    }
+}

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/groups/Group.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/groups/Group.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/groups/Group.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/groups/Group.java Mon Jul  1 10:06:18 2013
@@ -69,10 +69,8 @@ public final class Group {
 	 * {@inheritDoc}
 	 */
     @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o instanceof Group == false) return false;
-        return ObjectUtils.equals(group, ((Group) o).group);
+    public boolean equals(final Object o) {
+        return this == o || o instanceof Group && ObjectUtils.equals(group, ((Group) o).group);
     }
 
     /**

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/groups/GroupConversionDescriptorImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/groups/GroupConversionDescriptorImpl.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/groups/GroupConversionDescriptorImpl.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/groups/GroupConversionDescriptorImpl.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "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.
+ */
+package org.apache.bval.jsr303.groups;
+
+import javax.validation.ConstraintDeclarationException;
+import javax.validation.GroupSequence;
+import javax.validation.metadata.GroupConversionDescriptor;
+
+public class GroupConversionDescriptorImpl implements GroupConversionDescriptor {
+    private final Class<?> to;
+    private final Class<?> from;
+
+    public GroupConversionDescriptorImpl(final Group from, final Group to) {
+        this.from = from.getGroup();
+        if (this.from.getAnnotation(GroupSequence.class) != null) {
+            throw new ConstraintDeclarationException("from() can't get a group sequence");
+        }
+
+        this.to = to.getGroup();
+    }
+
+    public Class<?> getFrom() {
+        return from;
+    }
+
+    public Class<?> getTo() {
+        return to;
+    }
+}

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/groups/GroupsComputer.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/groups/GroupsComputer.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/groups/GroupsComputer.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/groups/GroupsComputer.java Mon Jul  1 10:06:18 2013
@@ -78,10 +78,13 @@ public class GroupsComputer {
             throw new IllegalArgumentException("At least one group has to be specified.");
         }
 
-        for (Class<?> clazz : groups) {
+        for (final Class<?> clazz : groups) {
+            if (clazz == null) {
+                throw new IllegalArgumentException("At least one group has to be specified.");
+            }
+
             if (!clazz.isInterface()) {
-                throw new ValidationException(
-                      "A group has to be an interface. " + clazz.getName() + " is not.");
+                throw new ValidationException("A group has to be an interface. " + clazz.getName() + " is not.");
             }
         }
 

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/parameter/DefaultParameterNameProvider.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/parameter/DefaultParameterNameProvider.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/parameter/DefaultParameterNameProvider.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/parameter/DefaultParameterNameProvider.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "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.
+ */
+package org.apache.bval.jsr303.parameter;
+
+import javax.validation.ParameterNameProvider;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+public class DefaultParameterNameProvider implements ParameterNameProvider {
+    private static final String ARG = "arg";
+
+    public List<String> getParameterNames(Constructor<?> constructor) {
+        return names(constructor.getParameterTypes().length);
+    }
+
+    public List<String> getParameterNames(Method method) {
+        return names(method.getParameterTypes().length);
+    }
+
+    private static List<String> names(final int length) {
+        final List<String> list = new ArrayList<String>();
+        for (int i = 0; i < length; i++) {
+            list.add(ARG + i);
+        }
+        return list;
+    }
+}

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ClassHelper.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ClassHelper.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ClassHelper.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ClassHelper.java Mon Jul  1 10:06:18 2013
@@ -20,6 +20,7 @@ package org.apache.bval.jsr303.util;
 
 import org.apache.commons.lang3.ClassUtils;
 
+import java.io.Serializable;
 import java.security.AccessController;
 import java.util.List;
 
@@ -44,7 +45,7 @@ public class ClassHelper {
      *            The current class, root of the hierarchy to traverse.
      */
     static public void fillFullClassHierarchyAsList(List<Class<?>> allClasses, Class<?> clazz) {
-        if (clazz == null || clazz == Object.class) {
+        if (clazz == null || clazz == Object.class || clazz == Serializable.class) {
             return;
         }
         if (allClasses.contains(clazz)) {



Mime
View raw message