You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2009/07/11 23:44:57 UTC

svn commit: r793226 [1/2] - in /myfaces/extensions/validator/trunk: core/src/main/java/org/apache/myfaces/extensions/validator/core/ core/src/main/java/org/apache/myfaces/extensions/validator/util/ validation-modules/bean-validation/ validation-modules...

Author: gpetracek
Date: Sat Jul 11 21:44:56 2009
New Revision: 793226

URL: http://svn.apache.org/viewvc?rev=793226&view=rev
Log:
transferred and updated bean-validation integration module

Added:
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/pom.xml
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/config/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/config/faces-config.xml
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/WebXmlParameter.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/BeanValidation.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/ModelValidation.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/extractor/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/extractor/DefaultGroupControllerScanningExtractor.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/PropertyValidationGroupProvider.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/BeanValidationMetaDataTransformer.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/DefaultBeanValidationStrategyToMetaDataTransformerNameMapper.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/startup/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/startup/BeanValidationStartupListener.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationEntry.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationPhaseListener.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/message/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/message/interpolator/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/message/interpolator/DefaultMessageInterpolator.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/message/interpolator/ExtValMessageInterpolatorAdapter.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/strategy/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/strategy/BeanValidationStrategyAdapter.java
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/resources/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/resources/LICENSE.txt
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/resources/NOTICE.txt
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/test/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/test/java/
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/test/resources/
Modified:
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/WebXmlUtils.java

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java?rev=793226&r1=793225&r2=793226&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java Sat Jul 11 21:44:56 2009
@@ -116,4 +116,14 @@
 
     //there is nothing like DEACTIVATE_DEFAULT_VALIDATION_INTERCEPTOR
     //use ExtValContext.getContext().denyRendererInterceptor(...) within an extval-StartupListener
+
+    //to display all violations via the messages-tag or to use the new jsf 2.0 support
+    static final String ACTIVATE_MULTIPLE_VIOLATIONS_PER_FIELD = WebXmlUtils
+        .getInitParameter("ACTIVATE_MULTIPLE_VIOLATIONS_PER_FIELD");
+                        
+    static final String INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL = WebXmlUtils
+        .getInitParameter("javax.faces", "INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL");
+
+    static final String VALIDATE_EMPTY_FIELDS = WebXmlUtils
+        .getInitParameter("javax.faces", "VALIDATE_EMPTY_FIELDS");
 }

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/WebXmlUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/WebXmlUtils.java?rev=793226&r1=793225&r2=793226&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/WebXmlUtils.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/WebXmlUtils.java Sat Jul 11 21:44:56 2009
@@ -33,8 +33,12 @@
 {
     public static String getInitParameter(String key)
     {
-        String value = FacesContext.getCurrentInstance().getExternalContext()
-            .getInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + "." + key);
+        return getInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX, key);
+    }
+
+    public static String getInitParameter(String prefix, String name)
+    {
+        String value = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(prefix + "." + name);
         return (value != null) ? value.replace(" ", "").trim() : null;
     }
 }

