geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r1026266 - in /geronimo/server/trunk: plugins/bval/geronimo-bval-builder/src/main/java/org/apache/geronimo/bval/deployment/ plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/ testsuite/javaee6-testsuite/beanvalidation-tests/...
Date Fri, 22 Oct 2010 09:32:49 GMT
Author: rickmcguire
Date: Fri Oct 22 09:32:49 2010
New Revision: 1026266

URL: http://svn.apache.org/viewvc?rev=1026266&view=rev
Log:
Fix bean validation tck deploy errors

Added:
    geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/ValidatorFactoryResourceReference.java
  (with props)
Modified:
    geronimo/server/trunk/plugins/bval/geronimo-bval-builder/src/main/java/org/apache/geronimo/bval/deployment/BValNamingBuilder.java
    geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/DefaultValidatorReference.java
    geronimo/server/trunk/testsuite/javaee6-testsuite/beanvalidation-tests/beanvalidation-web-test/src/main/java/org/apache/geronimo/sample/RegisterValidation/Action/submitInfo.java

Modified: geronimo/server/trunk/plugins/bval/geronimo-bval-builder/src/main/java/org/apache/geronimo/bval/deployment/BValNamingBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/bval/geronimo-bval-builder/src/main/java/org/apache/geronimo/bval/deployment/BValNamingBuilder.java?rev=1026266&r1=1026265&r2=1026266&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/bval/geronimo-bval-builder/src/main/java/org/apache/geronimo/bval/deployment/BValNamingBuilder.java
(original)
+++ geronimo/server/trunk/plugins/bval/geronimo-bval-builder/src/main/java/org/apache/geronimo/bval/deployment/BValNamingBuilder.java
Fri Oct 22 09:32:49 2010
@@ -28,6 +28,7 @@ import javax.validation.ValidatorFactory
 
 import org.apache.geronimo.bval.DefaultValidatorFactoryReference;
 import org.apache.geronimo.bval.DefaultValidatorReference;
+import org.apache.geronimo.bval.ValidatorFactoryResourceReference;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.annotation.GBean;
@@ -72,7 +73,7 @@ public class BValNamingBuilder extends A
             moduleContext.getGBeanInstance(abstractName);
             String osgiJndiName = module.getEarContext().getNaming().toOsgiJndiName(abstractName);
             String filter = "(osgi.jndi.service.name=" + osgiJndiName + ')';
-            put("java:comp/ValidatorFactory", new ResourceReference<ValidationException>(filter,
ValidatorFactory.class.getName()), module.getJndiContext(), Collections.<InjectionTarget>emptyList(),
sharedContext);
+            put("java:comp/ValidatorFactory", new ValidatorFactoryResourceReference(filter,
ValidatorFactory.class.getName()), module.getJndiContext(), Collections.<InjectionTarget>emptyList(),
sharedContext);
         } catch (GBeanNotFoundException e) {
             // if we can't find one on the module, then bind to a default validator factory

             put("java:comp/ValidatorFactory", new DefaultValidatorFactoryReference(), module.getJndiContext(),
Collections.<InjectionTarget>emptyList(), sharedContext);

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=1026266&r1=1026265&r2=1026266&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
Fri Oct 22 09:32:49 2010
@@ -23,6 +23,7 @@ package org.apache.geronimo.bval;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.validation.Validation;
+import javax.validation.ValidationException;
 import javax.validation.ValidatorFactory;
 
 import org.apache.xbean.naming.reference.SimpleReference;
@@ -36,11 +37,15 @@ public class DefaultValidatorReference e
         ValidatorFactory factory = null;
         
         try {
-            factory = (ValidatorFactory)new InitialContext().lookup("java:comp/ValidatorFactory");
-        } catch(NamingException e) {
-            factory = Validation.buildDefaultValidatorFactory();
+            try {
+                factory = (ValidatorFactory)new InitialContext().lookup("java:comp/ValidatorFactory");
+            } catch(NamingException e) {
+                factory = Validation.buildDefaultValidatorFactory();
+            }
+            return factory.getValidator();
+        } catch (ValidationException v) {
+            throw (NamingException)new NamingException("Could not create Validator instance").initCause(v);
         }
         
-        return factory.getValidator();
     }
 }
\ No newline at end of file

Added: geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/ValidatorFactoryResourceReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/ValidatorFactoryResourceReference.java?rev=1026266&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/ValidatorFactoryResourceReference.java
(added)
+++ geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/ValidatorFactoryResourceReference.java
Fri Oct 22 09:32:49 2010
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.bval;
+ 
+import javax.naming.NamingException;
+import javax.validation.Validation;
+import javax.validation.ValidationException;
+import javax.validation.ValidatorFactory;
+
+import org.apache.geronimo.naming.reference.ResourceReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ValidatorFactoryResourceReference extends ResourceReference<ValidationException>
{
+
+    public ValidatorFactoryResourceReference(String query, String type) {
+        super(query, type);
+    }
+    
+    @Override
+    public Object getContent() throws NamingException {
+        // get the associated reference and use that to request the validator 
+        try {
+            return (ValidatorFactory)super.getContent();
+        } catch (ValidationException e) {
+            // turn any creation errors into a NamingException 
+            throw (NamingException)new NamingException("Could not create ValidatorFactory
instance").initCause(e);
+        }
+    }
+}
+
+

Propchange: geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/ValidatorFactoryResourceReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/ValidatorFactoryResourceReference.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/bval/geronimo-bval/src/main/java/org/apache/geronimo/bval/ValidatorFactoryResourceReference.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/beanvalidation-tests/beanvalidation-web-test/src/main/java/org/apache/geronimo/sample/RegisterValidation/Action/submitInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/beanvalidation-tests/beanvalidation-web-test/src/main/java/org/apache/geronimo/sample/RegisterValidation/Action/submitInfo.java?rev=1026266&r1=1026265&r2=1026266&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/javaee6-testsuite/beanvalidation-tests/beanvalidation-web-test/src/main/java/org/apache/geronimo/sample/RegisterValidation/Action/submitInfo.java
(original)
+++ geronimo/server/trunk/testsuite/javaee6-testsuite/beanvalidation-tests/beanvalidation-web-test/src/main/java/org/apache/geronimo/sample/RegisterValidation/Action/submitInfo.java
Fri Oct 22 09:32:49 2010
@@ -101,6 +101,11 @@ public class submitInfo extends HttpServ
             InitialContext ctx = new InitialContext();
             vf = (ValidatorFactory)ctx.lookup("java:comp/ValidatorFactory");
             validator = (Validator)ctx.lookup("java:comp/Validator");
+            Validator validator2 = (Validator)ctx.lookup("java:comp/Validator");
+            if (validator == validator2) {
+                message += "<b>JNDI Validator is a singleton<br>";
+                violationSize += 1; 
+            }
         } catch (NamingException e) {
             // log this as a violation 
             message += "<b>Unable to obtain validator from JNDI:</b>" + e.getMessage()
+ "<br>";



Mime
View raw message