bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1498347 [5/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/util/ConstraintDefinitionValidator.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ConstraintDefinitionValidator.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ConstraintDefinitionValidator.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ConstraintDefinitionValidator.java Mon Jul  1 10:06:18 2013
@@ -20,6 +20,7 @@ package org.apache.bval.jsr303.util;
 
 import javax.validation.Constraint;
 import javax.validation.ConstraintDefinitionException;
+import javax.validation.ConstraintTarget;
 
 import org.apache.bval.jsr303.ConstraintAnnotationAttributes;
 
@@ -45,10 +46,19 @@ public class ConstraintDefinitionValidat
      * @throws ConstraintDefinitionException
      *             In case the constraint is invalid.
      */
-    public static void validateConstraintDefinition(Annotation annotation) {
-        ConstraintAnnotationAttributes.GROUPS.validateOn(annotation.annotationType());
-        ConstraintAnnotationAttributes.PAYLOAD.validateOn(annotation.annotationType());
-        ConstraintAnnotationAttributes.MESSAGE.validateOn(annotation.annotationType());
+    public static void validateConstraintDefinition(final Annotation annotation) {
+        final Class<? extends Annotation> type = annotation.annotationType();
+
+        ConstraintAnnotationAttributes.GROUPS.validateOn(type);
+        ConstraintAnnotationAttributes.PAYLOAD.validateOn(type);
+        ConstraintAnnotationAttributes.MESSAGE.validateOn(type);
+        ConstraintAnnotationAttributes.VALIDATION_APPLIES_TO.validateOn(type);
+
+        final Object defaultValidationApplies = ConstraintAnnotationAttributes.VALIDATION_APPLIES_TO.getDefaultValue(type);
+        if (ConstraintAnnotationAttributes.VALIDATION_APPLIES_TO.isDeclaredOn(type) && !ConstraintTarget.IMPLICIT.equals(defaultValidationApplies)) {
+            throw new ConstraintDefinitionException("validationAppliesTo default value should be IMPLICIT");
+        }
+
         validAttributes(annotation);
     }
 
@@ -59,6 +69,7 @@ public class ConstraintDefinitionValidat
      *            The annotation to check.
      */
     private static void validAttributes(final Annotation annotation) {
+        /*
         final Method[] methods = run(SecureActions.getDeclaredMethods(annotation.annotationType()));
         for (Method method : methods ){
             // Currently case insensitive, the spec is unclear about this
@@ -67,6 +78,7 @@ public class ConstraintDefinitionValidat
                     "A constraint annotation cannot have methods which start with 'valid'");
             }
         }
+        */
     }
 
     private static <T> T run(PrivilegedAction<T> action) {

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/IOs.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/IOs.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/IOs.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/IOs.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,52 @@
+/*
+ * 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.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class IOs {
+    private IOs() {
+        // no-op
+    }
+
+    public static InputStream convertToMarkableInputStream(final InputStream stream) {
+        if (stream == null) {
+            return null;
+        }
+
+        if (stream.markSupported()) {
+            return stream;
+        } else {
+            try {
+                final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                final byte[] buffer = new byte[1024];
+                int length;
+                while ((length = stream.read(buffer)) != -1) {
+                    baos.write(buffer, 0, length);
+                }
+                return new ByteArrayInputStream(baos.toByteArray());
+            } catch (final IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+}

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/LeafNodeBuilderCustomizableContextImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/LeafNodeBuilderCustomizableContextImpl.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/LeafNodeBuilderCustomizableContextImpl.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/LeafNodeBuilderCustomizableContextImpl.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,66 @@
+/*
+ * 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.util;
+
+import org.apache.bval.jsr303.ConstraintValidatorContextImpl;
+
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ElementKind;
+
+public class LeafNodeBuilderCustomizableContextImpl implements ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext {
+    private final ConstraintValidatorContextImpl context;
+    private final PathImpl path;
+    private final String template;
+    private final NodeImpl node;
+
+    public LeafNodeBuilderCustomizableContextImpl(final ConstraintValidatorContextImpl parent, String messageTemplate, PathImpl propertyPath) {
+        context = parent;
+        template = messageTemplate;
+        path = propertyPath;
+        node = new NodeImpl((String) null);
+        node.setKind(ElementKind.BEAN);
+    }
+
+    public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeContextBuilder inIterable() {
+        path.getLeafNode().setInIterable(true);
+        return new LeafNodeContextBuilderImpl();
+    }
+
+    public ConstraintValidatorContext addConstraintViolation() {
+        context.addError(template, path);
+        return context;
+    }
+
+    private class LeafNodeContextBuilderImpl implements ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeContextBuilder {
+        public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderDefinedContext atKey(Object key) {
+            path.getLeafNode().setKey(key);
+            return new LeafNodeBuilderDefinedContextImpl(context, template, path);
+        }
+
+        public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderDefinedContext atIndex(Integer index) {
+            path.getLeafNode().setIndex(index);
+            return new LeafNodeBuilderDefinedContextImpl(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/util/LeafNodeBuilderDefinedContextImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/LeafNodeBuilderDefinedContextImpl.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/LeafNodeBuilderDefinedContextImpl.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/LeafNodeBuilderDefinedContextImpl.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.util;
+
+import org.apache.bval.jsr303.ConstraintValidatorContextImpl;
+
+import javax.validation.ConstraintValidatorContext;
+
+public class LeafNodeBuilderDefinedContextImpl implements ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderDefinedContext {
+    private final ConstraintValidatorContextImpl context;
+    private final String template;
+    private final PathImpl path;
+
+    public LeafNodeBuilderDefinedContextImpl(final ConstraintValidatorContextImpl context, final String tpl, final PathImpl path) {
+        this.context = context;
+        this.template = tpl;
+        this.path = path;
+    }
+
+    public ConstraintValidatorContext addConstraintViolation() {
+        context.addError(template, path);
+        return context;
+    }
+}

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/MarkableInputStream.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/MarkableInputStream.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/MarkableInputStream.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/MarkableInputStream.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,140 @@
+/*
+ * 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.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class MarkableInputStream extends InputStream {
+    private final InputStream delegate;
+    private ByteArrayOutputStream baos;
+    private byte[] buffer;
+    private int bufferIndex;
+
+    public MarkableInputStream(final InputStream stream) {
+        delegate = stream;
+        baos = new ByteArrayOutputStream();
+    }
+
+    @Override
+    public boolean markSupported() {
+        return true;
+    }
+
+    @Override
+    public void mark(final int unused) {
+        // no-op
+    }
+
+    @Override
+    public void reset() throws IOException {
+        if (baos == null) {
+            throw new IOException("reset");
+        }
+
+        if (baos.size() == 0) {
+            baos = null;
+        } else {
+            buffer = baos.toByteArray();
+            baos = null;
+            bufferIndex = 0;
+        }
+    }
+
+    @Override
+    public void close() throws IOException {
+        delegate.close();
+        if (baos != null) {
+            baos.close();
+        }
+        baos = null;
+        buffer = null;
+    }
+
+    @Override
+    public int read() throws IOException {
+        if (buffer != null) {
+            return readFromBuffer();
+        } else {
+            return readFromStream();
+        }
+    }
+
+    @Override
+    public int read(final byte[] b, final int offset, final int length) throws IOException {
+        if (buffer != null) {
+            return readFromBuffer(b, offset, length);
+        } else {
+            return readFromStream(b, offset, length);
+        }
+    }
+
+    @Override
+    public int read(final byte[] b) throws IOException {
+        return read(b, 0, b.length);
+    }
+
+    private int readFromBuffer(final byte[] b, final int offset, final int length) {
+        int bytesRead = -1;
+        if (length <= buffer.length - bufferIndex) {
+            System.arraycopy(buffer, bufferIndex, b, offset, length);
+            bufferIndex += length;
+            bytesRead = length;
+        } else {
+            int count = buffer.length - bufferIndex;
+            System.arraycopy(buffer, bufferIndex, b, offset, count);
+            buffer = null;
+            bytesRead = count;
+        }
+        if (baos != null) {
+            baos.write(b, offset, bytesRead);
+        }
+        return bytesRead;
+    }
+
+    private int readFromStream(final byte[] b, final int offset, final int length)
+            throws IOException {
+
+        int i = delegate.read(b, offset, length);
+        if (i != -1 && baos != null) {
+            baos.write(b, offset, i);
+        }
+        return i;
+    }
+
+    private int readFromBuffer() {
+        int i = buffer[bufferIndex++];
+        if (baos != null) {
+            baos.write(i);
+        }
+        if (bufferIndex == buffer.length) {
+            buffer = null;
+        }
+        return i;
+    }
+
+    private int readFromStream() throws IOException {
+        int i = delegate.read();
+        if (i != -1 && baos != null) {
+            baos.write(i);
+        }
+        return i;
+    }
+}

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderCustomizableContextImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderCustomizableContextImpl.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderCustomizableContextImpl.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderCustomizableContextImpl.java Mon Jul  1 10:06:18 2013
@@ -22,9 +22,10 @@ package org.apache.bval.jsr303.util;
 import org.apache.bval.jsr303.ConstraintValidatorContextImpl;
 
 import javax.validation.ConstraintValidatorContext;
+import javax.validation.ElementKind;
 
 /**
- * Description: implementation of {@link NodeBuilderCustomizableContext}.<br/>
+ * Description: implementation of {@link javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext}.<br/>
  */
 final class NodeBuilderCustomizableContextImpl
       implements ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext {
@@ -46,6 +47,7 @@ final class NodeBuilderCustomizableConte
         messageTemplate = template;
         propertyPath = path;
         node = new NodeImpl(name);
+        node.setKind(ElementKind.PROPERTY);
     }
 
     /**
@@ -60,13 +62,26 @@ final class NodeBuilderCustomizableConte
     /**
      * {@inheritDoc}
      */
-    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext addNode(
-          String name) {
+    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext addNode(String name) {
         propertyPath.addNode(node);
         node = new NodeImpl(name);
         return this; // Re-use this instance
     }
 
+    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext addPropertyNode(String name) {
+        propertyPath.addNode(node);
+        node = new NodeImpl.PropertyNodeImpl(name);
+        node.setKind(ElementKind.PROPERTY);
+        return null;
+    }
+
+    public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext addBeanNode() {
+        propertyPath.addNode(node);
+        node = new NodeImpl((String) null);
+        node.setKind(ElementKind.BEAN);
+        return new LeafNodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath);
+    }
+
     /**
      * {@inheritDoc}
      */

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderDefinedContextImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderDefinedContextImpl.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderDefinedContextImpl.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderDefinedContextImpl.java Mon Jul  1 10:06:18 2013
@@ -22,6 +22,8 @@ package org.apache.bval.jsr303.util;
 import org.apache.bval.jsr303.ConstraintValidatorContextImpl;
 
 import javax.validation.ConstraintValidatorContext;
+import javax.validation.ElementKind;
+import javax.validation.Path;
 
 /**
  * Description: Implementation of {@link NodeBuilderDefinedContext}.<br/>
@@ -48,12 +50,22 @@ public final class NodeBuilderDefinedCon
     /**
      * {@inheritDoc}
      */
-    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext addNode(
-          String name) {
+    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext addNode(String name) {
         // Node not yet added, wait until more information is provided
         return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath, name);
     }
 
+    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext addPropertyNode(String name) {
+        return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath, name);
+    }
+
+    public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext addBeanNode() {
+        final NodeImpl node = new NodeImpl((String) null);
+        node.setKind(ElementKind.BEAN);
+        propertyPath.addNode(node);
+        return new LeafNodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath);
+    }
+
     /**
      * {@inheritDoc}
      */

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeContextBuilderImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeContextBuilderImpl.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeContextBuilderImpl.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeContextBuilderImpl.java Mon Jul  1 10:06:18 2013
@@ -23,6 +23,7 @@ import org.apache.bval.jsr303.Constraint
 
 import javax.validation.ConstraintValidatorContext;
 import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.NodeContextBuilder;
+import javax.validation.ElementKind;
 
 /**
  * Description: Implementation of {@link NodeContextBuilder}.<br/>
@@ -79,6 +80,15 @@ final class NodeContextBuilderImpl
         return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath, name);
     }
 
+    public ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext addPropertyNode(String name) {
+        propertyPath.addProperty(name);
+        return new NodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath, node.getName());
+    }
+
+    public ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderCustomizableContext addBeanNode() {
+        return new LeafNodeBuilderCustomizableContextImpl(parent, messageTemplate, propertyPath);
+    }
+
     /**
      * {@inheritDoc}
      */

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeImpl.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeImpl.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeImpl.java Mon Jul  1 10:06:18 2013
@@ -18,21 +18,25 @@
  */
 package org.apache.bval.jsr303.util;
 
+import javax.validation.ElementKind;
 import javax.validation.Path;
 import javax.validation.Path.Node;
-
 import java.io.Serializable;
+import java.util.List;
 import java.util.Map;
 
 /**
  * Description: a node (property) as part of a Path.
  * (Implementation based on reference implementation) <br/>
+ *
+ * TODO: split it in several impl
  */
-public final class NodeImpl implements Path.Node, Serializable {
+public class NodeImpl implements Path.Node, Serializable {
 
     private static final long serialVersionUID = 1L;
     private static final String INDEX_OPEN = "[";
     private static final String INDEX_CLOSE = "]";
+    private List<Class<?>> parameterTypes;
 
     /**
      * Append a Node to the specified StringBuilder.
@@ -84,13 +88,15 @@ public final class NodeImpl implements P
     private String name;
     private boolean inIterable;
     private Integer index;
+    private int parameterIndex;
     private Object key;
+    private ElementKind kind;
 
     /**
      * Create a new NodeImpl instance.
      * @param name
      */
-    public NodeImpl(String name) {
+    public  NodeImpl(String name) {
         this.name = name;
     }
 
@@ -103,6 +109,7 @@ public final class NodeImpl implements P
         this.inIterable = node.isInIterable();
         this.index = node.getIndex();
         this.key = node.getKey();
+        this.kind = node.getKind();
     }
 
     private NodeImpl() {
@@ -154,6 +161,10 @@ public final class NodeImpl implements P
         this.key = null;
     }
 
+    public void setParameterIndex(final Integer parameterIndex) {
+        this.parameterIndex = parameterIndex;
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -171,6 +182,21 @@ public final class NodeImpl implements P
         this.index = null;
     }
 
+    public ElementKind getKind() {
+        return kind;
+    }
+
+    public void setKind(ElementKind kind) {
+        this.kind = kind;
+    }
+
+    public <T extends Node> T as(final Class<T> nodeType) {
+        if (nodeType.isInstance(this)) {
+            return nodeType.cast(this);
+        }
+        throw new ClassCastException("Type " + nodeType + " not supported");
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -205,6 +231,9 @@ public final class NodeImpl implements P
         if (name != null ? !name.equals(node.name) : node.name != null) {
             return false;
         }
+        if (kind != null ? !kind.equals(node.kind) : node.kind != null) {
+            return false;
+        }
 
         return true;
     }
@@ -218,6 +247,129 @@ public final class NodeImpl implements P
         result = 31 * result + (inIterable ? 1 : 0);
         result = 31 * result + (index != null ? index.hashCode() : 0);
         result = 31 * result + (key != null ? key.hashCode() : 0);
+        result = 31 * result + (kind != null ? kind.hashCode() : 0);
         return result;
     }
+
+    public int getParameterIndex() {
+        return parameterIndex;
+    }
+
+    public List<Class<?>> getParameterTypes() {
+        return parameterTypes;
+    }
+
+    public void setParameterTypes(final List<Class<?>> parameterTypes) {
+        this.parameterTypes = parameterTypes;
+    }
+
+    public static class ParameterNodeImpl extends NodeImpl implements Path.ParameterNode {
+        public ParameterNodeImpl(final Node cast) {
+            super(cast);
+            if (ParameterNodeImpl.class.isInstance(cast)) {
+                setParameterIndex(ParameterNodeImpl.class.cast(cast).getParameterIndex());
+            }
+        }
+
+        public ParameterNodeImpl(final String name, final int idx) {
+            super(name);
+            setParameterIndex(idx);
+        }
+
+        public ElementKind getKind() {
+            return ElementKind.PARAMETER;
+        }
+    }
+
+    public static class ConstructorNodeImpl extends NodeImpl implements Path.ConstructorNode {
+        public ConstructorNodeImpl(final Node cast) {
+            super(cast);
+            if (NodeImpl.class.isInstance(cast)) {
+                setParameterTypes(NodeImpl.class.cast(cast).parameterTypes);
+            }
+        }
+
+        public ConstructorNodeImpl(final String simpleName, List<Class<?>> paramTypes) {
+            super(simpleName);
+            setParameterTypes(paramTypes);
+        }
+
+        public ElementKind getKind() {
+            return ElementKind.CONSTRUCTOR;
+        }
+    }
+
+    public static class CrossParameterNodeImpl extends NodeImpl implements Path.CrossParameterNode {
+        public CrossParameterNodeImpl() {
+            super("<cross-parameter>");
+        }
+
+        public CrossParameterNodeImpl(final Node cast) {
+            super(cast);
+        }
+
+        public ElementKind getKind() {
+            return ElementKind.CROSS_PARAMETER;
+        }
+    }
+
+    public static class MethodNodeImpl extends NodeImpl implements Path.MethodNode {
+        public MethodNodeImpl(final Node cast) {
+            super(cast);
+            if (MethodNodeImpl.class.isInstance(cast)) {
+                setParameterTypes(MethodNodeImpl.class.cast(cast).getParameterTypes());
+            }
+        }
+
+        public MethodNodeImpl(final String name, final List<Class<?>> classes) {
+            super(name);
+            setParameterTypes(classes);
+        }
+
+        public ElementKind getKind() {
+            return ElementKind.METHOD;
+        }
+    }
+
+    public static class ReturnValueNodeImpl extends NodeImpl implements Path.ReturnValueNode {
+        public ReturnValueNodeImpl(final Node cast) {
+            super(cast);
+        }
+
+        public ReturnValueNodeImpl() {
+            super("<return value>");
+        }
+
+        public ElementKind getKind() {
+            return ElementKind.RETURN_VALUE;
+        }
+    }
+
+    public static class PropertyNodeImpl extends NodeImpl implements Path.PropertyNode {
+        public PropertyNodeImpl(final String name) {
+            super(name);
+        }
+
+        public PropertyNodeImpl(final Node cast) {
+            super(cast);
+        }
+
+        public ElementKind getKind() {
+            return ElementKind.PROPERTY;
+        }
+    }
+
+    public static class BeanNodeImpl extends NodeImpl implements Path.BeanNode {
+        public BeanNodeImpl() {
+            // no-op
+        }
+
+        public BeanNodeImpl(final Node cast) {
+            super(cast);
+        }
+
+        public ElementKind getKind() {
+            return ElementKind.BEAN;
+        }
+    }
 }

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/PathImpl.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/PathImpl.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/PathImpl.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/PathImpl.java Mon Jul  1 10:06:18 2013
@@ -19,7 +19,6 @@
 package org.apache.bval.jsr303.util;
 
 import javax.validation.Path;
-
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -97,20 +96,19 @@ public class PathImpl implements Path, S
      */
     public static PathImpl createPathFromString(String propertyPath) {
         if (propertyPath == null || propertyPath.length() == 0) {
-            return create(null);
+            return create();
         }
         return PathNavigation.navigateAndReturn(propertyPath, new PathImplBuilder());
     }
 
     /**
      * Create a {@link PathImpl} instance representing the specified path.
-     * 
-     * @param name
+     *
      * @return PathImpl
      */
-    public static PathImpl create(String name) {
-        PathImpl path = new PathImpl();
-        NodeImpl node = new NodeImpl(name);
+    public static PathImpl create() {
+        final PathImpl path = new PathImpl();
+        final NodeImpl node = new NodeImpl.BeanNodeImpl();
         path.addNode(node);
         return path;
     }
@@ -127,9 +125,37 @@ public class PathImpl implements Path, S
 
     private PathImpl(Path path) {
         this.nodeList = new ArrayList<Node>();
-        for (Object aPath : path) {
-            nodeList.add(new NodeImpl((Node) aPath));
+        for (final Object aPath : path) {
+            nodeList.add(newNode(Node.class.cast(aPath)));
+        }
+    }
+
+    private static Node newNode(final Node cast) {
+        if (PropertyNode.class.isInstance(cast)) {
+            return new NodeImpl.PropertyNodeImpl(cast);
+        }
+        if (BeanNode.class.isInstance(cast)) {
+            return new NodeImpl.BeanNodeImpl(cast);
+        }
+        if (MethodNode.class.isInstance(cast)) {
+            return new NodeImpl.MethodNodeImpl(cast);
+        }
+        if (ConstructorNode.class.isInstance(cast)) {
+            return new NodeImpl.ConstructorNodeImpl(cast);
         }
+        if (ConstructorNode.class.isInstance(cast)) {
+            return new NodeImpl.ConstructorNodeImpl(cast);
+        }
+        if (ReturnValueNode.class.isInstance(cast)) {
+            return new NodeImpl.ReturnValueNodeImpl(cast);
+        }
+        if (ParameterNode.class.isInstance(cast)) {
+            return new NodeImpl.ParameterNodeImpl(cast);
+        }
+        if (CrossParameterNode.class.isInstance(cast)) {
+            return new NodeImpl.CrossParameterNodeImpl(cast);
+        }
+        return new NodeImpl(cast);
     }
 
     private PathImpl() {
@@ -194,12 +220,26 @@ public class PathImpl implements Path, S
     public void addProperty(String name) {
         if (!nodeList.isEmpty()) {
             NodeImpl leaf = getLeafNode();
-            if (leaf != null && leaf.isInIterable() && leaf.getName() == null) {
+            if (leaf != null && leaf.isInIterable() && leaf.getName() == null) { // TODO: avoid to be here
+                if (!PropertyNode.class.isInstance(leaf)) {
+                    final NodeImpl tmp = new NodeImpl.PropertyNodeImpl(leaf);
+                    removeLeafNode();
+                    addNode(tmp);
+                    leaf = tmp;
+                }
                 leaf.setName(name);
                 return;
             }
         }
-        addNode(new NodeImpl(name));
+
+        final NodeImpl node;
+        if ("<cross-parameter>".equals(name)) {
+            node = new NodeImpl.CrossParameterNodeImpl();
+        } else {
+            node = new NodeImpl.PropertyNodeImpl(name);
+        }
+        addNode(node);
+
     }
 
     /**

Added: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/Proxies.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/Proxies.java?rev=1498347&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/Proxies.java (added)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/Proxies.java Mon Jul  1 10:06:18 2013
@@ -0,0 +1,33 @@
+/*
+ * 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.util;
+
+public final class Proxies {
+    // get rid of proxies which probably contains wrong annotation metamodel
+    public static <T> Class<?> classFor(final Class<?> clazz) { // TODO: do we want a SPI with impl for guice, owb, openejb, ...?
+        if (!clazz.getSimpleName().contains("$$")) { // a lot of proxies use this convention to avoid conflicts with inner/anonymous classes
+            return clazz;
+        }
+        return classFor(clazz.getSuperclass());
+    }
+
+    private Proxies() {
+        // no-op
+    }
+}

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/SecureActions.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/SecureActions.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/SecureActions.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/SecureActions.java Mon Jul  1 10:06:18 2013
@@ -18,17 +18,17 @@
  */
 package org.apache.bval.jsr303.util;
 
+import org.apache.bval.jsr303.ConfigurationImpl;
+import org.apache.bval.util.PrivilegedActions;
+
+import javax.validation.ValidatorFactory;
 import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.security.PrivilegedAction;
 
-import javax.validation.ValidatorFactory;
-
-import org.apache.bval.jsr303.ConfigurationImpl;
-import org.apache.bval.util.PrivilegedActions;
-
 /**
  * Description: utility methods to perform actions with AccessController or without.<br/>
  */
@@ -79,19 +79,46 @@ public class SecureActions extends Privi
         };
     }
 
+    public static PrivilegedAction<Constructor<?>> getDeclaredConstructor(final Class<?> clazz, final Class<?>... parameters) {
+      return new PrivilegedAction<Constructor<?>>() {
+          public Constructor<?> run() {
+              try {
+                  return clazz.getDeclaredConstructor(parameters);
+              } catch (final NoSuchMethodException e) {
+                  return null;
+              }
+          }
+      };
+    }
 
+    public static PrivilegedAction<Method> getDeclaredMethod(final Class<?> clazz, final String name, final Class<?>... parameters) {
+        return new PrivilegedAction<Method>() {
+            public Method run() {
+                try {
+                    return clazz.getDeclaredMethod(name, parameters);
+                } catch (final NoSuchMethodException e) {
+                    return null;
+                }
+            }
+        };
+    }
 
-    /**
-     * Create a privileged action to get all methods declared by the specified class.
-     */
     public static PrivilegedAction<Method[]> getDeclaredMethods(final Class<?> clazz) {
-      // XXX 2011-03-27 jw: Inconsistent behaviour.
-      // doGetDeclaredFields() is setting fields accessible, but here we don't.
-      return new PrivilegedAction<Method[]>() {
-          public Method[] run() {
-            return clazz.getDeclaredMethods();
-        }
-      };
+        // XXX 2011-03-27 jw: Inconsistent behaviour.
+        // doGetDeclaredFields() is setting fields accessible, but here we don't.
+        return new PrivilegedAction<Method[]>() {
+            public Method[] run() {
+                return clazz.getDeclaredMethods();
+            }
+        };
+    }
+
+    public static PrivilegedAction<Constructor<?>[]> getDeclaredConstructors(final Class<?> clazz) {
+        return new PrivilegedAction<Constructor<?>[]>() {
+            public Constructor<?>[] run() {
+                return clazz.getDeclaredConstructors();
+            }
+        };
     }
 
     /**

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationIgnores.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationIgnores.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationIgnores.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationIgnores.java Mon Jul  1 10:06:18 2013
@@ -20,9 +20,7 @@ package org.apache.bval.jsr303.xml;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Member;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -50,11 +48,13 @@ public final class AnnotationIgnores {
      * <code>true</code> in the configuration
      * for this class.
      */
-    private final Map<Class<?>, List<Member>> ignoreAnnotationOnMember =
-          new HashMap<Class<?>, List<Member>>();
+    private final Map<Class<?>, Map<Member, Boolean>> ignoreAnnotationOnMember = new HashMap<Class<?>, Map<Member, Boolean>>();
 
-    private final Map<Class<?>, Boolean> ignoreAnnotationOnClass =
-          new HashMap<Class<?>, Boolean>();
+    private final Map<Class<?>, Boolean> ignoreAnnotationOnClass = new HashMap<Class<?>, Boolean>();
+
+    private final Map<Class<?>, Map<Member, Map<Integer, Boolean>>> ignoreAnnotationOnParameter = new HashMap<Class<?>, Map<Member, Map<Integer, Boolean>>>();
+    private final Map<Member, Boolean> ignoreAnnotationOnReturn = new HashMap<Member, Boolean>();
+    private final Map<Member, Boolean> ignoreAnnotationOnCrossParameter = new HashMap<Member, Boolean>();
 
     /**
      * Record the ignore state for a particular annotation type.
@@ -79,14 +79,14 @@ public final class AnnotationIgnores {
      * Ignore annotations on a particular {@link Member} of a class.
      * @param member
      */
-    public void setIgnoreAnnotationsOnMember(Member member) {
+    public void setIgnoreAnnotationsOnMember(Member member, boolean value) {
         Class<?> beanClass = member.getDeclaringClass();
-        List<Member> memberList = ignoreAnnotationOnMember.get(beanClass);
+        Map<Member, Boolean> memberList = ignoreAnnotationOnMember.get(beanClass);
         if (memberList == null) {
-            memberList = new ArrayList<Member>();
+            memberList = new HashMap<Member, Boolean>();
             ignoreAnnotationOnMember.put(beanClass, memberList);
         }
-        memberList.add(member);
+        memberList.put(member, value);
     }
 
     /**
@@ -94,22 +94,50 @@ public final class AnnotationIgnores {
      * @param member
      * @return boolean
      */
-    public boolean isIgnoreAnnotations(Member member) {
-        boolean ignoreAnnotation;
-        Class<?> clazz = member.getDeclaringClass();
-        List<Member> ignoreAnnotationForMembers = ignoreAnnotationOnMember.get(clazz);
-        if (ignoreAnnotationForMembers == null ||
-              !ignoreAnnotationForMembers.contains(member)) {
-            ignoreAnnotation = getDefaultIgnoreAnnotation(clazz);
-        } else {
-            ignoreAnnotation = ignoreAnnotationForMembers.contains(member);
+    public boolean isIgnoreAnnotations(final Member member) {
+        final Class<?> clazz = member.getDeclaringClass();
+        final Map<Member, Boolean> ignoreAnnotationForMembers = ignoreAnnotationOnMember.get(clazz);
+        if (ignoreAnnotationForMembers != null && ignoreAnnotationForMembers.containsKey(member)) {
+            final boolean value = ignoreAnnotationForMembers.get(member);
+            if (value) {
+                logMessage(member, clazz);
+            }
+            return value;
         }
+
+        final boolean ignoreAnnotation = getDefaultIgnoreAnnotation(clazz);
         if (ignoreAnnotation) {
             logMessage(member, clazz);
         }
         return ignoreAnnotation;
     }
 
+    public void setIgnoreAnnotationsOnParameter(final Member method, final int i, final boolean value) {
+        final Class<?> beanClass = method.getDeclaringClass();
+        Map<Member, Map<Integer, Boolean>> memberList = ignoreAnnotationOnParameter.get(beanClass);
+        if (memberList == null) {
+            memberList = new HashMap<Member, Map<Integer, Boolean>>();
+            ignoreAnnotationOnParameter.put(beanClass, memberList);
+        }
+        Map<Integer, Boolean> indexes = memberList.get(method);
+        if (indexes == null) {
+            indexes = new HashMap<Integer, Boolean>();
+            memberList.put(method, indexes);
+        }
+        indexes.put(i, value);
+    }
+
+    public boolean isIgnoreAnnotationOnParameter(final Member m, final int i) {
+        final Map<Member, Map<Integer, Boolean>> members = ignoreAnnotationOnParameter.get(m.getDeclaringClass());
+        if (members != null) {
+            final Map<Integer, Boolean> indexes = members.get(m);
+            if (indexes != null && indexes.containsKey(i)) {
+                return indexes.get(i);
+            }
+        }
+        return false;
+    }
+
     private void logMessage(Member member, Class<?> clazz) {
         String type;
         if (member instanceof Field) {
@@ -146,4 +174,28 @@ public final class AnnotationIgnores {
         }
         return ignoreAnnotation;
     }
+
+    public void setIgnoreAnnotationOnReturn(final Member method, final boolean value) {
+        ignoreAnnotationOnReturn.put(method, value);
+    }
+
+    public boolean isIgnoreAnnotationOnReturn(final Member m) {
+        final Boolean value = ignoreAnnotationOnReturn.get(m);
+        if (value != null) {
+            return value;
+        }
+        return false;
+    }
+
+    public void setIgnoreAnnotationOnCrossParameter(final Member method, final boolean value) {
+        ignoreAnnotationOnCrossParameter.put(method, value);
+    }
+
+    public boolean isIgnoreAnnotationOnCrossParameter(final Member m) {
+        final Boolean value = ignoreAnnotationOnCrossParameter.get(m);
+        if (value != null) {
+            return value;
+        }
+        return false;
+    }
 }

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxy.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxy.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxy.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxy.java Mon Jul  1 10:06:18 2013
@@ -29,14 +29,14 @@ import java.util.TreeSet;
 
 import org.apache.bval.jsr303.util.SecureActions;
 
+import javax.validation.Valid;
+
 /**
  * Description: <br/>
  * InvocationHandler implementation of <code>Annotation</code> that pretends it
  * is a "real" source code annotation.
  * <p/>
  */
-// TODO move this guy up to org.apache.bval.jsr303 or
-// org.apache.bval.jsr303.model
 class AnnotationProxy implements Annotation, InvocationHandler, Serializable {
 
     /** Serialization version */
@@ -72,7 +72,8 @@ class AnnotationProxy implements Annotat
                 throw new IllegalArgumentException("No value provided for " + m.getName());
             }
         }
-        if (processedValuesFromDescriptor != descriptor.size()) {
+        if (processedValuesFromDescriptor != descriptor.size()
+                && !Valid.class.equals(annotationType)) {
             throw new RuntimeException("Trying to instanciate " + annotationType + " with unknown paramters.");
         }
         return result;

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxyBuilder.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxyBuilder.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxyBuilder.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxyBuilder.java Mon Jul  1 10:06:18 2013
@@ -16,6 +16,13 @@
  */
 package org.apache.bval.jsr303.xml;
 
+import org.apache.bval.jsr303.ConstraintAnnotationAttributes;
+import org.apache.bval.jsr303.util.SecureActions;
+
+import javax.validation.Payload;
+import javax.validation.Valid;
+import javax.validation.ValidationException;
+import javax.validation.groups.ConvertGroup;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationHandler;
@@ -27,12 +34,6 @@ import java.security.PrivilegedAction;
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.validation.Payload;
-import javax.validation.ValidationException;
-
-import org.apache.bval.jsr303.ConstraintAnnotationAttributes;
-import org.apache.bval.jsr303.util.SecureActions;
-
 /**
  * Description: Holds the information and creates an annotation proxy during xml
  * parsing of validation mapping constraints. <br/>
@@ -199,4 +200,35 @@ final public class AnnotationProxyBuilde
             return action.run();
         }
     }
+
+
+    public static final class ValidAnnotation implements Valid {
+        public static final ValidAnnotation INSTANCE = new ValidAnnotation();
+
+        public Class<? extends Annotation> annotationType() {
+            return Valid.class;
+        }
+    }
+
+    public static final class ConverGroupAnnotation implements ConvertGroup {
+        private final Class<?> from;
+        private final Class<?> to;
+
+        public ConverGroupAnnotation(final Class<?> from, final Class<?> to) {
+            this.from = from;
+            this.to = to;
+        }
+
+        public Class<? extends Annotation> annotationType() {
+            return ConvertGroup.class;
+        }
+
+        public Class<?> from() {
+            return from;
+        }
+
+        public Class<?> to() {
+            return to;
+        }
+    }
 }

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/MetaConstraint.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/MetaConstraint.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/MetaConstraint.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/MetaConstraint.java Mon Jul  1 10:06:18 2013
@@ -17,12 +17,14 @@
 package org.apache.bval.jsr303.xml;
 
 
+import org.apache.bval.ConstructorAccess;
 import org.apache.bval.util.AccessStrategy;
 import org.apache.bval.util.FieldAccess;
 import org.apache.bval.util.MethodAccess;
 
 import javax.validation.ValidationException;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
@@ -43,6 +45,8 @@ public class MetaConstraint<T, A extends
     /** constraint annotation (proxy) */
     private final A annotation;
 
+    private Integer index; // for parameters
+
     private final AccessStrategy accessStrategy;
 
     /**
@@ -57,12 +61,11 @@ public class MetaConstraint<T, A extends
         this.annotation = annotation;
         if (member != null) {
             accessStrategy = createAccessStrategy(member);
-            if (accessStrategy == null || accessStrategy.getPropertyName() ==
-                  null) { // can happen if method does not follow the bean convention
-                throw new ValidationException(
-                      "Annotated method does not follow the JavaBeans naming convention: " +
-                            member);
+            /*TODO: see if can really be removed
+            if (accessStrategy == null || accessStrategy.getPropertyName() == null) { // can happen if method does not follow the bean convention
+                throw new ValidationException("Annotated method does not follow the JavaBeans naming convention: " + member);
             }
+            */
         } else {
             this.accessStrategy = null;
         }
@@ -73,6 +76,8 @@ public class MetaConstraint<T, A extends
             return new MethodAccess((Method) member);
         } else if (member instanceof Field) {
             return new FieldAccess((Field) member);
+        } else if (member instanceof Constructor<?>) {
+            return new ConstructorAccess((Constructor<?>) member);
         } else {
             return null; // class level
         }
@@ -109,4 +114,12 @@ public class MetaConstraint<T, A extends
     public AccessStrategy getAccessStrategy() {
         return accessStrategy;
     }
+
+    public Integer getIndex() {
+        return index;
+    }
+
+    public void setIndex(final int index) {
+        this.index = index;
+    }
 }

Modified: bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationMappingParser.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationMappingParser.java?rev=1498347&r1=1498346&r2=1498347&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationMappingParser.java (original)
+++ bval/branches/bval-11/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationMappingParser.java Mon Jul  1 10:06:18 2013
@@ -17,10 +17,33 @@
 package org.apache.bval.jsr303.xml;
 
 
+import org.apache.bval.jsr303.ApacheValidatorFactory;
+import org.apache.bval.jsr303.ConstraintAnnotationAttributes;
+import org.apache.bval.jsr303.util.EnumerationConverter;
+import org.apache.bval.jsr303.util.IOUtils;
+import org.apache.bval.jsr303.util.SecureActions;
+import org.apache.bval.util.FieldAccess;
+import org.apache.bval.util.MethodAccess;
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.Converter;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
+import javax.validation.Payload;
+import javax.validation.ValidationException;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
@@ -28,54 +51,28 @@ import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import javax.validation.Constraint;
-import javax.validation.ConstraintValidator;
-import javax.validation.Payload;
-import javax.validation.ValidationException;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-
-import org.apache.bval.jsr303.ApacheValidatorFactory;
-import org.apache.bval.jsr303.ConstraintAnnotationAttributes;
-import org.apache.bval.jsr303.util.EnumerationConverter;
-import org.apache.bval.jsr303.util.IOUtils;
-import org.apache.bval.jsr303.util.SecureActions;
-import org.apache.bval.util.FieldAccess;
-import org.apache.bval.util.MethodAccess;
-import org.apache.commons.beanutils.ConvertUtils;
-import org.apache.commons.beanutils.Converter;
-import org.apache.commons.lang3.StringUtils;
-
-
 /**
  * Uses JAXB to parse constraints.xml based on validation-mapping-1.0.xsd.<br>
  */
 @SuppressWarnings("restriction")
 public class ValidationMappingParser {
     //    private static final Log log = LogFactory.getLog(ValidationMappingParser.class);
-    private static final String VALIDATION_MAPPING_XSD = "META-INF/validation-mapping-1.0.xsd";
+    private static final String VALIDATION_MAPPING_XSD = "META-INF/validation-mapping-1.1.xsd";
 
     private static final Set<ConstraintAnnotationAttributes> RESERVED_PARAMS = Collections.unmodifiableSet(EnumSet.of(
         ConstraintAnnotationAttributes.GROUPS, ConstraintAnnotationAttributes.MESSAGE,
-        ConstraintAnnotationAttributes.PAYLOAD));
+        ConstraintAnnotationAttributes.PAYLOAD, ConstraintAnnotationAttributes.VALIDATION_APPLIES_TO));
 
     private final Set<Class<?>> processedClasses;
     private final ApacheValidatorFactory factory;
 
-    /**
-     * Create a new ValidationMappingParser instance.
-     * @param factory
-     */
     public ValidationMappingParser(ApacheValidatorFactory factory) {
         this.factory = factory;
         this.processedClasses = new HashSet<Class<?>>();
@@ -87,12 +84,12 @@ public class ValidationMappingParser {
      * @param xmlStreams - one or more contraints.xml file streams to parse
      */
     public void processMappingConfig(Set<InputStream> xmlStreams) throws ValidationException {
-        for (InputStream xmlStream : xmlStreams) {
+        for (final InputStream xmlStream : xmlStreams) {
             ConstraintMappingsType mapping = parseXmlMappings(xmlStream);
 
-            String defaultPackage = mapping.getDefaultPackage();
+            final String defaultPackage = mapping.getDefaultPackage();
             processConstraintDefinitions(mapping.getConstraintDefinition(), defaultPackage);
-            for (BeanType bean : mapping.getBean()) {
+            for (final BeanType bean : mapping.getBean()) {
                 Class<?> beanClass = loadClass(bean.getClazz(), defaultPackage);
                 if (!processedClasses.add(beanClass)) {
                     // spec: A given class must not be described more than once amongst all
@@ -100,11 +97,14 @@ public class ValidationMappingParser {
                     throw new ValidationException(
                           beanClass.getName() + " has already be configured in xml.");
                 }
-                factory.getAnnotationIgnores()
-                      .setDefaultIgnoreAnnotation(beanClass, bean.isIgnoreAnnotations());
+
+                boolean ignoreAnnotations = bean.getIgnoreAnnotations() == null ? true : bean.getIgnoreAnnotations();
+                factory.getAnnotationIgnores().setDefaultIgnoreAnnotation(beanClass, ignoreAnnotations);
                 processClassLevel(bean.getClassType(), beanClass, defaultPackage);
-                processFieldLevel(bean.getField(), beanClass, defaultPackage);
-                processPropertyLevel(bean.getGetter(), beanClass, defaultPackage);
+                processConstructorLevel(bean.getConstructor(), beanClass, defaultPackage, ignoreAnnotations);
+                processFieldLevel(bean.getField(), beanClass, defaultPackage, ignoreAnnotations);
+                final Collection<String> potentialMethodName = processPropertyLevel(bean.getGetter(), beanClass, defaultPackage, ignoreAnnotations);
+                processMethodLevel(bean.getMethod(), beanClass, defaultPackage, ignoreAnnotations, potentialMethodName);
                 processedClasses.add(beanClass);
             }
         }
@@ -122,10 +122,14 @@ public class ValidationMappingParser {
                   unmarshaller.unmarshal(stream, ConstraintMappingsType.class);
             mappings = root.getValue();
         } catch (JAXBException e) {
-            throw new ValidationException("Failed to parse XML deployment descriptor file.",
-                  e);
+            throw new ValidationException("Failed to parse XML deployment descriptor file.", e);
         } finally {
             IOUtils.closeQuietly(in);
+            try {
+                in.reset(); // can be read several times + we ensured it was re-readable in addMapping()
+            } catch (final IOException e) {
+                // no-op
+            }
         }
         return mappings;
     }
@@ -142,9 +146,8 @@ public class ValidationMappingParser {
         }
 
         // ignore annotation
-        if (classType.isIgnoreAnnotations() != null) {
-            factory.getAnnotationIgnores()
-                  .setIgnoreAnnotationsOnClass(beanClass, classType.isIgnoreAnnotations());
+        if (classType.getIgnoreAnnotations() != null) {
+            factory.getAnnotationIgnores().setIgnoreAnnotationsOnClass(beanClass, classType.getIgnoreAnnotations());
         }
 
         // group sequence
@@ -164,11 +167,11 @@ public class ValidationMappingParser {
 
     @SuppressWarnings("unchecked")
     private <A extends Annotation, T> MetaConstraint<?, ?> createConstraint(
-          ConstraintType constraint, Class<T> beanClass, Member member,
-          String defaultPackage) {
-        Class<A> annotationClass =
-              (Class<A>) loadClass(constraint.getAnnotation(), defaultPackage);
-        AnnotationProxyBuilder<A> annoBuilder = new AnnotationProxyBuilder<A>(annotationClass);
+            final ConstraintType constraint, final Class<T> beanClass,
+            final Member member, final String defaultPackage) {
+
+        final Class<A> annotationClass = (Class<A>) loadClass(constraint.getAnnotation(), defaultPackage);
+        final AnnotationProxyBuilder<A> annoBuilder = new AnnotationProxyBuilder<A>(annotationClass);
 
         if (constraint.getMessage() != null) {
             annoBuilder.setMessage(constraint.getMessage());
@@ -176,11 +179,12 @@ public class ValidationMappingParser {
         annoBuilder.setGroups(getGroups(constraint.getGroups(), defaultPackage));
         annoBuilder.setPayload(getPayload(constraint.getPayload(), defaultPackage));
 
-        for (ElementType elementType : constraint.getElement()) {
-            String name = elementType.getName();
+        for (final ElementType elementType : constraint.getElement()) {
+            final String name = elementType.getName();
             checkValidName(name);
-            Class<?> returnType = getAnnotationParameterType(annotationClass, name);
-            Object elementValue = getElementValue(elementType, returnType, defaultPackage);
+
+            final Class<?> returnType = getAnnotationParameterType(annotationClass, name);
+            final Object elementValue = getElementValue(elementType, returnType, defaultPackage);
             annoBuilder.putValue(name, elementValue);
         }
         return new MetaConstraint<T, A>(beanClass, member, annoBuilder.createAnnotation());
@@ -277,6 +281,25 @@ public class ValidationMappingParser {
          */
         if (returnType.equals(Class.class)) {
             value = toQualifiedClassName(value, defaultPackage);
+        } else if (Byte.class.equals(returnType) || byte.class.equals(returnType)) { // spec mandates it
+            return Byte.parseByte(value);
+        } else if (Short.class.equals(returnType) || short.class.equals(returnType)) {
+            return Short.parseShort(value);
+        } else if (Integer.class.equals(returnType) || int.class.equals(returnType)) {
+            return Integer.parseInt(value);
+        } else if (Long.class.equals(returnType) || long.class.equals(returnType)) {
+            return Long.parseLong(value);
+        } else if (Float.class.equals(returnType) || float.class.equals(returnType)) {
+            return Float.parseFloat(value);
+        } else if (Double.class.equals(returnType) || double.class.equals(returnType)) {
+            return Double.parseDouble(value);
+        } else if (Boolean.class.equals(returnType) || boolean.class.equals(returnType)) {
+            return Boolean.parseBoolean(value);
+        } else if (Character.class.equals(returnType) || char.class.equals(returnType)) {
+            if (value.length() > 1) {
+                throw new IllegalArgumentException("a char has a length of 1");
+            }
+            return value.charAt(0);
         }
 
         /* Converter lookup */
@@ -311,8 +334,8 @@ public class ValidationMappingParser {
         }
 
         List<Class<?>> groupList = new ArrayList<Class<?>>();
-        for (JAXBElement<String> groupClass : groupsType.getValue()) {
-            groupList.add(loadClass(groupClass.getValue(), defaultPackage));
+        for (String groupClass : groupsType.getValue()) {
+            groupList.add(loadClass(groupClass, defaultPackage));
         }
         return groupList.toArray(new Class[groupList.size()]);
     }
@@ -326,8 +349,8 @@ public class ValidationMappingParser {
         }
 
         List<Class<? extends Payload>> payloadList = new ArrayList<Class<? extends Payload>>();
-        for (JAXBElement<String> groupClass : payloadType.getValue()) {
-            Class<?> payload = loadClass(groupClass.getValue(), defaultPackage);
+        for (String groupClass : payloadType.getValue()) {
+            Class<?> payload = loadClass(groupClass, defaultPackage);
             if (!Payload.class.isAssignableFrom(payload)) {
                 throw new ValidationException("Specified payload class " + payload.getName() +
                       " does not implement javax.validation.Payload");
@@ -343,8 +366,8 @@ public class ValidationMappingParser {
         if (groupSequenceType != null) {
             Class<?>[] groupSequence = new Class<?>[groupSequenceType.getValue().size()];
             int i=0;
-            for (JAXBElement<String> groupName : groupSequenceType.getValue()) {
-                Class<?> group = loadClass(groupName.getValue(), defaultPackage);
+            for (String groupName : groupSequenceType.getValue()) {
+                Class<?> group = loadClass(groupName, defaultPackage);
                 groupSequence[i++] = group;
             }
             return groupSequence;
@@ -353,9 +376,196 @@ public class ValidationMappingParser {
         }
     }
 
-    private void processFieldLevel(List<FieldType> fields, Class<?> beanClass,
-                                   String defaultPackage) {
-        List<String> fieldNames = new ArrayList<String>();
+    private <A> void processMethodLevel(final List<MethodType> methods, final Class<A> beanClass, final String defaultPackage, final boolean parentIgnoreAnn, final Collection<String> getters) {
+        final List<String> methodNames = new ArrayList<String>();
+        for (final MethodType methodType : methods) {
+            final String methodName = methodType.getName();
+            if (methodNames.contains(methodName) || getters.contains(methodName)) {
+                throw new ValidationException(methodName + " is defined more than once in mapping xml for bean " + beanClass.getName());
+            } else {
+                methodNames.add(methodName);
+            }
+            final Method method = doPrivileged(SecureActions.getDeclaredMethod(beanClass, methodName, toTypes(methodType.getParameter(), defaultPackage)));
+            if (method == null) {
+                throw new ValidationException(beanClass.getName() + " does not contain the method  " + methodName);
+            }
+
+            // ignore annotations
+            final boolean ignoreMethodAnnotation = methodType.getIgnoreAnnotations() == null ? parentIgnoreAnn : methodType.getIgnoreAnnotations();
+            factory.getAnnotationIgnores().setIgnoreAnnotationsOnMember(method, ignoreMethodAnnotation);
+
+            final boolean ignoreAnn;
+            if (methodType.getIgnoreAnnotations() != null) {
+                ignoreAnn = methodType.getIgnoreAnnotations();
+            } else {
+                ignoreAnn = parentIgnoreAnn;
+            }
+
+            // constraints
+            int i = 0;
+            for (final ParameterType p : methodType.getParameter()) {
+                for (final ConstraintType constraintType : p.getConstraint()) {
+                    final MetaConstraint<?, ?> constraint = createConstraint(constraintType, beanClass, method, defaultPackage);
+                    constraint.setIndex(i);
+                    factory.addMetaConstraint(beanClass, constraint);
+                }
+                if (p.getValid() != null) {
+                    final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, method, AnnotationProxyBuilder.ValidAnnotation.INSTANCE);
+                    constraint.setIndex(i);
+                    factory.addMetaConstraint(beanClass, constraint);
+                }
+
+                if (p.getConvertGroup() != null) {
+                    for (final GroupConversionType groupConversion : p.getConvertGroup()) {
+                        final Class<?> from = loadClass(groupConversion.getFrom(), defaultPackage);
+                        final Class<?> to = loadClass(groupConversion.getTo(), defaultPackage);
+                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, method, new AnnotationProxyBuilder.ConverGroupAnnotation(from, to));
+                        constraint.setIndex(i);
+                        factory.addMetaConstraint(beanClass, constraint);
+                    }
+                }
+
+                boolean ignoreParametersAnnotation = p.getIgnoreAnnotations() == null ? ignoreMethodAnnotation : p.getIgnoreAnnotations();
+                factory.getAnnotationIgnores().setIgnoreAnnotationsOnParameter(method, i, ignoreParametersAnnotation);
+
+                i++;
+            }
+
+            final ReturnValueType returnValue = methodType.getReturnValue();
+            if (returnValue != null) {
+                for (final ConstraintType constraintType : returnValue.getConstraint()) {
+                    final MetaConstraint<?, ?> constraint = createConstraint(constraintType, beanClass, method, defaultPackage);
+                    factory.addMetaConstraint(beanClass, constraint);
+                }
+                if (returnValue.getValid() != null) {
+                    final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, method, AnnotationProxyBuilder.ValidAnnotation.INSTANCE);
+                    factory.addMetaConstraint(beanClass, constraint);
+                }
+
+                if (returnValue.getConvertGroup() != null) {
+                    for (final GroupConversionType groupConversion : returnValue.getConvertGroup()) {
+                        final Class<?> from = loadClass(groupConversion.getFrom(), defaultPackage);
+                        final Class<?> to = loadClass(groupConversion.getTo(), defaultPackage);
+                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, method, new AnnotationProxyBuilder.ConverGroupAnnotation(from, to));
+                        factory.addMetaConstraint(beanClass, constraint);
+                    }
+                }
+                factory.getAnnotationIgnores().setIgnoreAnnotationOnReturn(method, returnValue.getIgnoreAnnotations() == null ? ignoreAnn : returnValue.getIgnoreAnnotations());
+            }
+
+            final CrossParameterType crossParameter = methodType.getCrossParameter();
+            if (crossParameter != null) {
+                for (final ConstraintType constraintType : crossParameter.getConstraint()) {
+                    final MetaConstraint<?, ?> constraint = createConstraint(constraintType, beanClass, method, defaultPackage);
+                    factory.addMetaConstraint(beanClass, constraint);
+                }
+                factory.getAnnotationIgnores().setIgnoreAnnotationOnCrossParameter(method, crossParameter.getIgnoreAnnotations() != null ? crossParameter.getIgnoreAnnotations() : ignoreAnn);
+            }
+        }
+    }
+
+    private <A> void processConstructorLevel(final List<ConstructorType> constructors, final Class<A> beanClass, final String defaultPackage, final boolean parentIgnore) {
+        for (final ConstructorType constructorType : constructors) {
+            final Constructor<?> constructor = doPrivileged(SecureActions.getDeclaredConstructor(beanClass, toTypes(constructorType.getParameter(), defaultPackage)));
+            if (constructor == null) {
+                throw new ValidationException(beanClass.getName() + " does not contain the constructor  " + constructorType);
+            }
+
+            // ignore annotations
+            final boolean ignoreMethodAnnotation = constructorType.getIgnoreAnnotations() == null ? parentIgnore : constructorType.getIgnoreAnnotations();
+            factory.getAnnotationIgnores().setIgnoreAnnotationsOnMember(constructor, ignoreMethodAnnotation);
+
+            final boolean ignoreAnn;
+            if (constructorType.getIgnoreAnnotations() != null) {
+                ignoreAnn = constructorType.getIgnoreAnnotations();
+            } else {
+                ignoreAnn = parentIgnore;
+            }
+
+            // constraints
+            int i = 0;
+            for (final ParameterType p : constructorType.getParameter()) {
+                for (final ConstraintType constraintType : p.getConstraint()) {
+                    final MetaConstraint<?, ?> constraint = createConstraint(constraintType, beanClass, constructor, defaultPackage);
+                    constraint.setIndex(i);
+                    factory.addMetaConstraint(beanClass, constraint);
+                }
+                if (p.getValid() != null) {
+                    final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, constructor, AnnotationProxyBuilder.ValidAnnotation.INSTANCE);
+                    constraint.setIndex(i);
+                    factory.addMetaConstraint(beanClass, constraint);
+                }
+
+                if (p.getConvertGroup() != null) {
+                    for (final GroupConversionType groupConversion : p.getConvertGroup()) {
+                        final Class<?> from = loadClass(groupConversion.getFrom(), defaultPackage);
+                        final Class<?> to = loadClass(groupConversion.getTo(), defaultPackage);
+                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, constructor, new AnnotationProxyBuilder.ConverGroupAnnotation(from, to));
+                        constraint.setIndex(i);
+                        factory.addMetaConstraint(beanClass, constraint);
+                    }
+                }
+
+                boolean ignoreParametersAnnotation = p.getIgnoreAnnotations() == null ? ignoreMethodAnnotation : p.getIgnoreAnnotations();
+                if (ignoreParametersAnnotation || (ignoreMethodAnnotation && p.getIgnoreAnnotations() == null)) {
+
+                }
+                factory.getAnnotationIgnores().setIgnoreAnnotationsOnParameter(constructor, i, p.getIgnoreAnnotations() != null ? p.getIgnoreAnnotations() : ignoreAnn);
+
+                i++;
+            }
+
+            final ReturnValueType returnValue = constructorType.getReturnValue();
+            if (returnValue != null) {
+                for (final ConstraintType constraintType : returnValue.getConstraint()) {
+                    final MetaConstraint<?, ?> constraint = createConstraint(constraintType, beanClass, constructor, defaultPackage);
+                    constraint.setIndex(-1);
+                    factory.addMetaConstraint(beanClass, constraint);
+                }
+                if (returnValue.getValid() != null) {
+                    final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, constructor, AnnotationProxyBuilder.ValidAnnotation.INSTANCE);
+                    constraint.setIndex(-1);
+                    factory.addMetaConstraint(beanClass, constraint);
+                }
+
+                if (returnValue.getConvertGroup() != null) {
+                    for (final GroupConversionType groupConversion : returnValue.getConvertGroup()) {
+                        final Class<?> from = loadClass(groupConversion.getFrom(), defaultPackage);
+                        final Class<?> to = loadClass(groupConversion.getTo(), defaultPackage);
+                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, constructor, new AnnotationProxyBuilder.ConverGroupAnnotation(from, to));
+                        constraint.setIndex(-1);
+                        factory.addMetaConstraint(beanClass, constraint);
+                    }
+                }
+                factory.getAnnotationIgnores().setIgnoreAnnotationOnReturn(constructor, returnValue.getIgnoreAnnotations() != null ? returnValue.getIgnoreAnnotations() : ignoreAnn);
+            }
+
+            final CrossParameterType crossParameter = constructorType.getCrossParameter();
+            if (crossParameter != null) {
+                for (final ConstraintType constraintType : crossParameter.getConstraint()) {
+                    final MetaConstraint<?, ?> constraint = createConstraint(constraintType, beanClass, constructor, defaultPackage);
+                    factory.addMetaConstraint(beanClass, constraint);
+                }
+                factory.getAnnotationIgnores().setIgnoreAnnotationOnCrossParameter(constructor, crossParameter.getIgnoreAnnotations() != null ? crossParameter.getIgnoreAnnotations() : ignoreAnn);
+            }
+        }
+    }
+
+    private Class<?>[] toTypes(final List<ParameterType> parameter, final String defaultPck) {
+        if (parameter == null) {
+            return null;
+        }
+        final Class<?>[] types = new Class<?>[parameter.size()];
+        int i = 0;
+        for (final ParameterType type : parameter) {
+            types[i++] = loadClass(type.getType(), defaultPck);
+        }
+        return types;
+    }
+
+    private <A> void processFieldLevel(List<FieldType> fields, Class<A> beanClass,
+                                       String defaultPackage, boolean ignoreAnnotations) {
+        final List<String> fieldNames = new ArrayList<String>();
         for (FieldType fieldType : fields) {
             String fieldName = fieldType.getName();
             if (fieldNames.contains(fieldName)) {
@@ -372,17 +582,21 @@ public class ValidationMappingParser {
             }
 
             // ignore annotations
-            boolean ignoreFieldAnnotation = fieldType.isIgnoreAnnotations() == null ? false :
-                  fieldType.isIgnoreAnnotations();
-            if (ignoreFieldAnnotation) {
-                factory.getAnnotationIgnores().setIgnoreAnnotationsOnMember(field);
-            }
+            final boolean ignoreFieldAnnotation = fieldType.getIgnoreAnnotations() == null ? ignoreAnnotations : fieldType.getIgnoreAnnotations();
+            factory.getAnnotationIgnores().setIgnoreAnnotationsOnMember(field, ignoreFieldAnnotation);
 
             // valid
             if (fieldType.getValid() != null) {
                 factory.addValid(beanClass, new FieldAccess(field));
             }
 
+            for (final GroupConversionType conversion : fieldType.getConvertGroup()) {
+                final Class<?> from = loadClass(conversion.getFrom(), defaultPackage);
+                final Class<?> to = loadClass(conversion.getTo(), defaultPackage);
+                final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, field, new AnnotationProxyBuilder.ConverGroupAnnotation(from, to));
+                factory.addMetaConstraint(beanClass, constraint);
+            }
+
             // constraints
             for (ConstraintType constraintType : fieldType.getConstraint()) {
                 MetaConstraint<?, ?> constraint =
@@ -392,17 +606,18 @@ public class ValidationMappingParser {
         }
     }
 
-    private void processPropertyLevel(List<GetterType> getters, Class<?> beanClass,
-                                      String defaultPackage) {
+    private <A> Collection<String> processPropertyLevel(List<GetterType> getters, Class<A> beanClass,
+                                      String defaultPackage, boolean ignoreAnnotatino) {
         List<String> getterNames = new ArrayList<String>();
         for (GetterType getterType : getters) {
-            String getterName = getterType.getName();
-            if (getterNames.contains(getterName)) {
+            final String getterName = getterType.getName();
+            final String methodName = "get" + StringUtils.capitalize(getterType.getName());
+            if (getterNames.contains(methodName)) {
                 throw new ValidationException(getterName +
                       " is defined more than once in mapping xml for bean " +
                       beanClass.getName());
             } else {
-                getterNames.add(getterName);
+                getterNames.add(methodName);
             }
             final Method method = getGetter(beanClass, getterName);
             if (method == null) {
@@ -411,17 +626,22 @@ public class ValidationMappingParser {
             }
 
             // ignore annotations
-            boolean ignoreGetterAnnotation = getterType.isIgnoreAnnotations() == null ? false :
-                  getterType.isIgnoreAnnotations();
-            if (ignoreGetterAnnotation) {
-                factory.getAnnotationIgnores().setIgnoreAnnotationsOnMember(method);
-            }
+            final boolean ignoreGetterAnnotation = getterType.getIgnoreAnnotations() == null ? ignoreAnnotatino : getterType.getIgnoreAnnotations();
+            factory.getAnnotationIgnores().setIgnoreAnnotationsOnMember(method, ignoreGetterAnnotation);
 
             // valid
             if (getterType.getValid() != null) {
                 factory.addValid(beanClass, new MethodAccess(getterName, method));
             }
 
+            // ConvertGroup
+            for (final GroupConversionType conversion : getterType.getConvertGroup()) {
+                final Class<?> from = loadClass(conversion.getFrom(), defaultPackage);
+                final Class<?> to = loadClass(conversion.getTo(), defaultPackage);
+                final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass, method, new AnnotationProxyBuilder.ConverGroupAnnotation(from, to));
+                factory.addMetaConstraint(beanClass, constraint);
+            }
+
             // constraints
             for (ConstraintType constraintType : getterType.getConstraint()) {
                 MetaConstraint<?, ?> metaConstraint =
@@ -429,6 +649,8 @@ public class ValidationMappingParser {
                 factory.addMetaConstraint(beanClass, metaConstraint);
             }
         }
+
+        return getterNames;
     }
 
     @SuppressWarnings("unchecked")
@@ -450,8 +672,8 @@ public class ValidationMappingParser {
              If include-existing-validator is set to false,
              ConstraintValidator defined on the constraint annotation are ignored.
               */
-            if (validatedByType.isIncludeExistingValidators() != null &&
-                  validatedByType.isIncludeExistingValidators()) {
+            if (validatedByType.getIncludeExistingValidators() != null &&
+                  validatedByType.getIncludeExistingValidators()) {
                 /*
                  If set to true, the list of ConstraintValidators described in XML
                  are concatenated to the list of ConstraintValidator described on the
@@ -459,10 +681,10 @@ public class ValidationMappingParser {
                  */
                 classes.addAll(findConstraintValidatorClasses(annotationClass));
             }
-            for (JAXBElement<String> validatorClassName : validatedByType.getValue()) {
+            for (String validatorClassName : validatedByType.getValue()) {
                 Class<? extends ConstraintValidator<?, ?>> validatorClass;
                 validatorClass = (Class<? extends ConstraintValidator<?, ?>>)
-                      loadClass(validatorClassName.getValue());
+                      loadClass(validatorClassName);
 
 
                 if (!ConstraintValidator.class.isAssignableFrom(validatorClass)) {
@@ -512,7 +734,11 @@ public class ValidationMappingParser {
 
     private String toQualifiedClassName(String className, String defaultPackage) {
         if (!isQualifiedClass(className)) {
-            className = defaultPackage + "." + className;
+            if (className.startsWith("[L") && className.endsWith(";")) {
+                className = "[L" + defaultPackage + "." + className.substring(2);
+            } else {
+                className = defaultPackage + "." + className;
+            }
         }
         return className;
     }



Mime
View raw message