Added: myfaces/extensions/validator/trunk/validation-modules/bean-validation/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/pom.xml?rev=793226&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/pom.xml (added)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/pom.xml Sat Jul 11 21:44:56 2009
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <packaging>jar</packaging>
+
+    <groupId>org.apache.myfaces.extensions.validator.validation-modules</groupId>
+    <artifactId>myfaces-extval-bean-validation</artifactId>
+
+    <name>MyFaces Extensions-Validator Bean-Validation-Integration-Module (JSR 303)</name>
+    <version>1.2.3-SNAPSHOT</version>
+
+    <parent>
+        <groupId>org.apache.myfaces.extensions.validator.validation-modules</groupId>
+        <artifactId>validation-modules-project</artifactId>
+        <version>1.2.3-SNAPSHOT</version>
+    </parent>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.myfaces.extensions.validator</groupId>
+            <artifactId>myfaces-extval-core</artifactId>
+            <version>1.2.3-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+            <version>1.0.CR3-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.myfaces.core</groupId>
+            <artifactId>myfaces-api</artifactId>
+            <version>${jsf.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        
+        <!-- Test dependencies -->
+        <dependency>
+            <groupId>org.apache.myfaces.core</groupId>
+            <artifactId>myfaces-impl</artifactId>
+            <version>${jsf.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.5</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet.jsp</groupId>
+            <artifactId>jsp-api</artifactId>
+            <version>2.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shale</groupId>
+            <artifactId>shale-test</artifactId>
+            <version>1.0.4</version>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.myfaces</groupId>
+                    <artifactId>myfaces-api</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.myfaces</groupId>
+                    <artifactId>myfaces-impl</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>myfaces</groupId>
+                    <artifactId>myfaces-api</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>myfaces</groupId>
+                    <artifactId>myfaces-impl</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        
+    </dependencies>
+
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/config</directory>
+                <includes>
+                    <include>**/*xml</include>
+                </includes>
+                <targetPath>/META-INF</targetPath>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>LICENSE.txt</include>
+                    <include>NOTICE.txt</include>
+                </includes>
+                <targetPath>/META-INF</targetPath>
+            </resource>
+            <resource>
+                <directory>src/main/java</directory>
+                <includes>
+                    <include>**/*properties</include>
+                </includes>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <inherited>true</inherited>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.4.2</version>
+                <configuration>
+                    <excludes>
+                        <exclude>**/Abstract*.java</exclude>
+                        <exclude>**/TestUtils.java</exclude>
+                        <exclude>**/*Bean.java</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>            
+        </plugins>
+    </build>
+
+</project>

Added: myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/config/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/config/faces-config.xml?rev=793226&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/config/faces-config.xml (added)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/config/faces-config.xml Sat Jul 11 21:44:56 2009
@@ -0,0 +1,30 @@
+<!--
+ * 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.
+-->
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+              version="1.2">
+    <lifecycle>
+        <phase-listener>org.apache.myfaces.extensions.validator.beanval.startup.BeanValidationStartupListener</phase-listener>
+    </lifecycle>
+
+    <lifecycle>
+        <phase-listener>org.apache.myfaces.extensions.validator.beanval.validation.ModelValidationPhaseListener</phase-listener>
+    </lifecycle>
+</faces-config>
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java?rev=793226&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java (added)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java Sat Jul 11 21:44:56 2009
@@ -0,0 +1,376 @@
+/*
+ * 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.myfaces.extensions.validator.beanval;
+
+import org.apache.myfaces.extensions.validator.core.renderkit.exception.SkipBeforeInterceptorsException;
+import org.apache.myfaces.extensions.validator.core.renderkit.exception.SkipRendererDelegationException;
+import org.apache.myfaces.extensions.validator.core.WebXmlParameter;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
+import org.apache.myfaces.extensions.validator.core.property.PropertyDetails;
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.MetaDataExtractor;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.core.metadata.transformer.MetaDataTransformer;
+import org.apache.myfaces.extensions.validator.core.interceptor.AbstractRendererInterceptor;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.beanval.validation.strategy.BeanValidationStrategyAdapter;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.internal.Priority;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.render.Renderer;
+import javax.faces.convert.ConverterException;
+import javax.faces.validator.ValidatorException;
+import javax.faces.application.FacesMessage;
+import javax.validation.Validation;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.ElementDescriptor;
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.ValidatorFactory;
+import javax.validation.ConstraintViolation;
+import java.util.Set;
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+import java.io.IOException;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@ToDo(value = Priority.HIGH, description = "sync jsf 2.0 specific changes with bv-branch")
+@UsageInformation(UsageCategory.INTERNAL)
+public class BeanValidationInterceptor extends AbstractRendererInterceptor
+{
+    private ValidatorFactory validationFactory = Validation.buildDefaultValidatorFactory();
+
+    @Override
+    @ToDo(value = Priority.HIGH, description = "the api is available - but hv v4 beta doesn't impl. the needed parts")
+    public void beforeEncodeBegin(FacesContext facesContext, UIComponent uiComponent, Renderer wrapped)
+            throws IOException, SkipBeforeInterceptorsException, SkipRendererDelegationException
+    {
+        if(processComponent(uiComponent))
+        {
+            //initComponent(facesContext, uiComponent);
+        }
+    }
+
+    @ToDo(value = Priority.HIGH, description = "check groups")
+    protected void initComponent(FacesContext facesContext, UIComponent uiComponent)
+    {
+        if (logger.isTraceEnabled())
+        {
+            logger.trace("start to init component " + uiComponent.getClass().getName());
+        }
+
+        MetaDataExtractor metaDataExtractor = ExtValUtils.getComponentMetaDataExtractor();
+
+        PropertyDetails propertyDetails = metaDataExtractor.extract(facesContext, uiComponent)
+                .getInformation(PropertyInformationKeys.PROPERTY_DETAILS, PropertyDetails.class);
+
+        if(propertyDetails.getBaseObject() == null)
+        {
+            if(this.logger.isWarnEnabled())
+            {
+                this.logger.warn("no base object at " + propertyDetails.getKey() +
+                        " component-id: " + uiComponent.getClientId(facesContext));
+            }
+            return;
+        }
+
+        //TODO extract groups - see PropertyValidationGroupProvider
+        Class[] foundGroups = ExtValBeanValidationContext.getCurrentInstance().getGroups(
+                facesContext.getViewRoot().getViewId(),
+                uiComponent.getClientId(facesContext));
+
+        /*TODO
+            foundGroups = mergeFoundGroupsWithValidatorGroups(
+                foundGroups, ((EditableValueHolder)uiComponent).getValidators());
+        */
+        BeanDescriptor beanDescriptor = this.validationFactory.getValidator().getConstraintsForClass(
+                propertyDetails.getBaseObject().getClass());
+
+        ElementDescriptor elementDescriptor = beanDescriptor.getConstraintsForProperty(propertyDetails.getProperty());
+
+        if(elementDescriptor == null)
+        {
+            return;
+        }
+        
+        ValidationStrategy validationStrategy;
+        MetaDataTransformer metaDataTransformer;
+        MetaDataEntry entry;
+        Map<String, Object> metaData;
+
+        for (ConstraintDescriptor<?> constraintDescriptor :
+                elementDescriptor.getUnorderdConstraintDescriptorsMatchingGroups(foundGroups))
+        {
+            //TODO check groups
+            
+            validationStrategy = new BeanValidationStrategyAdapter(constraintDescriptor);
+
+            /*
+             * per default
+             * org.apache.myfaces.extensions.validator.beanval.metadata.transformer.BeanValidationMetaDataTransformer
+             * is bound to BeanValidationStrategyAdapter
+             * don't use it directly - it's possible to deactivate
+             * org.apache.myfaces.extensions.validator.beanval.metadata.transformer.mapper
+             *    .DefaultBeanValidationStrategyToMetaDataTransformerNameMapper
+             */
+            metaDataTransformer = ExtValUtils.getMetaDataTransformerForValidationStrategy(validationStrategy);
+
+            if (metaDataTransformer != null)
+            {
+                if (this.logger.isDebugEnabled())
+                {
+                    this.logger.debug(metaDataTransformer.getClass().getName() + " instantiated");
+                }
+
+                entry = new MetaDataEntry();
+                entry.setKey(constraintDescriptor.getAnnotation().annotationType().getName());
+                entry.setValue(constraintDescriptor);
+                //TODO (?) add type of property for meta-data transformation (e.g. size: string vs. number)
+
+                metaData = metaDataTransformer.convertMetaData(entry);
+            }
+            else
+            {
+                metaData = null;
+            }
+
+            if (metaData == null)
+            {
+                continue;
+            }
+
+            //get component initializer for the current component and configure it
+            //also in case of skipped validation to reset e.g. the required attribute
+            if (!metaData.isEmpty())
+            {
+                ExtValUtils.configureComponentWithMetaData(facesContext, uiComponent, metaData);
+            }
+        }
+
+        if (logger.isTraceEnabled())
+        {
+            logger.trace("init component of " + uiComponent.getClass().getName() + " finished");
+        }
+    }
+
+    @Override
+    public void beforeGetConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object o, Renderer wrapped)
+            throws ConverterException, SkipBeforeInterceptorsException, SkipRendererDelegationException
+    {
+        Object convertedObject = wrapped.getConvertedValue(facesContext, uiComponent, o);
+
+        try
+        {
+            if(processComponent(uiComponent))
+            {
+                if ("".equals(convertedObject) && interpretEmptyStringAsNull())
+                {
+                    convertedObject = null;
+                }
+
+                if(convertedObject == null && !validateEmptyFields())
+                {
+                    if(this.logger.isDebugEnabled())
+                    {
+                        this.logger.debug("empty field validation is deactivated in the web.xml - see: " +
+                                "javax.faces.VALIDATE_EMPTY_FIELDS");
+                    }
+
+                    return;
+                }
+
+                processValidation(facesContext, uiComponent, convertedObject);
+            }
+        }
+        catch (ValidatorException e)
+        {
+            throw new ConverterException(e.getFacesMessage(), e);
+        }
+    }
+
+    protected boolean processComponent(UIComponent uiComponent)
+    {
+        return uiComponent instanceof EditableValueHolder;
+    }
+
+    @ToDo(value = Priority.HIGH, description = "use ExtValUtils#createFacesMessage")
+    protected void processValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject)
+    {
+        MetaDataExtractor metaDataExtractor = ExtValUtils.getComponentMetaDataExtractor();
+
+        PropertyInformation propertyInformation = metaDataExtractor.extract(facesContext, uiComponent);
+
+        //e.g.: extract groups for validation
+        if(!ExtValUtils.executeGlobalBeforeValidationInterceptors(facesContext, uiComponent, convertedObject,
+                PropertyInformation.class.getName() ,propertyInformation))
+        {
+            return;
+        }
+
+        try
+        {
+            if (logger.isTraceEnabled())
+            {
+                logger.trace("jsr303 start validation");
+            }
+
+            if(processBeanValidationForProperty(propertyInformation))
+            {
+                processFieldValidation(facesContext, uiComponent, convertedObject, propertyInformation);
+            }
+        }
+        finally
+        {
+            if (logger.isTraceEnabled())
+            {
+                logger.trace("jsr303 validation finished");
+            }
+
+            ExtValUtils.executeGlobalAfterValidationInterceptors(facesContext, uiComponent, convertedObject,
+                    PropertyInformation.class.getName(), propertyInformation);
+        }
+    }
+
+    protected boolean processBeanValidationForProperty(PropertyInformation propertyInformation)
+    {
+        PropertyDetails propertyDetails = (propertyInformation.getInformation(
+                PropertyInformationKeys.PROPERTY_DETAILS, PropertyDetails.class));
+
+        BeanDescriptor beanDescriptor = this.validationFactory.getValidator().getConstraintsForClass(
+                propertyDetails.getBaseObject().getClass());
+
+        ElementDescriptor elementDescriptor = beanDescriptor.getConstraintsForProperty(propertyDetails.getProperty());
+
+        return elementDescriptor != null;
+    }
+
+    protected boolean validateEmptyFields()
+    {
+        return !"false".equalsIgnoreCase(WebXmlParameter.VALIDATE_EMPTY_FIELDS);
+    }
+
+    protected boolean interpretEmptyStringAsNull()
+    {
+        return !"false".equalsIgnoreCase(WebXmlParameter.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL);
+    }
+
+    protected void processFieldValidation(FacesContext facesContext,
+                                          UIComponent uiComponent,
+                                          Object convertedObject,
+                                          PropertyInformation propertyInformation)
+    {
+        Class baseBeanClass = (propertyInformation.getInformation(
+                PropertyInformationKeys.PROPERTY_DETAILS, PropertyDetails.class)).getBaseObject().getClass();
+
+        String propertyName = (propertyInformation.getInformation(
+                PropertyInformationKeys.PROPERTY_DETAILS, PropertyDetails.class)).getProperty();
+
+        ExtValBeanValidationContext beanValidationContext = ExtValBeanValidationContext.getCurrentInstance();
+
+        Class[] groups = beanValidationContext.getGroups(
+                facesContext.getViewRoot().getViewId(), uiComponent.getClientId(facesContext));
+
+        if(groups == null)
+        {
+            return;
+        }
+
+        Set<ConstraintViolation> violations = this.validationFactory.usingContext()
+                .messageInterpolator(ExtValBeanValidationContext.getCurrentInstance().getMessageInterpolator())
+                .getValidator()
+                .validateValue(baseBeanClass, propertyName, convertedObject, groups);
+
+        List<String> violationMessages = new ArrayList<String>();
+        for(ConstraintViolation violation : violations)
+        {
+            String violationMessage = violation.getMessage();
+
+            String labeledMessage = "{0}: " + violationMessage;
+            ValidatorException validatorException = new ValidatorException(
+                    new FacesMessage(FacesMessage.SEVERITY_ERROR, labeledMessage, labeledMessage));
+
+            ExtValUtils.executeAfterThrowingInterceptors(
+                    uiComponent,
+                    null,
+                    convertedObject,
+                    validatorException,
+                    null);
+
+            //check if the message has changed
+            if (labeledMessage.equals(validatorException.getFacesMessage().getSummary()) ||
+                    labeledMessage.equals(validatorException.getFacesMessage().getDetail()))
+            {
+                violationMessages.add(violationMessage);
+            }
+            else
+            {
+                violationMessages.add(validatorException.getFacesMessage().getSummary());
+            }
+
+            if(!supportMultipleViolationsPerField())
+            {
+                break;
+            }
+        }
+
+        if(!violationMessages.isEmpty())
+        {
+            throwException(facesContext, uiComponent, violationMessages);
+        }
+    }
+
+    //override this method in the jsf 2.0 version
+    protected void throwException(FacesContext facesContext, UIComponent uiComponent, List<String> violationMessages)
+    {
+        if(supportMultipleViolationsPerField())
+        {
+            boolean firstMessage = false;
+            for(String message : violationMessages)
+            {
+                if(!firstMessage)
+                {
+                    firstMessage = true;
+                }
+                else
+                {
+                    facesContext.addMessage(uiComponent.getClientId(facesContext),
+                            new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message));
+                }
+            }
+        }
+
+        throw new ValidatorException(
+                new FacesMessage(FacesMessage.SEVERITY_ERROR, violationMessages.get(0), violationMessages.get(0)));
+    }
+
+    //override this method in the jsf 2.0 version
+    protected boolean supportMultipleViolationsPerField()
+    {
+        return "true".equalsIgnoreCase(WebXmlParameter.ACTIVATE_MULTIPLE_VIOLATIONS_PER_FIELD);
+    }
+}

