You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ja...@apache.org on 2010/03/18 01:11:36 UTC

svn commit: r924566 - in /myfaces/core/trunk/api/src/main/java/javax/faces/component: _ExternalSpecifications.java _ValidationUtils.java

Author: jakobk
Date: Thu Mar 18 00:11:36 2010
New Revision: 924566

URL: http://svn.apache.org/viewvc?rev=924566&view=rev
Log:
MYFACES-2613 ExternalSpecifications has an import from javax.validation api, and this one should be optional (also applied changes for _ExternalSpecifications in javax.faces.component package)

Added:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/_ValidationUtils.java   (with props)
Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/_ExternalSpecifications.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/_ExternalSpecifications.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/_ExternalSpecifications.java?rev=924566&r1=924565&r2=924566&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/_ExternalSpecifications.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/_ExternalSpecifications.java Thu Mar 18 00:11:36 2010
@@ -21,8 +21,6 @@ package javax.faces.component;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javax.validation.Validation;
-
 /**
  * <p>
  * Package-private utility class for determining which specifications are available
@@ -54,8 +52,15 @@ final class _ExternalSpecifications
         {
             try
             {
-                beanValidationAvailable = (Class.forName("javax.validation.Validation") != null);
-
+                try
+                {
+                    beanValidationAvailable = (Class.forName("javax.validation.Validation") != null);
+                }
+                catch (ClassNotFoundException e)
+                {
+                    beanValidationAvailable = Boolean.FALSE;
+                }
+                
                 if (beanValidationAvailable)
                 {
                     try
@@ -63,7 +68,7 @@ final class _ExternalSpecifications
                         // Trial-error approach to check for Bean Validation impl existence.
                         // If any Exception occurs here, we assume that Bean Validation is not available.
                         // The cause may be anything, i.e. NoClassDef, config error...
-                        Validation.buildDefaultValidatorFactory().getValidator();
+                        _ValidationUtils.tryBuildDefaultValidatorFactory();
                     }
                     catch (Throwable t)
                     {

Added: myfaces/core/trunk/api/src/main/java/javax/faces/component/_ValidationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/_ValidationUtils.java?rev=924566&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/_ValidationUtils.java (added)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/_ValidationUtils.java Thu Mar 18 00:11:36 2010
@@ -0,0 +1,37 @@
+/*
+ * 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 javax.faces.component;
+
+import javax.validation.Validation;
+
+/**
+ * Utility class that isolates javax.validation, to prevent ClassNotFoundException
+ * 
+ * @since 2.0
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+final class _ValidationUtils
+{
+
+    public static void tryBuildDefaultValidatorFactory()
+    {
+        Validation.buildDefaultValidatorFactory().getValidator();
+    }
+}

Propchange: myfaces/core/trunk/api/src/main/java/javax/faces/component/_ValidationUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/trunk/api/src/main/java/javax/faces/component/_ValidationUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/core/trunk/api/src/main/java/javax/faces/component/_ValidationUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain