geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vamsic...@apache.org
Subject svn commit: r997732 - /geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/DefaultValidatorReference.java
Date Thu, 16 Sep 2010 13:03:46 GMT
Author: vamsic007
Date: Thu Sep 16 13:03:45 2010
New Revision: 997732

URL: http://svn.apache.org/viewvc?rev=997732&view=rev
Log:
GERONIMO-5221 Add naming support for Validator and ValidatorFactory
 o DefaultValidator should use configured ValidatorFactory if any

Modified:
    geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/DefaultValidatorReference.java

Modified: geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/DefaultValidatorReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/DefaultValidatorReference.java?rev=997732&r1=997731&r2=997732&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/DefaultValidatorReference.java
(original)
+++ geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/DefaultValidatorReference.java
Thu Sep 16 13:03:45 2010
@@ -20,8 +20,11 @@
 
 package org.apache.geronimo.bval;
 
+import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
+
 import org.apache.xbean.naming.reference.SimpleReference;
 
 /**
@@ -30,6 +33,14 @@ import org.apache.xbean.naming.reference
 public class DefaultValidatorReference extends SimpleReference {
     @Override
     public Object getContent() throws NamingException {
-        return Validation.buildDefaultValidatorFactory().getValidator();
+        ValidatorFactory factory = null;
+        
+        try {
+            factory = (ValidatorFactory)new InitialContext().lookup("java:comp/ValidatorFactory");
+        } catch(NamingException e) {
+            factory = Validation.buildDefaultValidatorFactory();
+        }
+        
+        return factory.getValidator();
     }
 }
\ No newline at end of file



Mime
View raw message