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/05/18 15:36:21 UTC

svn commit: r775945 [1/2] - in /myfaces/extensions/validator/branches/branch_for_jsf_2: core/src/main/java/org/apache/myfaces/extensions/validator/core/ core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ core/src/main/java/org/apache/m...

Author: gpetracek
Date: Mon May 18 13:36:20 2009
New Revision: 775945

URL: http://svn.apache.org/viewvc?rev=775945&view=rev
Log:
intermediate sync with bv-adapter branch + jsf 2 adjustments

Added:
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/myfaces-extval-bean-validation.iml
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/pom.xml
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/INTERNAL_README
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/faces-config.xml
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/WebXmlParameter.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/BeanValidation.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/GroupValidationKeys.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/ModelValidation.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/NoRestrictionGroup.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/extractor/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/extractor/DefaultGroupControllerScanningExtractor.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/factory/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/factory/ExtValApplicationFactory.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/BeanValidationMetaDataTransformer.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/metadata/transformer/mapper/DefaultBeanValidationStrategyToMetaDataTransformerNameMapper.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/property/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/property/BeanValidationPropertyInformationKeys.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/startup/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/startup/BeanValidationStartupListener.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationEntry.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationPhaseListener.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/message/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/message/interpolator/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/message/interpolator/DefaultMessageInterpolator.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/message/interpolator/ExtValMessageInterpolatorAdapter.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/strategy/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/strategy/BeanValidationStrategyAdapter.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/resources/
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/resources/LICENSE.txt
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/resources/NOTICE.txt
Modified:
    myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKit.java
    myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/pom.xml

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java?rev=775945&r1=775944&r2=775945&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/WebXmlParameter.java Mon May 18 13:36:20 2009
@@ -105,6 +105,9 @@
     static final String DEACTIVATE_EL_RESOLVER = WebXmlUtils
         .getInitParameter("DEACTIVATE_EL_RESOLVER");
 
+    static final String DEACTIVATE_EMPTY_STRING_INTERPRETATION = WebXmlUtils
+        .getInitParameter("DEACTIVATE_EMPTY_STRING_INTERPRETATION");
+
     //there is nothing like DEACTIVATE_DEFAULT_VALIDATION_INTERCEPTOR
     //use ExtValContext.getContext().denyRendererInterceptor(...) within an extval-StartupListener
 }

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java?rev=775945&r1=775944&r2=775945&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java Mon May 18 13:36:20 2009
@@ -153,6 +153,8 @@
         return new ValueBindingExpression(valueBindingExpression);
     }
 
+    @ToDo(value = Priority.BLOCKING, description = "doesn't work with new interface for composite components" +
+            "solution see: BeanValidator.class and ValueExpressionAnalyzer")
     public PropertyDetails getPropertyDetailsOfValueBinding(UIComponent uiComponent)
     {
         if("true".equalsIgnoreCase(DEACTIVATE_EL_RESOLVER))

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKit.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKit.java?rev=775945&r1=775944&r2=775945&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKit.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRenderKit.java Mon May 18 13:36:20 2009
@@ -97,23 +97,28 @@
         return wrapped.createResponseStream(outputStream);
     }
 
