You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by st...@apache.org on 2013/08/10 14:15:49 UTC

[1/2] git commit: add comment about ALv2 license of this special hibernate part.

Updated Branches:
  refs/heads/master cef50b097 -> a421be8c7


add comment about ALv2 license of this special hibernate part.


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/744fa104
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/744fa104
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/744fa104

Branch: refs/heads/master
Commit: 744fa1046d5e930af976a313b02f427c4be6ac54
Parents: cef50b0
Author: Mark Struberg <st...@apache.org>
Authored: Sat Aug 10 12:06:28 2013 +0200
Committer: Mark Struberg <st...@apache.org>
Committed: Sat Aug 10 12:06:28 2013 +0200

----------------------------------------------------------------------
 deltaspike/modules/data/impl/pom.xml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/744fa104/deltaspike/modules/data/impl/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/pom.xml b/deltaspike/modules/data/impl/pom.xml
index 926d89c..bf06364 100755
--- a/deltaspike/modules/data/impl/pom.xml
+++ b/deltaspike/modules/data/impl/pom.xml
@@ -75,6 +75,7 @@
                     </processors>
                 </configuration>
                 <dependencies>
+                    <!-- this part of Hibernate is Apache License 2.0, thus O.K. for us. -->
                     <dependency>
                         <groupId>org.hibernate</groupId>
                         <artifactId>hibernate-jpamodelgen</artifactId>


[2/2] git commit: DELTASPIKE-385 fix for getBeanManager for ClassLoaders which have not been used in Extension loading

Posted by st...@apache.org.
DELTASPIKE-385 fix for getBeanManager for ClassLoaders which have not been used in Extension loading


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/a421be8c
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/a421be8c
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/a421be8c

Branch: refs/heads/master
Commit: a421be8c740645d1c09402bdf94463b4319fcec1
Parents: 744fa10
Author: Mark Struberg <st...@apache.org>
Authored: Sat Aug 10 14:15:01 2013 +0200
Committer: Mark Struberg <st...@apache.org>
Committed: Sat Aug 10 14:15:01 2013 +0200

----------------------------------------------------------------------
 .../core/api/provider/BeanManagerProvider.java  | 57 ++++++++++++++++++--
 1 file changed, 53 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/a421be8c/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanManagerProvider.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanManagerProvider.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanManagerProvider.java
index 3db6f3a..cfa5907 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanManagerProvider.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanManagerProvider.java
@@ -167,15 +167,22 @@ public class BeanManagerProvider implements Extension
         // warn the user if he tries to use the BeanManager before container startup
         if (!bmi.booted)
         {
-            LOG.warning("When using the BeanManager to retrieve Beans before the Container is started," +
-                    " non-portable behaviour results!");
+            if (!isParentBeanManagerBooted())
+            {
+                LOG.warning("When using the BeanManager to retrieve Beans before the Container is started," +
+                        " non-portable behaviour results!");
+
+                // reset the flag to only issue the warning once.
+                // this is a workaround for some containers which mess up EAR handling.
+                bmi.booted = true;
+            }
         }
 
         BeanManager result = bmi.finalBm;
 
         if (result == null)
         {
-            synchronized (this)
+            synchronized (bmi)
             {
                 result = bmi.finalBm;
                 if (result == null)
@@ -211,7 +218,13 @@ public class BeanManagerProvider implements Extension
      * container might not be fully setup yet.
      *
      * This might happen if someone uses the BeanManagerProvider during Extension
-     * startup.
+     * startup. This should generally avoided but instead you should just use
+     * an injected BeanManager in your Extension and propagate the BeanManager
+     * via setters.
+     *
+     * In EARs with multiple webapps you might get different Extensions per WAR.
+     * This depends on the container you use. By resetting <i>all</i> known
+     * BeanManagerInfos we try to
      */
     public void cleanupFinalBeanManagers(@Observes AfterDeploymentValidation adv)
     {
@@ -303,4 +316,40 @@ public class BeanManagerProvider implements Extension
 
         return bmpSingleton;
     }
+
+    /**
+     * @return whether a BeanManagerInfo for a parent classloader is available and has the booted flag set.
+     */
+    private boolean isParentBeanManagerBooted()
+    {
+        ClassLoader classLoader = ClassUtils.getClassLoader(null);
+        BeanManagerInfo parentBmi = getParentBeanManagerInfo(classLoader);
+
+        return parentBmi != null && parentBmi.booted;
+    }
+
+    /**
+     * This method recurses into the parent ClassLoaders and will check if a
+     * BeanManagerInfo for it exists.
+     * @return the BeanManagerInfo of the parent ClassLoader hierarchy if any exists,
+     *         or <code>null</code> if there is no {@link BeanManagerInfo} for the ClassLoaders in the hierarchy.
+     */
+    private BeanManagerInfo getParentBeanManagerInfo(ClassLoader classLoader)
+    {
+        ClassLoader parentClassLoader = classLoader.getParent();
+        if (parentClassLoader.equals(ClassLoader.getSystemClassLoader()))
+        {
+            return null;
+        }
+
+        BeanManagerInfo bmi = getBeanManagerInfo(parentClassLoader);
+        if (bmi == null)
+        {
+            bmi = getParentBeanManagerInfo(parentClassLoader);
+        }
+
+        return bmi;
+    }
+
+
 }