Added: myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java?rev=793226&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java (added)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java Sat Jul 11 21:44:56 2009
@@ -0,0 +1,411 @@
+/*
+ * 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.myfaces.extensions.validator.beanval;
+
+import org.apache.myfaces.extensions.validator.beanval.validation.message.interpolator.DefaultMessageInterpolator;
+import org.apache.myfaces.extensions.validator.beanval.validation.message.interpolator.ExtValMessageInterpolatorAdapter;
+import org.apache.myfaces.extensions.validator.beanval.validation.ModelValidationEntry;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.internal.Priority;
+import org.apache.myfaces.extensions.validator.core.validation.message.resolver.MessageResolver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import javax.validation.groups.Default;
+import javax.validation.MessageInterpolator;
+import javax.validation.Validation;
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.3
+ */
+public class ExtValBeanValidationContext
+{
+    protected final Log logger = LogFactory.getLog(getClass());
+
+    private static final String KEY = ExtValBeanValidationContext.class.getName() + ":KEY";
+
+    private static MessageInterpolator defaultMessageInterpolator = new DefaultMessageInterpolator(
+            Validation.buildDefaultValidatorFactory().getMessageInterpolator());
+
+    private static MessageResolver messageResolver;
+
+    @ToDo(value = Priority.HIGH, description = "refactor to a pluggable Storage")
+    private Map<String, List<Class>> addedGroups = new HashMap<String, List<Class>>();
+
+    @ToDo(value = Priority.HIGH, description = "refactor to a pluggable Storage")
+    private Map<String, List<Class>> restrictedGroups = new HashMap<String, List<Class>>();
+
+    @ToDo(value = Priority.HIGH, description = "refactor to a pluggable Storage")
+    private Map<String, List<ModelValidationEntry>> modelValidationEntries =
+            new HashMap<String, List<ModelValidationEntry>>();
+
+    @ToDo(value = Priority.HIGH, description = "refactor to a pluggable Storage")
+    private List<String> componentsOfRequest = new ArrayList<String>();
+
+    private ExtValBeanValidationContext()
+    {
+    }
+
+    @SuppressWarnings({"unchecked"})
+    public static ExtValBeanValidationContext getCurrentInstance()
+    {
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+
+        Map requestMap = facesContext.getExternalContext().getRequestMap();
+
+        ExtValBeanValidationContext currentContext = (ExtValBeanValidationContext)requestMap.get(KEY);
+
+        if(currentContext == null)
+        {
+            currentContext = new ExtValBeanValidationContext();
+            requestMap.put(KEY, currentContext);
+        }
+
+        return currentContext;
+    }
+
+    private String getGroupKey(String viewId, String componentId)
+    {
+        return componentId == null ? viewId : viewId + "@" + componentId;
+    }
+
+    public void addGroup(Class groupClass)
+    {
+        addGroup(groupClass, FacesContext.getCurrentInstance().getViewRoot().getViewId());
+    }
+
+    public void addGroup(Class groupClass, String viewId)
+    {
+        addGroup(groupClass, viewId, null);
+    }
+
+    public void addGroup(Class groupClass, String viewId, String componentId)
+    {
+        addGroupToGroupStorage(groupClass, viewId, componentId, this.addedGroups);
+    }
+
+    public void addModelValidationEntry(ModelValidationEntry modelValidationEntry)
+    {
+        addModelValidationEntry(modelValidationEntry, FacesContext.getCurrentInstance().getViewRoot().getViewId());
+    }
+
+    public void addModelValidationEntry(ModelValidationEntry modelValidationEntry, String viewId)
+    {
+        addModelValidationEntry(modelValidationEntry, viewId, null);
+    }
+
+    public void addModelValidationEntry(
+            ModelValidationEntry modelValidationEntry, String viewId, UIComponent component)
+    {
+        modelValidationEntry.setComponent(component);
+
+        String componentId = null;
+
+        if(component != null)
+        {
+            componentId = component.getClientId(FacesContext.getCurrentInstance());
+            this.componentsOfRequest.add(componentId);
+        }
+
+        List<ModelValidationEntry> modelValidationEntryList =
+                this.modelValidationEntries.get(getGroupKey(viewId, componentId));
+
+        if(modelValidationEntryList == null)
+        {
+            modelValidationEntryList = new ArrayList<ModelValidationEntry>();
+            this.modelValidationEntries.put(getGroupKey(viewId, componentId), modelValidationEntryList);
+        }
+
+        if(!modelValidationEntryList.contains(modelValidationEntry))
+        {
+            modelValidationEntryList.add(modelValidationEntry);
+        }
+    }
+
+    public void restrictGroup(Class groupClass)
+    {
+        restrictGroup(groupClass, FacesContext.getCurrentInstance().getViewRoot().getViewId());
+    }
+
+    public void restrictGroup(Class groupClass, String viewId)
+    {
+        restrictGroup(groupClass, viewId, null);
+    }
+
+    public void restrictGroup(Class groupClass, String viewId, String componentId)
+    {
+        addGroupToGroupStorage(groupClass, viewId, componentId, this.restrictedGroups);
+    }
+
+    private void addGroupToGroupStorage(Class groupClass, String viewId, String componentId,
+                                        Map<String, List<Class>> groupStorage)
+    {
+        List<Class> groupList = groupStorage.get(getGroupKey(viewId, componentId));
+
+        if(groupList == null)
+        {
+            groupList = new ArrayList<Class>();
+            groupStorage.put(getGroupKey(viewId, componentId), groupList);
+        }
+
+        if(!groupList.contains(groupClass))
+        {
+            groupList.add(groupClass);
+        }
+    }
+
+    public void resetGroup(String viewId)
+    {
+        resetGroups(viewId, null);
+    }
+
+    public void resetGroups(String viewId, String componentId)
+    {
+        this.addedGroups.put(getGroupKey(viewId, componentId), new ArrayList<Class>());
+    }
+
+    /*
+    public Class[] getGroups()
+    {
+        if(this.addedGroups.size() < 1)
+        {
+            return new Class[] {Default.class};
+        }
+
+        List<Class> fullGroupList = new ArrayList<Class>();
+
+        for(Map.Entry<String, List<Class>> currentGroupEntry : this.addedGroups.entrySet())
+        {
+            fullGroupList.addAll(currentGroupEntry.getValue());
+
+        }
+        return (Class[]) fullGroupList.toArray();
+    }
+    */
+
+    public Class[] getGroups(String viewId)
+    {
+        return getGroups(viewId, null);
+    }
+
+    public Class[] getAllGroups(String viewId)
+    {
+        return getGroups(viewId, "*");
+    }
+
+    @ToDo(value = Priority.HIGH, description = "change impl. for #getAllGroups - see getModelValidationEntries")
+    public Class[] getGroups(String viewId, String componentId)
+    {
+        if(this.addedGroups.size() < 1)
+        {
+            if(!"true".equalsIgnoreCase(WebXmlParameter.DEACTIVATE_IMPLICIT_DEFAULT_GROUP_VALIDATION))
+            {
+                return new Class[] {Default.class};
+            }
+            return null;
+        }
+
+        //add found groups
+        String key = getGroupKey(viewId, null);
+        List<Class> resultListForPage = buildGroupList(key, this.addedGroups);
+
+        key = getGroupKey(viewId, componentId);
+        List<Class> resultListForComponent = buildGroupList(key, this.addedGroups);
+
+        //remove restricted groups
+        Class[] resultsForPage = filterGroupList(getGroupKey(viewId, null), resultListForPage);
+        Class[] resultsForComponent = filterGroupList(getGroupKey(viewId, componentId), resultListForComponent);
+
+        if(resultsForPage.length == 0)
+        {
+            if(resultsForComponent.length == 0)
+            {
+                if(this.logger.isDebugEnabled())
+                {
+                    this.logger.debug("no groups for group-validation available." +
+                            "maybe you restricted all groups or you aren't using groups." +
+                            "bean validation will use the default group for validation");
+                }
+            }
+            return resultsForComponent;
+        }
+        else if(resultsForComponent.length == 0)
+        {
+            return resultsForPage;
+        }
+
+        return mergeResults(resultsForPage, resultsForComponent);
+    }
+
+    public List<ModelValidationEntry> getModelValidationEntries(String viewId)
+    {
+        return getModelValidationEntries(viewId, null);
+    }
+
+    public List<ModelValidationEntry> getAllModelValidationEntries(String viewId)
+    {
+        return getModelValidationEntries(viewId, "*");
+    }
+
+    public List<ModelValidationEntry> getModelValidationEntriesOfCurrentRequest(String viewId)
+    {
+        List<ModelValidationEntry> result = new ArrayList<ModelValidationEntry>();
+
+        for(String currentClientId : this.componentsOfRequest)
+        {
+            result.addAll(getModelValidationEntries(viewId, currentClientId));
+        }
+
+        result.addAll(getModelValidationEntries(viewId));
+
+        return result;
+    }
+
+    public List<ModelValidationEntry> getModelValidationEntries(String viewId, String componentId)
+    {
+        if(this.modelValidationEntries.size() < 1)
+        {
+            return new ArrayList<ModelValidationEntry>();
+        }
+
+        //add found groups
+        String key;
+        List<ModelValidationEntry> resultListForPage = null;
+
+        if(!"*".equals(componentId))
+        {
+            key = getGroupKey(viewId, null);
+            resultListForPage =
+                    buildModelValidationEntryList(key, this.modelValidationEntries);
+        }
+
+        key = getGroupKey(viewId, componentId);
+        List<ModelValidationEntry> resultListForComponent =
+                buildModelValidationEntryList(key, this.modelValidationEntries);
+
+        if(resultListForPage == null || resultListForPage.isEmpty())
+        {
+            return resultListForComponent;
+        }
+        else if(resultListForComponent.isEmpty())
+        {
+            return resultListForPage;
+        }
+
+        //merge results
+        List<ModelValidationEntry> mergedResult = new ArrayList<ModelValidationEntry>();
+        mergedResult.addAll(resultListForPage);
+        mergedResult.addAll(resultListForComponent);
+        return mergedResult;
+    }
+
+    private List<Class> buildGroupList(String key, Map<String, List<Class>> groupStorage)
+    {
+        List<Class> list = groupStorage.get(key);
+        return (list != null) ? list : new ArrayList<Class>();
+    }
+
+    private List<ModelValidationEntry> buildModelValidationEntryList(
+            String key, Map<String, List<ModelValidationEntry>> groupStorage)
+    {
+        List<ModelValidationEntry> list;
+
+        if(key != null && key.endsWith("*"))
+        {
+            list = new ArrayList<ModelValidationEntry>();
+            for(Map.Entry<String,List<ModelValidationEntry>> entry : groupStorage.entrySet())
+            {
+                if(entry.getKey().substring(0, entry.getKey().indexOf("@"))
+                        .equals(key.substring(0, key.indexOf("@"))))
+                {
+                    list.addAll(entry.getValue());
+                }
+            }
+            return list;
+        }
+
+        list = groupStorage.get(key);
+        return (list != null) ? list : new ArrayList<ModelValidationEntry>();
+    }
+
+    private Class[] filterGroupList(String key, List<Class> addedGroups)
+    {
+        List<Class> restrictedGroups = buildGroupList(key, this.restrictedGroups);
+        List<Class> results = new ArrayList<Class>();
+
+        for(Class currentGroup : addedGroups)
+        {
+            if(!restrictedGroups.contains(currentGroup))
+            {
+                results.add(currentGroup);
+            }
+        }
+
+        return results.toArray(new Class[results.size()]);
+    }
+
+    private Class[] mergeResults(Class[] resultsForPage, Class[] resultsForComponent)
+    {
+        Class[] mergedResult = new Class[resultsForPage.length + resultsForComponent.length];
+
+        System.arraycopy(resultsForPage, 0, mergedResult, 0, resultsForPage.length);
+        System.arraycopy(resultsForComponent, 0, mergedResult, resultsForPage.length, resultsForComponent.length);
+
+        return mergedResult;
+    }
+
+    public void removeGroup(Class groupClass)
+    {
+        removeGroup(groupClass, FacesContext.getCurrentInstance().getViewRoot().getViewId());
+    }
+
+    public void removeGroup(Class groupClass, String viewId)
+    {
+        removeGroup(groupClass, viewId, null);
+    }
+
+    @ToDo(Priority.HIGH)
+    public void removeGroup(Class groupClass, String viewId, String componentId)
+    {
+        this.addedGroups.remove(getGroupKey(viewId, componentId));
+    }
+
+    public MessageInterpolator getMessageInterpolator()
+    {
+        if(messageResolver != null)
+        {
+            return new ExtValMessageInterpolatorAdapter(defaultMessageInterpolator, messageResolver);
+        }
+
+        return defaultMessageInterpolator;
+    }
+
+    @ToDo(Priority.HIGH)
+    public static void setMessageResolver(MessageResolver customMessageResolver)
+    {
+        messageResolver = customMessageResolver;
+    }
+}

