[hibernate-commits] Hibernate SVN: r15891 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Feb 4 12:16:57 EST 2009


Author: hardy.ferentschik
Date: 2009-02-04 12:16:57 -0500 (Wed, 04 Feb 2009)
New Revision: 15891

Added:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java
Removed:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidationContext.java
Modified:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
Log:
Renaming ValidationContext into ExecutionContext. See how this goes. An laternative would be ValidatorExectutionContext, but I would like to avoid 'Validator' or 'Validation'

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java	2009-02-04 16:44:02 UTC (rev 15890)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java	2009-02-04 17:16:57 UTC (rev 15891)
@@ -80,31 +80,31 @@
 		return descriptor;
 	}
 
-	public void validateConstraints(Object value, Class beanClass, ValidationContext validationContext) {
+	public void validateConstraints(Object value, Class beanClass, ExecutionContext executionContext) {
 		for ( ConstraintTree tree : getChildren() ) {
-			tree.validateConstraints( value, beanClass, validationContext );
+			tree.validateConstraints( value, beanClass, executionContext );
 		}
 
-		final Object leafBeanInstance = validationContext.peekValidatedObject();
+		final Object leafBeanInstance = executionContext.peekValidatedObject();
 		ConstraintValidatorContextImpl constraintContext = new ConstraintValidatorContextImpl( descriptor );
 		if ( log.isTraceEnabled() ) {
 			log.trace( "Validating value {} against constraint defined by {}", value, descriptor );
 		}
 		ConstraintValidator validator = getInitalizedValidator(
-				value, validationContext.getConstraintValidatorFactory()
+				value, executionContext.getConstraintValidatorFactory()
 		);
 		if ( !validator.isValid( value, constraintContext ) ) {
 			for ( ConstraintValidatorContextImpl.ErrorMessage error : constraintContext.getErrorMessages() ) {
 				final String message = error.getMessage();
-				createConstraintViolation( value, beanClass, validationContext, leafBeanInstance, message, descriptor );
+				createConstraintViolation( value, beanClass, executionContext, leafBeanInstance, message, descriptor );
 			}
 		}
 		if ( reportAsSingleViolation()
-				&& validationContext.getFailingConstraints().size() > 0 ) {
-			validationContext.clearFailingConstraints();
+				&& executionContext.getFailingConstraints().size() > 0 ) {
+			executionContext.clearFailingConstraints();
 			final String message = ( String ) getParent().getDescriptor().getParameters().get( "message" );
 			createConstraintViolation(
-					value, beanClass, validationContext, leafBeanInstance, message, getParent().descriptor
+					value, beanClass, executionContext, leafBeanInstance, message, getParent().descriptor
 			);
 		}
 	}
@@ -114,8 +114,8 @@
 				&& getParent().getDescriptor().isReportAsSingleViolation();
 	}
 
-	private <T> void createConstraintViolation(Object value, Class<T> beanClass, ValidationContext<T> validationContext, Object leafBeanInstance, String message, ConstraintDescriptor descriptor) {
-		String interpolatedMessage = validationContext.getMessageResolver().interpolate(
+	private <T> void createConstraintViolation(Object value, Class<T> beanClass, ExecutionContext<T> executionContext, Object leafBeanInstance, String message, ConstraintDescriptor descriptor) {
+		String interpolatedMessage = executionContext.getMessageResolver().interpolate(
 				message,
 				descriptor,
 				leafBeanInstance
@@ -123,15 +123,15 @@
 		ConstraintViolationImpl<T> failingConstraintViolation = new ConstraintViolationImpl<T>(
 				message,
 				interpolatedMessage,
-				validationContext.getRootBean(),
+				executionContext.getRootBean(),
 				beanClass,
 				leafBeanInstance,
 				value,
-				validationContext.peekPropertyPath(), //FIXME use error.getProperty()
-				validationContext.getCurrentGroup(),
+				executionContext.peekPropertyPath(), //FIXME use error.getProperty()
+				executionContext.getCurrentGroup(),
 				descriptor
 		);
-		validationContext.addConstraintFailure( failingConstraintViolation );
+		executionContext.addConstraintFailure( failingConstraintViolation );
 	}
 
 	/**

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java (from rev 15883, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidationContext.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java	2009-02-04 17:16:57 UTC (rev 15891)
@@ -0,0 +1,232 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,  
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.engine;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Stack;
+import javax.validation.ConstraintValidatorFactory;
+import javax.validation.MessageInterpolator;
+
+import org.hibernate.validation.util.IdentitySet;
+
+/**
+ * Context object keeping track of all processed objects and all failing constraints.
+ * At the same time it keeps track of the currently validated object, the current group and property path.
+ * The way the validation works at the moment the validated object and the property path have to be processed
+ * in a stack fashion.
+ * <p/>
+ * all sort of information needed  Introduced to reduce the parameters passed around between the different
+ * validate methdods in <code>ValidatorImpl</code>.
+ *
+ * @author Hardy Ferentschik
+ * @author Emmanuel Bernard
+ */
+public class ExecutionContext<T> {
+
+	/**
+	 * The root bean of the validation.
+	 */
+	private final T rootBean;
+
+	/**
+	 * Maps for each group to an identity set to keep track of already validated objects. We have to make sure
+	 * that each object gets only validated once (per group).
+	 */
+	private final Map<Class<?>, IdentitySet> processedObjects;
+
+	/**
+	 * A list of all failing constraints so far.
+	 */
+	private final List<ConstraintViolationImpl<T>> failingConstraintViolations;
+
+	/**
+	 * The current property path.
+	 */
+	private String propertyPath;
+
+	/**
+	 * The current group which is getting processed.
+	 */
+	private Class<?> currentGroup;
+
+	/**
+	 * Stack for keeping track of the currently validated object.
+	 */
+	private Stack<ValidatedBean> validatedObjectStack = new Stack<ValidatedBean>();
+
+	/**
+	 * The message resolver which should be used in this context.
+	 */
+	private final MessageInterpolator messageResolver;
+
+	/**
+	 * The constraint factory which should be used in this context.
+	 */
+	ConstraintValidatorFactory constraintValidatorFactory;
+
+
+	public ExecutionContext(T object, MessageInterpolator messageResolver, ConstraintValidatorFactory constraintValidatorFactory) {
+		this( object, object, messageResolver, constraintValidatorFactory );
+	}
+
+	public ExecutionContext(T rootBean, Object object, MessageInterpolator messageResolver, ConstraintValidatorFactory constraintValidatorFactory) {
+		this.rootBean = rootBean;
+		this.messageResolver = messageResolver;
+		this.constraintValidatorFactory = constraintValidatorFactory;
+		validatedObjectStack.push( new ValidatedBean( object ) );
+		processedObjects = new HashMap<Class<?>, IdentitySet>();
+		propertyPath = "";
+		failingConstraintViolations = new ArrayList<ConstraintViolationImpl<T>>();
+	}
+
+	public MessageInterpolator getMessageResolver() {
+		return messageResolver;
+	}
+
+	public ConstraintValidatorFactory getConstraintValidatorFactory() {
+		return constraintValidatorFactory;
+	}
+
+	public Object peekValidatedObject() {
+		return validatedObjectStack.peek().bean;
+	}
+
+	public Class<?> peekValidatedObjectType() {
+		return validatedObjectStack.peek().beanType;
+	}
+
+	public void pushValidatedObject(Object validatedObject) {
+		validatedObjectStack.push( new ValidatedBean( validatedObject ) );
+	}
+
+	public void popValidatedObject() {
+		validatedObjectStack.pop();
+	}
+
+	public T getRootBean() {
+		return rootBean;
+	}
+
+	public Class<?> getCurrentGroup() {
+		return currentGroup;
+	}
+
+	public void setCurrentGroup(Class<?> currentGroup) {
+		this.currentGroup = currentGroup;
+	}
+
+	public void markProcessedForCurrentGroup() {
+		if ( processedObjects.containsKey( currentGroup ) ) {
+			processedObjects.get( currentGroup ).add( validatedObjectStack.peek().bean );
+		}
+		else {
+			IdentitySet set = new IdentitySet();
+			set.add( validatedObjectStack.peek().bean );
+			processedObjects.put( currentGroup, set );
+		}
+	}
+
+	public boolean isProcessedForCurrentGroup(Object value) {
+		final IdentitySet objectsProcessedInCurrentGroups = processedObjects.get( currentGroup );
+		return objectsProcessedInCurrentGroups != null && objectsProcessedInCurrentGroups.contains( value );
+	}
+
+	public void addConstraintFailure(ConstraintViolationImpl<T> failingConstraintViolation) {
+		int i = failingConstraintViolations.indexOf( failingConstraintViolation );
+		if ( i == -1 ) {
+			failingConstraintViolations.add( failingConstraintViolation );
+		}
+		else {
+			failingConstraintViolations.get( i ).addGroups( failingConstraintViolation.getGroups() );
+		}
+	}
+
+	public List<ConstraintViolationImpl<T>> getFailingConstraints() {
+		return failingConstraintViolations;
+	}
+
+	public void clearFailingConstraints() {
+		failingConstraintViolations.clear();
+	}
+
+	/**
+	 * Adds a new level to the current property path of this context.
+	 *
+	 * @param property the new property to add to the current path.
+	 */
+	public void pushProperty(String property) {
+		if ( propertyPath.length() == 0 ) {
+			propertyPath = property;
+		}
+		else {
+			propertyPath = propertyPath + "." + property;
+		}
+	}
+
+	/**
+	 * Drops the last level of the current property path of this context.
+	 */
+	public void popProperty() {
+		int lastIndex = propertyPath.lastIndexOf( '.' );
+		if ( lastIndex != -1 ) {
+			propertyPath = propertyPath.substring( 0, lastIndex );
+		}
+		else {
+			propertyPath = "";
+		}
+	}
+
+	public void appendIndexToPropertyPath(String index) {
+		propertyPath += index;
+	}
+
+	public void replacePropertyIndex(String index) {
+		propertyPath = propertyPath.replaceAll( "\\{0\\}", index );
+	}
+
+	public String peekPropertyPath() {
+		return propertyPath;
+	}
+
+	public boolean needsValidation(Set<Class<?>> groups) {
+		return groups.contains( currentGroup );
+	}
+
+	/**
+	 * @todo Is it useful to cache the object class?
+	 */
+	private static class ValidatedBean {
+
+		final Object bean;
+		final Class<?> beanType;
+
+		private ValidatedBean(Object bean) {
+			this.bean = bean;
+			if ( bean == null ) {
+				this.beanType = null;
+			}
+			else {
+				this.beanType = bean.getClass();
+			}
+		}
+	}
+}
\ No newline at end of file


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java	2009-02-04 16:44:02 UTC (rev 15890)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java	2009-02-04 17:16:57 UTC (rev 15891)
@@ -167,14 +167,14 @@
 		return constraintTree;
 	}
 
-	public <T> void validateConstraint(Class beanClass, ValidationContext<T> validationContext) {
-		final Object leafBeanInstance = validationContext.peekValidatedObject();
+	public <T> void validateConstraint(Class beanClass, ExecutionContext<T> executionContext) {
+		final Object leafBeanInstance = executionContext.peekValidatedObject();
 		Object value = getValue( leafBeanInstance );
-		constraintTree.validateConstraints( value, beanClass, validationContext );
+		constraintTree.validateConstraints( value, beanClass, executionContext );
 	}
 
-	public <T> void validateConstraint(Class beanClass, Object value, ValidationContext<T> validationContext) {
-		constraintTree.validateConstraints( value, beanClass, validationContext );
+	public <T> void validateConstraint(Class beanClass, Object value, ExecutionContext<T> executionContext) {
+		constraintTree.validateConstraints( value, beanClass, executionContext );
 	}
 
 	private Type typeOfAnnoatedElement() {

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidationContext.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidationContext.java	2009-02-04 16:44:02 UTC (rev 15890)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidationContext.java	2009-02-04 17:16:57 UTC (rev 15891)
@@ -1,232 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,  
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.engine;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Stack;
-import javax.validation.ConstraintValidatorFactory;
-import javax.validation.MessageInterpolator;
-
-import org.hibernate.validation.util.IdentitySet;
-
-/**
- * Context object keeping track of all processed objects and all failing constraints.
- * At the same time it keeps track of the currently validated object, the current group and property path.
- * The way the validation works at the moment the validated object and the property path have to be processed
- * in a stack fashion.
- * <p/>
- * all sort of information needed  Introduced to reduce the parameters passed around between the different
- * validate methdods in <code>ValidatorImpl</code>.
- *
- * @author Hardy Ferentschik
- * @author Emmanuel Bernard
- */
-public class ValidationContext<T> {
-
-	/**
-	 * The root bean of the validation.
-	 */
-	private final T rootBean;
-
-	/**
-	 * Maps for each group to an identity set to keep track of already validated objects. We have to make sure
-	 * that each object gets only validated once (per group).
-	 */
-	private final Map<Class<?>, IdentitySet> processedObjects;
-
-	/**
-	 * A list of all failing constraints so far.
-	 */
-	private final List<ConstraintViolationImpl<T>> failingConstraintViolations;
-
-	/**
-	 * The current property path.
-	 */
-	private String propertyPath;
-
-	/**
-	 * The current group which is getting processed.
-	 */
-	private Class<?> currentGroup;
-
-	/**
-	 * Stack for keeping track of the currently validated object.
-	 */
-	private Stack<ValidatedBean> validatedObjectStack = new Stack<ValidatedBean>();
-
-	/**
-	 * The message resolver which should be used in this context.
-	 */
-	private final MessageInterpolator messageResolver;
-
-	/**
-	 * The constraint factory which should be used in this context.
-	 */
-	ConstraintValidatorFactory constraintValidatorFactory;
-
-
-	public ValidationContext(T object, MessageInterpolator messageResolver, ConstraintValidatorFactory constraintValidatorFactory) {
-		this( object, object, messageResolver, constraintValidatorFactory );
-	}
-
-	public ValidationContext(T rootBean, Object object, MessageInterpolator messageResolver, ConstraintValidatorFactory constraintValidatorFactory) {
-		this.rootBean = rootBean;
-		this.messageResolver = messageResolver;
-		this.constraintValidatorFactory = constraintValidatorFactory;
-		validatedObjectStack.push( new ValidatedBean( object ) );
-		processedObjects = new HashMap<Class<?>, IdentitySet>();
-		propertyPath = "";
-		failingConstraintViolations = new ArrayList<ConstraintViolationImpl<T>>();
-	}
-
-	public MessageInterpolator getMessageResolver() {
-		return messageResolver;
-	}
-
-	public ConstraintValidatorFactory getConstraintValidatorFactory() {
-		return constraintValidatorFactory;
-	}
-
-	public Object peekValidatedObject() {
-		return validatedObjectStack.peek().bean;
-	}
-
-	public Class<?> peekValidatedObjectType() {
-		return validatedObjectStack.peek().beanType;
-	}
-
-	public void pushValidatedObject(Object validatedObject) {
-		validatedObjectStack.push( new ValidatedBean( validatedObject ) );
-	}
-
-	public void popValidatedObject() {
-		validatedObjectStack.pop();
-	}
-
-	public T getRootBean() {
-		return rootBean;
-	}
-
-	public Class<?> getCurrentGroup() {
-		return currentGroup;
-	}
-
-	public void setCurrentGroup(Class<?> currentGroup) {
-		this.currentGroup = currentGroup;
-	}
-
-	public void markProcessedForCurrentGroup() {
-		if ( processedObjects.containsKey( currentGroup ) ) {
-			processedObjects.get( currentGroup ).add( validatedObjectStack.peek().bean );
-		}
-		else {
-			IdentitySet set = new IdentitySet();
-			set.add( validatedObjectStack.peek().bean );
-			processedObjects.put( currentGroup, set );
-		}
-	}
-
-	public boolean isProcessedForCurrentGroup(Object value) {
-		final IdentitySet objectsProcessedInCurrentGroups = processedObjects.get( currentGroup );
-		return objectsProcessedInCurrentGroups != null && objectsProcessedInCurrentGroups.contains( value );
-	}
-
-	public void addConstraintFailure(ConstraintViolationImpl<T> failingConstraintViolation) {
-		int i = failingConstraintViolations.indexOf( failingConstraintViolation );
-		if ( i == -1 ) {
-			failingConstraintViolations.add( failingConstraintViolation );
-		}
-		else {
-			failingConstraintViolations.get( i ).addGroups( failingConstraintViolation.getGroups() );
-		}
-	}
-
-	public List<ConstraintViolationImpl<T>> getFailingConstraints() {
-		return failingConstraintViolations;
-	}
-
-	public void clearFailingConstraints() {
-		failingConstraintViolations.clear();
-	}
-
-	/**
-	 * Adds a new level to the current property path of this context.
-	 *
-	 * @param property the new property to add to the current path.
-	 */
-	public void pushProperty(String property) {
-		if ( propertyPath.length() == 0 ) {
-			propertyPath = property;
-		}
-		else {
-			propertyPath = propertyPath + "." + property;
-		}
-	}
-
-	/**
-	 * Drops the last level of the current property path of this context.
-	 */
-	public void popProperty() {
-		int lastIndex = propertyPath.lastIndexOf( '.' );
-		if ( lastIndex != -1 ) {
-			propertyPath = propertyPath.substring( 0, lastIndex );
-		}
-		else {
-			propertyPath = "";
-		}
-	}
-
-	public void appendIndexToPropertyPath(String index) {
-		propertyPath += index;
-	}
-
-	public void replacePropertyIndex(String index) {
-		propertyPath = propertyPath.replaceAll( "\\{0\\}", index );
-	}
-
-	public String peekPropertyPath() {
-		return propertyPath;
-	}
-
-	public boolean needsValidation(Set<Class<?>> groups) {
-		return groups.contains( currentGroup );
-	}
-
-	/**
-	 * @todo Is it useful to cache the object class?
-	 */
-	private static class ValidatedBean {
-
-		final Object bean;
-		final Class<?> beanType;
-
-		private ValidatedBean(Object bean) {
-			this.bean = bean;
-			if ( bean == null ) {
-				this.beanType = null;
-			}
-			else {
-				this.beanType = bean.getClass();
-			}
-		}
-	}
-}
\ No newline at end of file

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java	2009-02-04 16:44:02 UTC (rev 15890)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java	2009-02-04 17:16:57 UTC (rev 15891)
@@ -81,7 +81,7 @@
 			throw new IllegalArgumentException( "Validation of a null object" );
 		}
 
-		ValidationContext<T> context = new ValidationContext<T>(
+		ExecutionContext<T> context = new ExecutionContext<T>(
 				object, messageInterpolator, constraintValidatorFactory
 		);
 		List<ConstraintViolationImpl<T>> list = validateInContext( context, Arrays.asList( groups ) );
@@ -100,7 +100,7 @@
 	 * @todo Currently we iterate the cascaded fields multiple times. Maybe we should change to an approach where we iterate the object graph only once.
 	 * @todo Context root bean can be a different object than the current Validator<T> hence two different generics variables
 	 */
-	private <T> List<ConstraintViolationImpl<T>> validateInContext(ValidationContext<T> context, List<Class<?>> groups) {
+	private <T> List<ConstraintViolationImpl<T>> validateInContext(ExecutionContext<T> context, List<Class<?>> groups) {
 		if ( context.peekValidatedObject() == null ) {
 			return Collections.emptyList();
 		}
@@ -133,30 +133,30 @@
 	/**
 	 * Validates the non-cascaded constraints.
 	 *
-	 * @param validationContext The current validation context.
+	 * @param executionContext The current validation context.
 	 */
-	private <T> void validateConstraints(ValidationContext<T> validationContext) {
+	private <T> void validateConstraints(ExecutionContext<T> executionContext) {
 		//casting rely on the fact that root object is at the top of the stack
 		@SuppressWarnings("unchecked")
 		BeanMetaData<T> beanMetaData =
-				( BeanMetaData<T> ) getBeanMetaData( validationContext.peekValidatedObjectType() );
+				( BeanMetaData<T> ) getBeanMetaData( executionContext.peekValidatedObjectType() );
 		for ( MetaConstraint metaConstraint : beanMetaData.geMetaConstraintList() ) {
 			ConstraintDescriptor mainConstraintDescriptor = metaConstraint.getDescriptor();
 
-			validationContext.pushProperty( metaConstraint.getPropertyName() );
+			executionContext.pushProperty( metaConstraint.getPropertyName() );
 
-			if ( !validationContext.needsValidation( mainConstraintDescriptor.getGroups() ) ) {
-				validationContext.popProperty();
+			if ( !executionContext.needsValidation( mainConstraintDescriptor.getGroups() ) ) {
+				executionContext.popProperty();
 				continue;
 			}
 
-			metaConstraint.validateConstraint( beanMetaData.getBeanClass(), validationContext );
-			validationContext.popProperty();
+			metaConstraint.validateConstraint( beanMetaData.getBeanClass(), executionContext );
+			executionContext.popProperty();
 		}
-		validationContext.markProcessedForCurrentGroup();
+		executionContext.markProcessedForCurrentGroup();
 	}
 
-	private <T> void validateCascadedConstraints(ValidationContext<T> context) {
+	private <T> void validateCascadedConstraints(ExecutionContext<T> context) {
 		List<Member> cascadedMembers = getBeanMetaData( context.peekValidatedObjectType() )
 				.getCascadedMembers();
 		for ( Member member : cascadedMembers ) {
@@ -181,7 +181,7 @@
 	 * @param value the actual value.
 	 * @return An iterator over the value of a cascaded property.
 	 */
-	private <T> Iterator<?> createIteratorForCascadedValue(ValidationContext<T> context, Type type, Object value) {
+	private <T> Iterator<?> createIteratorForCascadedValue(ExecutionContext<T> context, Type type, Object value) {
 		Iterator<?> iter;
 		if ( ReflectionHelper.isCollection( type ) ) {
 			boolean isIterable = value instanceof Iterable;
@@ -205,7 +205,7 @@
 		return iter;
 	}	
 
-	private <T> void validateCascadedConstraint(ValidationContext<T> context, Iterator<?> iter) {
+	private <T> void validateCascadedConstraint(ExecutionContext<T> context, Iterator<?> iter) {
 		Object actualValue;
 		String propertyIndex;
 		int i = 0;
@@ -275,7 +275,7 @@
 						continue;
 					}
 
-					ValidationContext<T> context = new ValidationContext<T>(
+					ExecutionContext<T> context = new ExecutionContext<T>(
 							object, messageInterpolator, constraintValidatorFactory
 					);
 					metaConstraint.validateConstraint( object.getClass(), context );
@@ -328,7 +328,7 @@
 						continue;
 					}
 
-					ValidationContext<T> context = new ValidationContext<T>(
+					ExecutionContext<T> context = new ExecutionContext<T>(
 							( T ) value, messageInterpolator, constraintValidatorFactory
 					);
 					context.pushProperty( propertyIter.getOriginalProperty() );




More information about the hibernate-commits mailing list