Skip to content

Commit 6ed86fc

Browse files
marko-bekhtagsmet
authored andcommitted
HV-1577 Move from JAXB to Stax for XML mappings
1 parent 50665fe commit 6ed86fc

31 files changed

+2939
-442
lines changed

engine/src/main/java/org/hibernate/validator/internal/cfg/context/TypeConstraintMappingContextImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public MethodConstraintMappingContext method(String name, Class<?>... parameterT
144144
Method method = run( GetDeclaredMethod.action( beanClass, name, parameterTypes ) );
145145

146146
if ( method == null || method.getDeclaringClass() != beanClass ) {
147-
throw LOG.getBeanDoesNotContainMethodException( beanClass, name, Arrays.asList( parameterTypes ) );
147+
throw LOG.getBeanDoesNotContainMethodException( beanClass, name, parameterTypes );
148148
}
149149

150150
if ( configuredMembers.contains( method ) ) {
@@ -168,7 +168,7 @@ public ConstructorConstraintMappingContext constructor(Class<?>... parameterType
168168
if ( constructor == null || constructor.getDeclaringClass() != beanClass ) {
169169
throw LOG.getBeanDoesNotContainConstructorException(
170170
beanClass,
171-
Arrays.asList( parameterTypes )
171+
parameterTypes
172172
);
173173
}
174174

engine/src/main/java/org/hibernate/validator/internal/metadata/provider/XmlMetaDataProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.hibernate.validator.internal.util.CollectionHelper;
2121
import org.hibernate.validator.internal.util.TypeResolutionHelper;
2222
import org.hibernate.validator.internal.util.stereotypes.Immutable;
23-
import org.hibernate.validator.internal.xml.MappingXmlParser;
23+
import org.hibernate.validator.internal.xml.mapping.MappingXmlParser;
2424

2525
/**
2626
* A {@link MetaDataProvider} providing constraint related meta data based on

engine/src/main/java/org/hibernate/validator/internal/util/logging/Log.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@
4848
import org.hibernate.validator.internal.engine.messageinterpolation.parser.MessageDescriptorFormatException;
4949
import org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.ConstraintType;
5050
import org.hibernate.validator.internal.metadata.location.ConstraintLocation;
51+
import org.hibernate.validator.internal.util.logging.formatter.ArrayOfClassesObjectFormatter;
5152
import org.hibernate.validator.internal.util.logging.formatter.ClassObjectFormatter;
5253
import org.hibernate.validator.internal.util.logging.formatter.CollectionOfClassesObjectFormatter;
5354
import org.hibernate.validator.internal.util.logging.formatter.CollectionOfObjectsToStringFormatter;
5455
import org.hibernate.validator.internal.util.logging.formatter.DurationFormatter;
5556
import org.hibernate.validator.internal.util.logging.formatter.ExecutableFormatter;
5657
import org.hibernate.validator.internal.util.logging.formatter.ObjectArrayFormatter;
5758
import org.hibernate.validator.internal.util.logging.formatter.TypeFormatter;
58-
import org.hibernate.validator.internal.xml.ContainerElementTypePath;
59+
import org.hibernate.validator.internal.xml.mapping.ContainerElementTypePath;
5960
import org.hibernate.validator.spi.scripting.ScriptEvaluationException;
6061
import org.hibernate.validator.spi.scripting.ScriptEvaluatorFactory;
6162
import org.hibernate.validator.spi.scripting.ScriptEvaluatorNotFoundException;
@@ -379,7 +380,7 @@ RuntimeException getTryingToInstantiateAnnotationWithUnknownAttributesException(
379380
ValidationException getIsNotAConstraintValidatorClassException(@FormatWith(ClassObjectFormatter.class) Class<?> validatorClass);
380381

381382
@Message(id = 103, value = "%s is configured at least twice in xml.")
382-
ValidationException getBeanClassHasAlreadyBeConfiguredInXmlException(@FormatWith(ClassObjectFormatter.class) Class<?> beanClass);
383+
ValidationException getBeanClassHasAlreadyBeenConfiguredInXmlException(@FormatWith(ClassObjectFormatter.class) Class<?> beanClass);
383384

384385
@Message(id = 104, value = "%1$s is defined twice in mapping xml for bean %2$s.")
385386
ValidationException getIsDefinedTwiceInMappingXmlForBeanException(String name, @FormatWith(ClassObjectFormatter.class) Class<?> beanClass);
@@ -468,14 +469,14 @@ ConstraintDeclarationException getMultipleGroupConversionsForSameSourceException
468469

469470
@Message(id = 133, value = "%1$s does not contain a constructor with the parameter types %2$s.")
470471
ValidationException getBeanDoesNotContainConstructorException(@FormatWith(ClassObjectFormatter.class) Class<?> beanClass,
471-
@FormatWith(CollectionOfClassesObjectFormatter.class) List<Class<?>> parameterTypes);
472+
@FormatWith(ArrayOfClassesObjectFormatter.class) Class<?>[] parameterTypes);
472473

473474
@Message(id = 134, value = "Unable to load parameter of type '%1$s' in %2$s.")
474475
ValidationException getInvalidParameterTypeException(String type, @FormatWith(ClassObjectFormatter.class) Class<?> beanClass);
475476

476477
@Message(id = 135, value = "%1$s does not contain a method with the name '%2$s' and parameter types %3$s.")
477478
ValidationException getBeanDoesNotContainMethodException(@FormatWith(ClassObjectFormatter.class) Class<?> beanClass, String methodName,
478-
@FormatWith(CollectionOfClassesObjectFormatter.class) List<Class<?>> parameterTypes);
479+
@FormatWith(ArrayOfClassesObjectFormatter.class) Class<?>[] parameterTypes);
479480

480481
@Message(id = 136, value = "The specified constraint annotation class %1$s cannot be loaded.")
481482
ValidationException getUnableToLoadConstraintAnnotationClassException(String constraintAnnotationClassName, @Cause Exception e);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Hibernate Validator, declare and validate application constraints
3+
*
4+
* License: Apache License, Version 2.0
5+
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
6+
*/
7+
package org.hibernate.validator.internal.util.logging.formatter;
8+
9+
import java.util.Arrays;
10+
import java.util.stream.Collectors;
11+
12+
/**
13+
* Used with JBoss Logging to display array of class names in log messages.
14+
*
15+
* @author Guillaume Smet
16+
* @author Marko Bekhta
17+
*/
18+
public class ArrayOfClassesObjectFormatter {
19+
20+
private final String stringRepresentation;
21+
22+
public ArrayOfClassesObjectFormatter(Class<?>[] classes) {
23+
this.stringRepresentation = Arrays.stream( classes )
24+
.map( c -> c.getName() )
25+
.collect( Collectors.joining( ", " ) );
26+
}
27+
28+
@Override
29+
public String toString() {
30+
return stringRepresentation;
31+
}
32+
}

engine/src/main/java/org/hibernate/validator/internal/xml/ConstrainedExecutableBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Set<ConstrainedExecutable> buildMethodConstrainedExecutable(List<MethodType> met
102102
throw LOG.getBeanDoesNotContainMethodException(
103103
beanClass,
104104
methodName,
105-
parameterTypes
105+
parameterTypes.toArray( new Class[parameterTypes.size()] )
106106
);
107107
}
108108

@@ -157,7 +157,7 @@ Set<ConstrainedExecutable> buildConstructorConstrainedExecutable(List<Constructo
157157
if ( constructor == null ) {
158158
throw LOG.getBeanDoesNotContainConstructorException(
159159
beanClass,
160-
constructorParameterTypes
160+
constructorParameterTypes.toArray( new Class[constructorParameterTypes.size()] )
161161
);
162162
}
163163
if ( alreadyProcessedConstructors.contains( constructor ) ) {

0 commit comments

Comments
 (0)