-    public Iterator<String> getComponentFamilies() {
+    public Iterator<String> getComponentFamilies()
+    {
         return wrapped.getComponentFamilies();
     }
 
-    public Iterator<String> getRendererTypes(String s) {
+    public Iterator<String> getRendererTypes(String s)
+    {
         return wrapped.getRendererTypes(s);
     }
 
-    public void addClientBehaviorRenderer(String s, ClientBehaviorRenderer clientBehaviorRenderer) {
+    public void addClientBehaviorRenderer(String s, ClientBehaviorRenderer clientBehaviorRenderer)
+    {
         wrapped.addClientBehaviorRenderer(s, clientBehaviorRenderer);
     }
 
-    public ClientBehaviorRenderer getClientBehaviorRenderer(String s) {
+    public ClientBehaviorRenderer getClientBehaviorRenderer(String s)
+    {
         return wrapped.getClientBehaviorRenderer(s);
     }
 
-    public Iterator<String> getClientBehaviorRendererTypes() {
+    public Iterator<String> getClientBehaviorRendererTypes()
+    {
         return wrapped.getClientBehaviorRendererTypes();
     }
 

Added: myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/myfaces-extval-bean-validation.iml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/myfaces-extval-bean-validation.iml?rev=775945&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/myfaces-extval-bean-validation.iml (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/myfaces-extval-bean-validation.iml Mon May 18 13:36:20 2009
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module relativePaths="true" MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/target/classes" />
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/config" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
+      <excludeFolder url="file://$MODULE_DIR$/target" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="myfaces-extval-core" exported="" />
+    <orderEntry type="library" exported="" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
+    <orderEntry type="library" exported="" name="Maven: javax.validation:validation-api:1.0.Beta4" level="project" />
+    <orderEntry type="library" name="Maven: com.sun.faces:jsf-api:2.0.0-b11" level="project" />
+    <orderEntry type="library" name="Maven: javax.el:el-api:1.0" level="project" />
+  </component>
+</module>
+

Added: myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/pom.xml?rev=775945&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/pom.xml (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/pom.xml Mon May 18 13:36:20 2009
@@ -0,0 +1,129 @@
+<?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>2.0bv-PROTOTYPE</version>
+
+    <parent>
+        <groupId>org.apache.myfaces.extensions.validator.validation-modules</groupId>
+        <artifactId>validation-modules-project</artifactId>
+        <version>2.0.3-SNAPSHOT</version>
+    </parent>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.myfaces.extensions.validator</groupId>
+            <artifactId>myfaces-extval-core</artifactId>
+            <version>2.0.3-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+            <version>1.0.Beta4</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.faces</groupId>
+            <artifactId>jsf-api</artifactId>
+            <version>2.0.0-b11</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.el</groupId>
+            <artifactId>el-api</artifactId>
+            <version>1.0</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.1.1</version>
+            <scope>compile</scope>
+        </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/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/INTERNAL_README
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/INTERNAL_README?rev=775945&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/INTERNAL_README (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/INTERNAL_README Mon May 18 13:36:20 2009
@@ -0,0 +1,5 @@
+jsf 2.0 specific changes in (not finished):
+ - ExtValApplicationFactory
+ - ExtValRenderKit
+ - BeanValidationInterceptor (isValidationDisabled, mergeFoundGroupsWithValidatorGroups)
+ - DefaultELHelper
\ No newline at end of file

Added: myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/faces-config.xml?rev=775945&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/faces-config.xml (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/config/faces-config.xml Mon May 18 13:36:20 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">
+    <factory>
+        <application-factory>org.apache.myfaces.extensions.validator.beanval.factory.ExtValApplicationFactory</application-factory>
+    </factory>
+    <lifecycle>
+        <phase-listener>org.apache.myfaces.extensions.validator.beanval.startup.BeanValidationStartupListener</phase-listener>
+        <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/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java?rev=775945&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java Mon May 18 13:36:20 2009
@@ -0,0 +1,780 @@
+/*
+ * 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.recorder.ProcessedInformationRecorder;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.WebXmlParameter;
+import org.apache.myfaces.extensions.validator.core.el.ELHelper;
+import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
+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.util.ReflectionUtils;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
+import org.apache.myfaces.extensions.validator.beanval.property.BeanValidationPropertyInformationKeys;
+import org.apache.myfaces.extensions.validator.beanval.annotation.BeanValidation;
+import org.apache.myfaces.extensions.validator.beanval.annotation.ModelValidation;
+import org.apache.myfaces.extensions.validator.beanval.annotation.extractor.DefaultGroupControllerScanningExtractor;
+import org.apache.myfaces.extensions.validator.beanval.validation.strategy.BeanValidationStrategyAdapter;
+import org.apache.myfaces.extensions.validator.beanval.validation.ModelValidationEntry;
+import org.apache.myfaces.extensions.validator.beanval.annotation.NoRestrictionGroup;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.internal.Priority;
+
+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.validator.Validator;
+import javax.faces.validator.BeanValidator;
+import javax.faces.application.FacesMessage;
+import javax.validation.Validation;
+import javax.validation.BeanDescriptor;
+import javax.validation.ElementDescriptor;
+import javax.validation.ConstraintDescriptor;
+import javax.validation.ValidatorFactory;
+import javax.validation.ConstraintViolation;
+import javax.validation.groups.Default;
+import java.util.Set;
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.io.IOException;
+import java.lang.reflect.Method;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.3
+ */
+@ToDo(value = Priority.HIGH, description = "sync jsf 2.0 specific changes with bv-branch")
+public class BeanValidationInterceptor extends AbstractRendererInterceptor
+{
+    private ValidatorFactory validationFactory = Validation.buildDefaultValidatorFactory();
+
+    @Override
+    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());
+        }
+
+        if(isValidationDisabled(((EditableValueHolder)uiComponent).getValidators()))
+        {
+            return;
+        }
+
+        MetaDataExtractor metaDataExtractor = ExtValUtils.getComponentMetaDataExtractor();
+
+        PropertyInformation propertyInformation = metaDataExtractor.extract(facesContext, uiComponent);
+        PropertyDetails propertyDetails = propertyInformation
+                .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;
+        }
+
+        addMetaDataToContext(propertyInformation, uiComponent);
+
+        Class[] foundGroups = ExtValBeanValidationContext.getCurrentInstance().getGroups(
+                facesContext.getViewRoot().getViewId(),
+                uiComponent.getClientId(facesContext));
+
+        foundGroups = mergeFoundGroupsWithValidatorGroups(
+                foundGroups, ((EditableValueHolder)uiComponent).getValidators());
+
+        BeanDescriptor beanDescriptor = this.validationFactory.getValidator().getConstraintsForClass(
+                propertyDetails.getBaseObject().getClass()/*, foundGroups*/);
+
+        ElementDescriptor elementDescriptor = beanDescriptor.getConstraintsForProperty(propertyDetails.getProperty());
+
+        if(elementDescriptor == null)
+        {
+            return;
+        }
+
+        ValidationStrategy validationStrategy;
+        MetaDataTransformer metaDataTransformer;
+        MetaDataEntry entry;
+        Map<String, Object> metaData;
+
+        for (ConstraintDescriptor<?> constraintDescriptor : elementDescriptor.getConstraintDescriptors())
+        {
+            //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");
+        }
+    }
+
+    @ToDo(value = Priority.HIGH, description = "check if f:validateBean deactivates validation")
+    private boolean isValidationDisabled(Validator[] validators)
+    {
+        //
+        return false;
+    }
+
+
+    @ToDo.List({@ToDo(value = Priority.HIGH, description = "optimize"),
+            @ToDo(value = Priority.HIGH, description = "use reflection instead of BeanValidator for jsf 1.x versions"),
+            @ToDo(value = Priority.HIGH, description = "test")
+    })
+    private Class[] mergeFoundGroupsWithValidatorGroups(Class[] foundGroups, Validator[] validators)
+    {
+        List<String> validatorsOfTagList = new ArrayList<String>();
+
+        for (Validator validator : validators)
+        {
+            if (validator instanceof BeanValidator)
+            {
+                validatorsOfTagList.addAll(
+                        Arrays.asList(((BeanValidator) validator).getValidationGroups().split(",")));
+            }
+        }
+
+        List<Class> result = new ArrayList<Class>(Arrays.asList(foundGroups));
+        Class currentClass;
+        for(String groupClassName : validatorsOfTagList)
+        {
+            currentClass = ClassUtils.tryToLoadClassForName(groupClassName);
+
+            if(currentClass != null && currentClass.isInterface())
+            {
+                result.add(currentClass);
+            }
+            else
+            {
+                if(this.logger.isErrorEnabled())
+                {
+                    this.logger.error(groupClassName + " is no valid group - only existing interfaces are allowed");
+                }
+            }
+        }
+        return result.toArray(new Class[result.size()]);
+    }
+
+    @Override
+    public void beforeGetConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object o, Renderer wrapped)
+            throws ConverterException, SkipBeforeInterceptorsException, SkipRendererDelegationException
+    {
+        Object convertedObject = wrapped.getConvertedValue(facesContext, uiComponent, o);
+
+        //recorde user input e.g. for cross-component validation
+        for (ProcessedInformationRecorder recorder : ExtValContext.getContext().getProcessedInformationRecorders())
+        {
+            recorder.recordUserInput(uiComponent, convertedObject);
+
+            if (logger.isTraceEnabled())
+            {
+                logger.trace(recorder.getClass().getName() + " called");
+            }
+        }
+
+        try
+        {
+            if(processComponent(uiComponent))
+            {
+                processValidation(facesContext, uiComponent, convertedObject);
+            }
+        }
+        catch (ValidatorException e)
+        {
+            throw new ConverterException(e.getFacesMessage(), e);
+        }
+    }
+
+    private 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)
+    {
+        if (logger.isTraceEnabled())
+        {
+            logger.trace("jsr303 start validation");
+        }
+
+        if(isValidationDisabled(((EditableValueHolder)uiComponent).getValidators()))
+        {
+            return;
+        }
+
+        if (!"true".equalsIgnoreCase(WebXmlParameter.DEACTIVATE_EMPTY_STRING_INTERPRETATION)
+                && "".equals(convertedObject))
+        {
+            convertedObject = null;
+        }
+
+        MetaDataExtractor metaDataExtractor = ExtValUtils.getComponentMetaDataExtractor();
+
+        PropertyInformation propertyInformation = metaDataExtractor.extract(facesContext, uiComponent);
+
+        //extract group validation annotations
+        addMetaDataToContext(propertyInformation, uiComponent);
+
+        processFieldValidation(facesContext, uiComponent, convertedObject, propertyInformation);
+
+        if (logger.isTraceEnabled())
+        {
+            logger.trace("jsr303 validation finished");
+        }
+    }
+
+    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);
+    }
+
+    protected void processFoundGroups(ExtValBeanValidationContext extValBeanValidationContext,
+                                      String currentViewId,
+                                      String clientId,
+                                      List<Class> foundGroupsForPropertyValidation)
+    {
+        for (Class currentGroupClass : foundGroupsForPropertyValidation)
+        {
+            extValBeanValidationContext.addGroup(currentGroupClass, currentViewId, clientId);
+        }
+    }
+
+    protected void processRestrictedGroups(ExtValBeanValidationContext extValBeanValidationContext,
+                                         String currentViewId,
+                                         String clientId,
+                                         List<Class> restrictedGroupsForPropertyValidation)
+    {
+        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)
+    {
+        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);
+            }
+        }
+    }
+
+    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));
+
+        groups = mergeFoundGroupsWithValidatorGroups(
+                groups, ((EditableValueHolder)uiComponent).getValidators());
+
+        if(groups == null)
+        {
+            return;
+        }
+
+        Set<ConstraintViolation> violations = this.validationFactory.usingContext()
+                .messageInterpolator(ExtValBeanValidationContext.getCurrentInstance().getMessageInterpolator())
+                .getValidator()
+                .validateValue(baseBeanClass, propertyName, convertedObject, groups);
+
+        if (violations != null && violations.size() > 0)
+        {
+            //TODO jsf 2.0 supports multiple messages -> use all messages
+            ConstraintViolation violation = (ConstraintViolation) violations.toArray()[0];
+
+            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);
+
+            //TODO check & remove
+            propertyInformation.setInformation(
+                    BeanValidationPropertyInformationKeys.CONSTRAINT_VIOLATIONS, violations);
+
+            if (labeledMessage.equals(validatorException.getFacesMessage().getSummary()) ||
+                    labeledMessage.equals(validatorException.getFacesMessage().getDetail()))
+            {
+                throw new ValidatorException(
+                        new FacesMessage(FacesMessage.SEVERITY_ERROR, violationMessage, violationMessage));
+            }
+            else
+            {
+                throw validatorException;
+            }
+        }
+    }
+    
+    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 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);
+        }
+    }
+
+    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 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 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 processGroups(BeanValidation beanValidation,
+                           List<Class> foundGroupsForPropertyValidation,
+                           List<Class> restrictedGroupsForPropertyValidation)
+    {
+        foundGroupsForPropertyValidation.addAll(Arrays.asList(beanValidation.useGroups()));
+
+        if(!(beanValidation.restrictGroups().length == 1 &&
+                beanValidation.restrictGroups()[0].equals(NoRestrictionGroup.class)))
+        {
+            restrictedGroupsForPropertyValidation.addAll(Arrays.asList(beanValidation.restrictGroups()));
+        }
+    }
+
+    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 == 1 &&
+                beanValidation.restrictGroups()[0].equals(NoRestrictionGroup.class)))
+        {
+            restrictedGroupsForModelValidation.addAll(Arrays.asList(beanValidation.restrictGroups()));
+        }
+
+        modelValidationEntryList.add(modelValidationEntry);
+    }
+
+    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 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);
+    }
+
+    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;
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java?rev=775945&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java Mon May 18 13:36:20 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/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/WebXmlParameter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/WebXmlParameter.java?rev=775945&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/WebXmlParameter.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/WebXmlParameter.java Mon May 18 13:36:20 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/branches/branch_for_jsf_2/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/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/BeanValidation.java?rev=775945&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/BeanValidation.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/BeanValidation.java Mon May 18 13:36:20 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 NoRestrictionGroup.class;
+
+    @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/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/GroupValidationKeys.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/GroupValidationKeys.java?rev=775945&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/GroupValidationKeys.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/GroupValidationKeys.java Mon May 18 13:36:20 2009
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public interface GroupValidationKeys
+{
+    static final String GROUPS_TO_VALIDATE = "groups_to_validate";
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2/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/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/ModelValidation.java?rev=775945&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/ModelValidation.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/ModelValidation.java Mon May 18 13:36:20 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/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/NoRestrictionGroup.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/NoRestrictionGroup.java?rev=775945&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/NoRestrictionGroup.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/annotation/NoRestrictionGroup.java Mon May 18 13:36:20 2009
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+/**
+ * default group for restricted groups
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.3
+ */
+
+@UsageInformation(UsageCategory.INTERNAL)
+public interface NoRestrictionGroup
+{
+}
\ No newline at end of file