Author: hardy.ferentschik
Date: 2009-08-19 08:48:52 -0400 (Wed, 19 Aug 2009)
New Revision: 17358
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java
Log:
made sure that the default package also applies for annotation
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java 2009-08-19
10:20:42 UTC (rev 17357)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java 2009-08-19
12:48:52 UTC (rev 17358)
@@ -91,8 +91,10 @@
public void parse(Set<InputStream> mappingStreams) {
for ( InputStream in : mappingStreams ) {
ConstraintMappingsType mapping = getValidationConfig( in );
- parseConstraintDefinitions( mapping.getConstraintDefinition() );
String defaultPackage = mapping.getDefaultPackage();
+
+ parseConstraintDefinitions( mapping.getConstraintDefinition(), defaultPackage );
+
for ( BeanType bean : mapping.getBean() ) {
Class<?> beanClass = getClass( bean.getClazz(), defaultPackage );
checkClassHasNotBeenProcessed( processedClasses, beanClass );
@@ -147,17 +149,15 @@
}
@SuppressWarnings("unchecked")
- private void parseConstraintDefinitions(List<ConstraintDefinitionType>
constraintDefinitionList) {
+ private void parseConstraintDefinitions(List<ConstraintDefinitionType>
constraintDefinitionList, String defaultPackage) {
for ( ConstraintDefinitionType constraintDefinition : constraintDefinitionList ) {
String annotationClassName = constraintDefinition.getAnnotation();
- Class<? extends Annotation> annotationClass;
- annotationClass = ( Class<? extends Annotation> ) loadClass(
- annotationClassName, this.getClass()
- );
- if ( !annotationClass.isAnnotation() ) {
+ Class<?> clazz = getClass( annotationClassName, defaultPackage );
+ if ( !clazz.isAnnotation() ) {
throw new ValidationException( annotationClassName + " is not an
annotation" );
}
+ Class<? extends Annotation> annotationClass = (Class<? extends
Annotation>) clazz;
ValidatedByType validatedByType = constraintDefinition.getValidatedBy();
List<Class<? extends ConstraintValidator<? extends Annotation, ?>>>
constraintValidatorClasses = new ArrayList<Class<? extends ConstraintValidator<?
extends Annotation, ?>>>();
Show replies by date