You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2015/07/15 00:58:31 UTC

svn commit: r1691102 - /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java

Author: lu4242
Date: Tue Jul 14 22:58:31 2015
New Revision: 1691102

URL: http://svn.apache.org/r1691102
Log:
MYFACES-3998 improve BanManger lookup for CDI-1.1

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java?rev=1691102&r1=1691101&r2=1691102&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java Tue Jul 14 22:58:31 2015
@@ -593,13 +593,16 @@ public abstract class AbstractFacesIniti
             Class cdiClass = null;
             Method cdiCurrentMethod = null;
             Method cdiGetBeanManagerMethod = null;
-            cdiClass = ClassUtils.simpleClassForName("javax.enterprise.inject.spi.CDI");
-            cdiCurrentMethod = cdiClass.getMethod("current");
+            cdiClass = simpleClassForNameNoException("javax.enterprise.inject.spi.CDI");
+            if (cdiClass != null)
+            {
+                cdiCurrentMethod = cdiClass.getMethod("current");
 
-            Object cdiInstance = cdiCurrentMethod.invoke(null);
+                Object cdiInstance = cdiCurrentMethod.invoke(null);
 
-            cdiGetBeanManagerMethod = cdiClass.getMethod("getBeanManager");
-            return cdiGetBeanManagerMethod.invoke(cdiInstance);
+                cdiGetBeanManagerMethod = cdiClass.getMethod("getBeanManager");
+                return cdiGetBeanManagerMethod.invoke(cdiInstance);
+            }
         }
         catch (Exception e)
         {
@@ -607,6 +610,20 @@ public abstract class AbstractFacesIniti
         }
         return null;
     }
+    
+    private static Class simpleClassForNameNoException(String type)
+    {
+        try
+        {
+            return ClassUtils.classForName(type);
+        }
+        catch (ClassNotFoundException e)
+        {
+            //log.log(Level.SEVERE, "Class " + type + " not found", e);
+            //Ignore
+            return null;
+        }
+    }
 
     /**
      * Try to lookup the CDI BeanManager from JNDI.