Added: myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/WebXmlParameter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/WebXmlParameter.java?rev=793226&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/WebXmlParameter.java (added)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/WebXmlParameter.java Sat Jul 11 21:44:56 2009
@@ -0,0 +1,37 @@
+/*
+ * 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.myfaces.extensions.validator.beanval;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.util.WebXmlUtils;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public interface WebXmlParameter
+{
+    static final String DEACTIVATE_IMPLICIT_DEFAULT_GROUP_VALIDATION = WebXmlUtils
+        .getInitParameter("DEACTIVATE_IMPLICIT_DEFAULT_GROUP_VALIDATION");
+
+    static final String DEACTIVATE_ADDITIONAL_GROUP_VALIDATION_ANNOTATIONS = WebXmlUtils
+        .getInitParameter("DEACTIVATE_ADDITIONAL_GROUP_VALIDATION_ANNOTATIONS");
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/BeanValidation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/BeanValidation.java?rev=793226&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/BeanValidation.java (added)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/BeanValidation.java Sat Jul 11 21:44:56 2009
@@ -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.myfaces.extensions.validator.beanval.annotation;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.internal.Priority;
+
+import javax.validation.groups.Default;
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.3
+ */
+
+@Target({METHOD, FIELD, TYPE})
+@Retention(RUNTIME)
+@UsageInformation(UsageCategory.API)
+public @interface BeanValidation
+{
+    String[] viewIds() default "*";
+
+    Class[] useGroups() default Default.class;
+
+    Class[] restrictGroups() default {};
+
+    @ToDo(value = Priority.HIGH, description = "support property chain syntax")
+    String[] conditions() default "#{true}";
+
+    ModelValidation modelValidation() default @ModelValidation;
+    
+    @Retention(RUNTIME) static @interface List
+    {
+        BeanValidation[] value();
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/ModelValidation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/ModelValidation.java?rev=793226&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/ModelValidation.java (added)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/ModelValidation.java Sat Jul 11 21:44:56 2009
@@ -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.myfaces.extensions.validator.beanval.annotation;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.3
+ */
+
+@Target({METHOD, FIELD, TYPE})
+@Retention(RUNTIME)
+@UsageInformation(UsageCategory.API)
+public @interface ModelValidation
+{
+    public static final String DEFAULT_TARGET = "base";
+    public static final String DEFAULT_MESSAGE = "org.apache.myfaces.extensions.validator.bv_message";
+
+    boolean isActive() default false;
+
+    boolean displayInline() default false;
+
+    String[] validationTargets() default DEFAULT_TARGET;
+
+    String message() default DEFAULT_MESSAGE;
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/extractor/DefaultGroupControllerScanningExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/extractor/DefaultGroupControllerScanningExtractor.java?rev=793226&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/extractor/DefaultGroupControllerScanningExtractor.java (added)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/extractor/DefaultGroupControllerScanningExtractor.java Sat Jul 11 21:44:56 2009
@@ -0,0 +1,56 @@
+/*
+ * 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.myfaces.extensions.validator.beanval.annotation.extractor;
+
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.DefaultComponentMetaDataExtractor;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.core.property.DefaultPropertyInformation;
+import org.apache.myfaces.extensions.validator.core.property.PropertyDetails;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.3
+ */
+public class DefaultGroupControllerScanningExtractor extends DefaultComponentMetaDataExtractor
+{
+    @Override
+    public PropertyInformation extract(FacesContext facesContext, Object object)
+    {
+        if (!(object instanceof PropertyDetails))
+        {
+            throw new IllegalStateException(object.getClass() + " is not a " + PropertyDetails.class.getName());
+        }
+
+        PropertyDetails propertyDetails = (PropertyDetails)object;
+
+        Class entityClass = propertyDetails.getBaseObject().getClass();
+
+        PropertyInformation propertyInformation = new DefaultPropertyInformation();
+        
+        /*
+         * find and add annotations
+         */
+        addPropertyAccessAnnotations(entityClass, propertyDetails.getProperty(), propertyInformation);
+        addFieldAccessAnnotations(entityClass, propertyDetails.getProperty(), propertyInformation);
+
+        return propertyInformation;
+    }
+}

Added: myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/PropertyValidationGroupProvider.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/PropertyValidationGroupProvider.java?rev=793226&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/PropertyValidationGroupProvider.java (added)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/interceptor/PropertyValidationGroupProvider.java Sat Jul 11 21:44:56 2009
@@ -0,0 +1,487 @@
+/*
+ * 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.myfaces.extensions.validator.beanval.interceptor;
+
+import org.apache.myfaces.extensions.validator.core.interceptor.PropertyValidationInterceptor;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.core.property.PropertyDetails;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.core.el.ELHelper;
+import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
+import org.apache.myfaces.extensions.validator.beanval.validation.ModelValidationEntry;
+import org.apache.myfaces.extensions.validator.beanval.ExtValBeanValidationContext;
+import org.apache.myfaces.extensions.validator.beanval.annotation.extractor.DefaultGroupControllerScanningExtractor;
+import org.apache.myfaces.extensions.validator.beanval.annotation.BeanValidation;
+import org.apache.myfaces.extensions.validator.beanval.annotation.ModelValidation;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.internal.Priority;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import javax.validation.groups.Default;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+import java.lang.reflect.Method;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.3
+ */
+public class PropertyValidationGroupProvider implements PropertyValidationInterceptor
+{
+    protected final Log logger = LogFactory.getLog(getClass());
+
+    public boolean beforeValidation(FacesContext facesContext,
+                                    UIComponent uiComponent,
+                                    Object convertedObject,
+                                    Map<String, Object> properties)
+    {
+        if(properties.containsKey(PropertyInformation.class.getName()))
+        {
+            addMetaDataToContext(
+                    (PropertyInformation)properties.get(PropertyInformation.class.getName()), uiComponent);
+        }
+        return true;
+    }
+
+    public void afterValidation(FacesContext facesContext,
+                                UIComponent uiComponent,
+                                Object convertedObject,
+                                Map<String, Object> properties)
+    {
+        //not used
+    }
+
+    protected void addMetaDataToContext(PropertyInformation propertyInformation, UIComponent component)
+    {
+        PropertyDetails propertyDetails = propertyInformation
+                .getInformation(PropertyInformationKeys.PROPERTY_DETAILS, PropertyDetails.class);
+
+        String[] key = propertyDetails.getKey().split("\\.");
+
+        Object firstBean = ExtValUtils.getELHelper().getBean(key[0]);
+
+        List<Class> foundGroupsForPropertyValidation = new ArrayList<Class>();
+        List<Class> restrictedGroupsForPropertyValidation = new ArrayList<Class>();
+        List<ModelValidationEntry> modelValidationEntryList = new ArrayList<ModelValidationEntry>();
+        List<Class> restrictedGroupsForModelValidation = new ArrayList<Class>();
+
+        //extract bv-controller-annotation of
+
+        //first bean
+        processClass(firstBean,
+                foundGroupsForPropertyValidation,
+                restrictedGroupsForPropertyValidation,
+                modelValidationEntryList,
+                restrictedGroupsForModelValidation);
+
+        //first property
+        processFieldsAndProperties(key[0] + "." + key[1],
+                firstBean,
+                key[1],
+                foundGroupsForPropertyValidation,
+                restrictedGroupsForPropertyValidation,
+                modelValidationEntryList,
+                restrictedGroupsForModelValidation);
+
+        //base object (of target property)
+        processClass(propertyDetails.getBaseObject(),
+                foundGroupsForPropertyValidation,
+                restrictedGroupsForPropertyValidation,
+                modelValidationEntryList,
+                restrictedGroupsForModelValidation);
+
+        //last property
+        processFieldsAndProperties(
+                propertyDetails.getKey(),
+                propertyDetails.getBaseObject(),
+                propertyDetails.getProperty(),
+                foundGroupsForPropertyValidation,
+                restrictedGroupsForPropertyValidation,
+                modelValidationEntryList,
+                restrictedGroupsForModelValidation);
+
+        ExtValBeanValidationContext extValBeanValidationContext = ExtValBeanValidationContext.getCurrentInstance();
+        String currentViewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();
+
+        String clientId = component.getClientId(FacesContext.getCurrentInstance());
+
+        processFoundGroups(extValBeanValidationContext, currentViewId, clientId,
+                foundGroupsForPropertyValidation);
+
+        processRestrictedGroups(extValBeanValidationContext, currentViewId, clientId,
+                restrictedGroupsForPropertyValidation);
+
+        initModelValidation(extValBeanValidationContext, currentViewId, component, propertyDetails,
+                modelValidationEntryList, restrictedGroupsForModelValidation);
+    }
+
+    private void processClass(Object objectToInspect,
+                              List<Class> foundGroupsForPropertyValidation,
+                              List<Class> restrictedGroupsForPropertyValidation,
+                              List<ModelValidationEntry> modelValidationEntryList,
+                              List<Class> restrictedGroupsForModelValidation)
+    {
+        Class classToInspect = objectToInspect.getClass();
+        while (!Object.class.getName().equals(classToInspect.getName()))
+        {
+            transferGroupValidationInformationToFoundGroups(objectToInspect,
+                    foundGroupsForPropertyValidation,
+                    restrictedGroupsForPropertyValidation,
+                    modelValidationEntryList,
+                    restrictedGroupsForModelValidation);
+
+            processInterfaces(objectToInspect.getClass(), objectToInspect,
+                    foundGroupsForPropertyValidation,
+                    restrictedGroupsForPropertyValidation,
+                    modelValidationEntryList,
+                    restrictedGroupsForModelValidation);
+
+            classToInspect = classToInspect.getSuperclass();
+        }
+    }
+
+    private void processFieldsAndProperties(String key,
+                                            Object base,
+                                            String property, List<Class> foundGroupsForPropertyValidation,
+                                            List<Class> restrictedGroupsForPropertyValidation,
+                                            List<ModelValidationEntry> modelValidationEntryList,
+                                            List<Class> restrictedGroupsForModelValidation)
+    {
+        PropertyInformation propertyInformation = new DefaultGroupControllerScanningExtractor()
+                .extract(FacesContext.getCurrentInstance(), new PropertyDetails(key, base, property));
+
+        for (MetaDataEntry metaDataEntry : propertyInformation.getMetaDataEntries())
+        {
+            if (metaDataEntry.getValue() instanceof BeanValidation)
+            {
+                processMetaData((BeanValidation) metaDataEntry.getValue(),
+                        base,
+                        foundGroupsForPropertyValidation,
+                        restrictedGroupsForPropertyValidation,
+                        modelValidationEntryList,
+                        restrictedGroupsForModelValidation);
+            }
+            else if(metaDataEntry.getValue() instanceof BeanValidation.List)
+            {
+                for(BeanValidation currentBeanValidation : ((BeanValidation.List)metaDataEntry.getValue()).value())
+                {
+                    processMetaData(currentBeanValidation,
+                            base,
+                            foundGroupsForPropertyValidation,
+                            restrictedGroupsForPropertyValidation,
+                            modelValidationEntryList,
+                            restrictedGroupsForModelValidation);
+                }
+            }
+        }
+    }
+
+    protected void processFoundGroups(ExtValBeanValidationContext extValBeanValidationContext,
+                                      String currentViewId,
+                                      String clientId,
+                                      List<Class> foundGroupsForPropertyValidation)
+    {
+        /*
+         * add found groups to context
+         */
+        for (Class currentGroupClass : foundGroupsForPropertyValidation)
+        {
+            extValBeanValidationContext.addGroup(currentGroupClass, currentViewId, clientId);
+        }
+    }
+
+    protected void processRestrictedGroups(ExtValBeanValidationContext extValBeanValidationContext,
+                                         String currentViewId,
+                                         String clientId,
+                                         List<Class> restrictedGroupsForPropertyValidation)
+    {
+        /*
+         * add restricted groups
+         */
+        for (Class currentGroupClass : restrictedGroupsForPropertyValidation)
+        {
+            extValBeanValidationContext.restrictGroup(currentGroupClass, currentViewId, clientId);
+        }
+    }
+
+    protected void initModelValidation(ExtValBeanValidationContext extValBeanValidationContext,
+                                     String currentViewId,
+                                     UIComponent component,
+                                     PropertyDetails propertyDetails,
+                                     List<ModelValidationEntry> modelValidationEntryList,
+                                     List<Class> restrictedGroupsForModelValidation)
+    {
+        /*
+         * add model validation entry list
+         */
+        for(ModelValidationEntry modelValidationEntry : modelValidationEntryList)
+        {
+            if(!"true".equalsIgnoreCase(org.apache.myfaces.extensions.validator.beanval.WebXmlParameter
+                    .DEACTIVATE_IMPLICIT_DEFAULT_GROUP_VALIDATION))
+            {
+                modelValidationEntry.addGroup(Default.class);
+            }
+
+            for(Class restrictedGroup : restrictedGroupsForModelValidation)
+            {
+                modelValidationEntry.removeGroup(restrictedGroup);
+            }
+
+            if(modelValidationEntry.getGroups().length > 0)
+            {
+                addTargetsForModelValidation(modelValidationEntry, propertyDetails.getBaseObject());
+                extValBeanValidationContext.addModelValidationEntry(modelValidationEntry, currentViewId, component);
+            }
+        }
+    }
+
+    private void transferGroupValidationInformationToFoundGroups(Object objectToInspect,
+                                                                 List<Class> foundGroupsForPropertyValidation,
+                                                                 List<Class> restrictedGroupsForPropertyValidation,
+                                                                 List<ModelValidationEntry> modelValidationEntryList,
+                                                                 List<Class> restrictedGroupsForModelValidation)
+    {
+        if (objectToInspect.getClass().isAnnotationPresent(BeanValidation.class))
+        {
+            processMetaData(objectToInspect.getClass().getAnnotation(BeanValidation.class),
+                    objectToInspect,
+                    foundGroupsForPropertyValidation,
+                    restrictedGroupsForPropertyValidation,
+                    modelValidationEntryList,
+                    restrictedGroupsForModelValidation);
+        }
+        else if (objectToInspect.getClass().isAnnotationPresent(BeanValidation.List.class))
+        {
+            for(BeanValidation currentBeanValidation :
+                    (objectToInspect.getClass().getAnnotation(BeanValidation.List.class)).value())
+            {
+                processMetaData(currentBeanValidation,
+                        objectToInspect,
+                        foundGroupsForPropertyValidation,
+                        restrictedGroupsForPropertyValidation,
+                        modelValidationEntryList,
+                        restrictedGroupsForModelValidation);
+            }
+        }
+    }
+
+    private void processInterfaces(Class currentClass,
+                                   Object metaDataSourceObject,
+                                   List<Class> foundGroupsForPropertyValidation,
+                                   List<Class> restrictedGroupsForPropertyValidation,
+                                   List<ModelValidationEntry> modelValidationEntryList,
+                                   List<Class> restrictedGroupsForModelValidation)
+    {
+        for (Class currentInterface : currentClass.getInterfaces())
+        {
+            transferGroupValidationInformationToFoundGroups(metaDataSourceObject,
+                    foundGroupsForPropertyValidation,
+                    restrictedGroupsForPropertyValidation,
+                    modelValidationEntryList,
+                    restrictedGroupsForModelValidation);
+
+            processInterfaces(currentInterface, metaDataSourceObject,
+                    foundGroupsForPropertyValidation,
+                    restrictedGroupsForPropertyValidation,
+                    modelValidationEntryList,
+                    restrictedGroupsForModelValidation);
+        }
+    }
+
+    protected void processMetaData(BeanValidation beanValidation,
+                                 Object metaDataSourceObject,
+                                 List<Class> foundGroupsForPropertyValidation,
+                                 List<Class> restrictedGroupsForPropertyValidation,
+                                 List<ModelValidationEntry> modelValidationEntryList,
+                                 List<Class> restrictedGroupsForModelValidation)
+    {
+        for (String currentViewId : beanValidation.viewIds())
+        {
+            if ((currentViewId.equals(FacesContext.getCurrentInstance().getViewRoot().getViewId()) ||
+                    currentViewId.equals("*")) && isValidationPermitted(beanValidation))
+            {
+                if(isModelValidation(beanValidation))
+                {
+                    addModelValidationEntry(
+                            beanValidation, metaDataSourceObject,
+                            modelValidationEntryList, restrictedGroupsForModelValidation);
+                }
+                else
+                {
+                    processGroups(
+                            beanValidation, foundGroupsForPropertyValidation, restrictedGroupsForPropertyValidation);
+                }
+
+                return;
+            }
+        }
+    }
+
+    private void addTargetsForModelValidation(ModelValidationEntry modelValidationEntry, Object defaultTarget)
+    {
+        if(modelValidationEntry.getMetaData().validationTargets().length == 1 &&
+                modelValidationEntry.getMetaData().validationTargets()[0].equals(ModelValidation.DEFAULT_TARGET))
+        {
+            modelValidationEntry.addValidationTarget(defaultTarget);
+        }
+        else
+        {
+            Object target;
+            for(String modelValidationTarget : modelValidationEntry.getMetaData().validationTargets())
+            {
+                target = resolveTarget(modelValidationEntry.getMetaDataSourceObject(), modelValidationTarget);
+
+                if(target == null && this.logger.isErrorEnabled())
+                {
+                    this.logger.error("target unreachable - source class: " +
+                            modelValidationEntry.getMetaDataSourceObject().getClass().getName() +
+                            " target to resolve: " + modelValidationTarget);
+                }
+
+                modelValidationEntry.addValidationTarget(target);
+            }
+        }
+    }
+
+    private boolean isValidationPermitted(BeanValidation beanValidation)
+    {
+        ELHelper elHelper = ExtValUtils.getELHelper();
+
+        for(String condition : beanValidation.conditions())
+        {
+            if(elHelper.isELTermWellFormed(condition) &&
+                    elHelper.isELTermValid(FacesContext.getCurrentInstance(), condition))
+            {
+                if(Boolean.TRUE.equals(
+                        elHelper.getValueOfExpression(
+                                FacesContext.getCurrentInstance(), new ValueBindingExpression(condition))))
+                {
+                    return true;
+                }
+            }
+            else
+            {
+                if(this.logger.isErrorEnabled())
+                {
+                    this.logger.error("an invalid condition is used: " + condition);
+                }
+            }
+        }
+        return false;
+    }
+
+    private boolean isModelValidation(BeanValidation beanValidation)
+    {
+        return beanValidation.modelValidation().isActive();
+    }
+
+    private void addModelValidationEntry(BeanValidation beanValidation,
+                                         Object metaDataSourceObject,
+                                         List<ModelValidationEntry> modelValidationEntryList,
+                                         List<Class> restrictedGroupsForModelValidation)
+    {
+        ModelValidationEntry modelValidationEntry = new ModelValidationEntry();
+
+        modelValidationEntry.setGroups(Arrays.asList(beanValidation.useGroups()));
+        modelValidationEntry.setMetaData(beanValidation.modelValidation());
+        modelValidationEntry.setMetaDataSourceObject(metaDataSourceObject);
+
+        if(beanValidation.restrictGroups().length > 0)
+        {
+            restrictedGroupsForModelValidation.addAll(Arrays.asList(beanValidation.restrictGroups()));
+        }
+
+        modelValidationEntryList.add(modelValidationEntry);
+    }
+
+    private void processGroups(BeanValidation beanValidation,
+                           List<Class> foundGroupsForPropertyValidation,
+                           List<Class> restrictedGroupsForPropertyValidation)
+    {
+        foundGroupsForPropertyValidation.addAll(Arrays.asList(beanValidation.useGroups()));
+
+        if(beanValidation.restrictGroups().length > 0)
+        {
+            restrictedGroupsForPropertyValidation.addAll(Arrays.asList(beanValidation.restrictGroups()));
+        }
+    }
+
+    private Object resolveTarget(Object metaDataSourceObject, String modelValidationTarget)
+    {
+        ELHelper elHelper = ExtValUtils.getELHelper();
+
+        if(elHelper.isELTermWellFormed(modelValidationTarget))
+        {
+            if(elHelper.isELTermValid(FacesContext.getCurrentInstance(), modelValidationTarget))
+            {
+                return elHelper.getValueOfExpression(
+                        FacesContext.getCurrentInstance(), new ValueBindingExpression(modelValidationTarget));
+            }
+            else
+            {
+                if(this.logger.isErrorEnabled())
+                {
+                    this.logger.error("an invalid binding is used: " + modelValidationTarget);
+                }
+            }
+        }
+
+        String[] properties = modelValidationTarget.split("\\.");
+
+        Object result = metaDataSourceObject;
+        for(String property : properties)
+        {
+            result = getValueOfProperty(result, property);
+
+            if(result == null)
+            {
+                return null;
+            }
+        }
+
+        return result;
+    }
+
+    @ToDo(value = Priority.HIGH, description = "move to util class - the original method is in LocalCompareStrategy")
+    protected Object getValueOfProperty(Object base, String property)
+    {
+        property = property.substring(0,1).toUpperCase() + property.substring(1, property.length());
+        Method targetMethod = ReflectionUtils.tryToGetMethod(base.getClass(), "get" + property);
+
+        if(targetMethod == null)
+        {
+            targetMethod = ReflectionUtils.tryToGetMethod(base.getClass(), "is" + property);
+        }
+
+        if(targetMethod == null)
+        {
+            throw new IllegalStateException(
+                "class " + base.getClass() + " has no public get/is " + property.toLowerCase());
+        }
+        return ReflectionUtils.tryToInvokeMethod(base, targetMethod);
+    }
+}

Added: myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/BeanValidationMetaDataTransformer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/BeanValidationMetaDataTransformer.java?rev=793226&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/BeanValidationMetaDataTransformer.java (added)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/BeanValidationMetaDataTransformer.java Sat Jul 11 21:44:56 2009
@@ -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.myfaces.extensions.validator.beanval.metadata.transformer;
+
+import org.apache.myfaces.extensions.validator.core.metadata.transformer.MetaDataTransformer;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.internal.Priority;
+
+import javax.validation.metadata.ConstraintDescriptor;
+import java.util.Map;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.3
+ */
+@ToDo(value = Priority.HIGH, description = "select final transformer")
+public class BeanValidationMetaDataTransformer implements MetaDataTransformer
+{
+    public Map<String, Object> convertMetaData(MetaDataEntry metaData)
+    {
+        if(isSupportedConstraint(metaData.getValue(ConstraintDescriptor.class)))
+        {
+            //TODO
+        }
+
+        //TODO
+        return null;
+    }
+
+    protected boolean isSupportedConstraint(ConstraintDescriptor constraintDescriptor)
+    {
+        if(!constraintDescriptor.getAnnotation().annotationType().getName().startsWith("javax.validation.constraints"))
+        {
+            return false;
+        }
+
+        String simpleName = constraintDescriptor.getAnnotation().annotationType().getSimpleName();
+
+        return simpleName.equals("Size") || simpleName.equals("Pattern") || simpleName.equals("NotNull");
+    }
+
+}