deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject deltaspike git commit: DELTASPIKE-1161 [perf] avoid Instance#Select
Date Fri, 03 Jun 2016 08:39:31 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 96761cdbf -> c14297ce2


DELTASPIKE-1161 [perf] avoid Instance#Select

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

Branch: refs/heads/master
Commit: c14297ce2e716df0509a166b8387ac3e164f2f65
Parents: 96761cd
Author: tandraschko <tandraschko@apache.org>
Authored: Fri Jun 3 10:38:58 2016 +0200
Committer: tandraschko <tandraschko@apache.org>
Committed: Fri Jun 3 10:38:58 2016 +0200

----------------------------------------------------------------------
 .../impl/handler/EntityManagerRefLookup.java    | 23 +++++---------------
 1 file changed, 5 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/c14297ce/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerRefLookup.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerRefLookup.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerRefLookup.java
index c43b42f..aab17be 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerRefLookup.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerRefLookup.java
@@ -58,25 +58,12 @@ public class EntityManagerRefLookup
             
             BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();
             Set<Bean<?>> beans = beanManager.getBeans(EntityManager.class);
+            Bean<?> bean = beanManager.resolve(beans);
 
-            if (!beans.isEmpty() && beans.size() == 1)
-            {
-                Class<? extends Annotation> scope = beanManager.resolve(beans).getScope();
-                globalEntityManagerIsNormalScope = beanManager.isNormalScope(scope);
-
-                if (globalEntityManagerIsNormalScope)
-                {
-                    Bean<?> bean = beans.iterator().next();
-                    globalEntityManager = (EntityManager) beanManager.getReference(bean,
-                            EntityManager.class,
-                            beanManager.createCreationalContext(bean));
-                }
-            }
-            else
-            {
-                throw new IllegalArgumentException(
-                        "None or multiple EntityManager's found with the default qualifier.");
-            }            
+            globalEntityManagerIsNormalScope = beanManager.isNormalScope(bean.getScope());
+            globalEntityManager = (EntityManager) beanManager.getReference(bean,
+                    EntityManager.class,
+                    beanManager.createCreationalContext(bean));       
         }
     }
     


Mime
View raw message