tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-1913 trying to deactivate CDI fallback to see how much it does hurt
Date Wed, 24 Aug 2016 10:31:35 GMT
Repository: tomee
Updated Branches:
  refs/heads/master e6ebfddea -> 069385506


TOMEE-1913 trying to deactivate CDI fallback to see how much it does hurt


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

Branch: refs/heads/master
Commit: 06938550651525c7c513c9a848b059ef8951fc45
Parents: e6ebfdd
Author: Romain manni-Bucau <rmannibucau@gmail.com>
Authored: Wed Aug 24 12:31:17 2016 +0200
Committer: Romain manni-Bucau <rmannibucau@gmail.com>
Committed: Wed Aug 24 12:31:17 2016 +0200

----------------------------------------------------------------------
 .../openejb/cdi/ThreadSingletonServiceImpl.java | 37 +++-----------------
 1 file changed, 4 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/06938550/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
b/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
index 5170eba..afcfc5f 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
@@ -22,7 +22,6 @@ import org.apache.openejb.assembler.classic.AppInfo;
 import org.apache.openejb.assembler.classic.EjbJarInfo;
 import org.apache.openejb.cdi.transactional.TransactionContext;
 import org.apache.openejb.loader.SystemInstance;
-import org.apache.openejb.spi.ContainerSystem;
 import org.apache.openejb.util.AppFinder;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
@@ -33,6 +32,7 @@ import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.corespi.se.DefaultApplicationBoundaryService;
 import org.apache.webbeans.intercept.ApplicationScopedBeanInterceptorHandler;
 import org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler;
+import org.apache.webbeans.intercept.RequestScopedBeanInterceptorHandler;
 import org.apache.webbeans.intercept.SessionScopedBeanInterceptorHandler;
 import org.apache.webbeans.spi.ApplicationBoundaryService;
 import org.apache.webbeans.spi.BeanArchiveService;
@@ -46,17 +46,13 @@ import org.apache.webbeans.spi.ScannerService;
 import org.apache.webbeans.spi.SecurityService;
 import org.apache.webbeans.spi.TransactionService;
 import org.apache.webbeans.spi.adaptor.ELAdaptor;
-import org.apache.webbeans.intercept.RequestScopedBeanInterceptorHandler;
 
-import java.util.Collections;
-import java.util.Comparator;
+import javax.enterprise.inject.spi.DeploymentException;
+import javax.transaction.Transactional;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
-import javax.enterprise.inject.spi.DeploymentException;
-import javax.transaction.Transactional;
 
 /**
  * @version $Rev:$ $Date:$
@@ -287,14 +283,7 @@ public class ThreadSingletonServiceImpl implements ThreadSingletonService
{
         context = AppFinder.findAppContextOrWeb(cl, AppFinder.WebBeansContextTransformer.INSTANCE);
         if (context == null) {
             context = contexts.get();
-            if (context == null) {
-                // Fallback strategy is to just grab the first AppContext and assume it is
the right one
-                // This kind of algorithm could be greatly improved
-                final List<AppContext> appContexts = SystemInstance.get().getComponent(ContainerSystem.class).getAppContexts();
-                if (appContexts.size() > 0) {
-                    return getWebBeansContext(appContexts);
-                }
-
+            if (context == null) { // any "guess" algortithm there would break prod apps
cause AppFinder failed already, let's try to not try to be more clever than we can
                 throw new IllegalStateException("On a thread without an initialized context
nor a classloader mapping a deployed app");
             }
         } else { // some cache to avoid to browse each app each time
@@ -304,24 +293,6 @@ public class ThreadSingletonServiceImpl implements ThreadSingletonService
{
         return context;
     }
 
-    private static WebBeansContext getWebBeansContext(final List<AppContext> appContexts)
{
-        Collections.sort(appContexts, new Comparator<AppContext>() {
-            @Override
-            public int compare(final AppContext appContext, final AppContext appContext1)
{
-                return cdiSize(appContext1) - cdiSize(appContext);
-            }
-        });
-        return appContexts.get(0).getWebBeansContext();
-    }
-
-    private static int cdiSize(final AppContext ctx) {
-        final WebBeansContext wbc = ctx.getWebBeansContext();
-        if (wbc == null) {
-            return 0;
-        }
-        return wbc.getBeanManagerImpl().getBeans().size();
-    }
-
     @Override
     public WebBeansContext get(final Object key) {
         return getContext((ClassLoader) key);


Mime
View raw message