Author: alexsmirnov
Date: 2009-07-16 20:34:10 -0400 (Thu, 16 Jul 2009)
New Revision: 14944
Added:
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/component/UIBeanValidator.java
Modified:
branches/community/3.3.X/samples/beanValidatorSample/pom.xml
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/ObjectValidator.java
Log:
https://jira.jboss.org/jira/browse/RF-7226
Modified: branches/community/3.3.X/samples/beanValidatorSample/pom.xml
===================================================================
--- branches/community/3.3.X/samples/beanValidatorSample/pom.xml 2009-07-16 15:45:54 UTC
(rev 14943)
+++ branches/community/3.3.X/samples/beanValidatorSample/pom.xml 2009-07-17 00:34:10 UTC
(rev 14944)
@@ -135,5 +135,16 @@
</dependency>
</dependencies>
</profile>
+ <profile>
+ <!-- That profile appends validation-api library to check initialization process
-->
+ <id>validation-api</id>
+ <dependencies>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ <version>1.0.CR2</version>
+ </dependency>
+ </dependencies>
+ </profile>
</profiles>
</project>
\ No newline at end of file
Added:
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/component/UIBeanValidator.java
===================================================================
---
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/component/UIBeanValidator.java
(rev 0)
+++
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/component/UIBeanValidator.java 2009-07-17
00:34:10 UTC (rev 14944)
@@ -0,0 +1,23 @@
+/**
+ *
+ */
+package org.richfaces.component;
+
+/**
+ * Stage class to keep backward compatibility.
+ * @author asmirnov
+ * @deprecated That class has been renamed, Use {@link UIAjaxValidator} instead
+ *
+ */
+public abstract class UIBeanValidator extends UIAjaxValidator {
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+
+}
Property changes on:
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/component/UIBeanValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java
===================================================================
---
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java 2009-07-16
15:45:54 UTC (rev 14943)
+++
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java 2009-07-17
00:34:10 UTC (rev 14944)
@@ -24,11 +24,15 @@
public class BeanValidator extends ObjectValidator {
private static final Class[] DEFAULT_PROFILE = new Class[] {};
- private volatile ValidatorFactory validatorFactory = null;
+ private final ValidatorFactory validatorFactory;
BeanValidator() {
// Enforce class to load
ValidatorFactory.class.getName();
+ // Check Factory, to avoid instantiation errors
+ //
https://jira.jboss.org/jira/browse/RF-7226
+ validatorFactory = Validation
+ .buildDefaultValidatorFactory();
}
/*
@@ -103,22 +107,6 @@
}
protected Validator getValidator(Locale locale) {
- if (null == validatorFactory) {
- synchronized (this) {
- if (null == validatorFactory) {
- try {
- validatorFactory = Validation
- .buildDefaultValidatorFactory();
- } catch (ValidationException e) {
- throw new FacesException(
- "Could not build a default Bean Validator factory",
- e);
- }
-
- }
- }
- }
-
ValidatorContext validatorContext = validatorFactory.usingContext();
MessageInterpolator jsfMessageInterpolator = new JsfMessageInterpolator(
locale, validatorFactory.getMessageInterpolator());
Modified:
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/ObjectValidator.java
===================================================================
---
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/ObjectValidator.java 2009-07-16
15:45:54 UTC (rev 14943)
+++
branches/community/3.3.X/ui/beanValidator/src/main/java/org/richfaces/validator/ObjectValidator.java 2009-07-17
00:34:10 UTC (rev 14944)
@@ -19,6 +19,8 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.el.ELContextWrapper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
public abstract class ObjectValidator {
@@ -32,6 +34,8 @@
.getName();
private static final Object MUTEX = new Object();
+
+ private static final Log log = LogFactory.getLog(ObjectValidator.class);
/**
* Create BeanValidator instance. For a Junit tests only.
@@ -45,12 +49,12 @@
ObjectValidator validator;
try {
validator = new BeanValidator();
-
- } catch (NoClassDefFoundError e) {
+ } catch (Throwable e) {
+ log.warn("Bean Validator could not be instantiated", e);
try {
validator = new HibernateValidator();
-
- } catch (NoClassDefFoundError e2) {
+ } catch (Throwable e2) {
+ log.warn("Hibernate Validator could not be instantiated, use stub instead",
e);
validator = new NullValidator();
}
}