Author: epbernard
Date: 2009-06-10 17:48:21 -0400 (Wed, 10 Jun 2009)
New Revision: 16754
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ValidatorFactory.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
Log:
BVAL-161 Add unwrap methods to ValidatorFactory and Validator
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java 2009-06-10
20:48:54 UTC (rev 16753)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java 2009-06-10
21:48:21 UTC (rev 16754)
@@ -100,4 +100,16 @@
* constraints are invalid.
*/
BeanDescriptor getConstraintsForClass(Class<?> clazz);
+
+ /**
+ * Return an object of the specified type to allow access to the
+ * provider-specific API. If the Bean Validation provider
+ * implementation does not support the specified class, the
+ * ValidationException is thrown.
+ * @param type the class of the object to be returned.
+ * @return an instance of the specified class
+ * @throws ValidationException if the provider does not
+ * support the call.
+ */
+ public <T> T unwrap(Class<T> type);
}
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ValidatorFactory.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ValidatorFactory.java 2009-06-10
20:48:54 UTC (rev 16753)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ValidatorFactory.java 2009-06-10
21:48:21 UTC (rev 16754)
@@ -50,4 +50,16 @@
* @return MessageInterpolator instance.
*/
MessageInterpolator getMessageInterpolator();
+
+ /**
+ * Return an object of the specified type to allow access to the
+ * provider-specific API. If the Bean Validation provider
+ * implementation does not support the specified class, the
+ * ValidationException is thrown.
+ * @param type the class of the object to be returned.
+ * @return an instance of the specified class
+ * @throws ValidationException if the provider does not
+ * support the call.
+ */
+ public <T> T unwrap(Class<T> type);
}
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java 2009-06-10
20:48:54 UTC (rev 16753)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java 2009-06-10
21:48:21 UTC (rev 16754)
@@ -27,6 +27,7 @@
import javax.validation.Validator;
import javax.validation.ValidatorContext;
import javax.validation.ValidatorFactory;
+import javax.validation.ValidationException;
import javax.validation.spi.ConfigurationState;
import org.hibernate.validation.engine.xml.AnnotationIgnores;
@@ -70,6 +71,10 @@
return messageInterpolator;
}
+ public <T> T unwrap(Class<T> type) {
+ throw new ValidationException( "Type " + type + " not supported");
+ }
+
/**
* {@inheritDoc}
*/
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-06-10
20:48:54 UTC (rev 16753)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-06-10
21:48:21 UTC (rev 16754)
@@ -34,6 +34,7 @@
import javax.validation.MessageInterpolator;
import javax.validation.TraversableResolver;
import javax.validation.Validator;
+import javax.validation.ValidationException;
import javax.validation.groups.Default;
import com.googlecode.jtype.TypeUtils;
@@ -150,6 +151,10 @@
return getBeanMetaData( clazz ).getBeanDescriptor();
}
+ public <T> T unwrap(Class<T> type) {
+ throw new ValidationException( "Type " + type + " not supported");
+ }
+
private void sanityCheckPropertyPath(String propertyName) {
if ( propertyName == null || propertyName.length() == 0 ) {
throw new IllegalArgumentException( "Invalid property path." );
Show replies by date