[seam-commits] Seam SVN: r13642 - in modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence: util and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu Aug 26 04:17:03 EDT 2010


Author: swd847
Date: 2010-08-26 04:17:03 -0400 (Thu, 26 Aug 2010)
New Revision: 13642

Added:
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EnvironmentUtils.java
Modified:
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java
Log:
minor update


Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java	2010-08-26 08:12:29 UTC (rev 13641)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java	2010-08-26 08:17:03 UTC (rev 13642)
@@ -47,6 +47,7 @@
 import javax.persistence.Persistence;
 import javax.persistence.PersistenceContext;
 
+import org.jboss.seam.persistence.util.EnvironmentUtils;
 import org.jboss.weld.extensions.literal.AnyLiteral;
 import org.jboss.weld.extensions.literal.DefaultLiteral;
 import org.slf4j.Logger;
@@ -88,7 +89,7 @@
       }
       else if (bootstrapRequired == null)
       {
-         if (isPersistenceContainerManaged())
+         if (EnvironmentUtils.isEEEnvironment())
          {
             bootstrapRequired = false;
             return;
@@ -241,34 +242,4 @@
       }
    }
 
-   /**
-    * Check whether persistence is container managed. For now, this simply
-    * checks for the presence of the EJB API. If it's present, we assume this is
-    * an EE environment and that persistence is container managed.
-    */
-   boolean isPersistenceContainerManaged()
-   {
-      boolean eeEnv = true;
-      try
-      {
-         if (Thread.currentThread().getContextClassLoader() != null)
-         {
-            Thread.currentThread().getContextClassLoader().loadClass("javax.ejb.Stateless");
-         }
-         else
-         {
-            Class.forName("javax.ejb.Stateless");
-         }
-      }
-      catch (ClassNotFoundException e)
-      {
-         eeEnv = false;
-      }
-      catch (NoClassDefFoundError e)
-      {
-         eeEnv = false;
-      }
-
-      return eeEnv;
-   }
 }

Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EnvironmentUtils.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EnvironmentUtils.java	                        (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EnvironmentUtils.java	2010-08-26 08:17:03 UTC (rev 13642)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.util;
+
+import java.util.Hashtable;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Provides information about the runtime environment
+ * 
+ * @author Stuart Douglas
+ * 
+ */
+public final class EnvironmentUtils
+{
+  public static boolean isEEEnvironment()
+  {
+     boolean eeEnv = true;
+     try
+     {
+        if (Thread.currentThread().getContextClassLoader() != null)
+        {
+           Thread.currentThread().getContextClassLoader().loadClass("javax.ejb.Stateless");
+        }
+        else
+        {
+           Class.forName("javax.ejb.Stateless");
+        }
+     }
+     catch (ClassNotFoundException e)
+     {
+        eeEnv = false;
+     }
+     catch (NoClassDefFoundError e)
+     {
+        eeEnv = false;
+     }
+     return eeEnv;
+  }
+}



More information about the seam-commits mailing list