tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: ensuring batchee uses the right classloader forcing some eager bean manager access
Date Fri, 11 Sep 2015 05:55:35 GMT
Repository: tomee
Updated Branches:
  refs/heads/master 549d7334e -> e158fb678


ensuring batchee uses the right classloader forcing some eager bean manager access


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

Branch: refs/heads/master
Commit: e158fb678a30633cf8516b1ca32aba5762866465
Parents: 549d733
Author: Romain Manni-Bucau <rmannibu@gmail.com>
Authored: Thu Sep 10 22:55:17 2015 -0700
Committer: Romain Manni-Bucau <rmannibu@gmail.com>
Committed: Thu Sep 10 22:55:17 2015 -0700

----------------------------------------------------------------------
 .../apache/openejb/batchee/BatchEEServiceManager.java | 14 ++++++++++++++
 .../apache/openejb/cdi/OptimizedLoaderService.java    |  5 ++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/e158fb67/container/openejb-core/src/main/java/org/apache/openejb/batchee/BatchEEServiceManager.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/batchee/BatchEEServiceManager.java
b/container/openejb-core/src/main/java/org/apache/openejb/batchee/BatchEEServiceManager.java
index ae62276..09aecc8 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/batchee/BatchEEServiceManager.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/batchee/BatchEEServiceManager.java
@@ -18,13 +18,17 @@ package org.apache.openejb.batchee;
 
 import org.apache.batchee.container.services.ServicesManager;
 import org.apache.batchee.container.services.ServicesManagerLocator;
+import org.apache.batchee.container.services.factory.CDIBatchArtifactFactory;
+import org.apache.batchee.spi.BatchArtifactFactory;
 import org.apache.openejb.AppContext;
 import org.apache.openejb.assembler.classic.event.AssemblerAfterApplicationCreated;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.observer.Observes;
 import org.apache.openejb.observer.event.ObserverAdded;
 import org.apache.openejb.util.AppFinder;
+import org.apache.webbeans.config.WebBeansContext;
 
+import javax.enterprise.inject.spi.BeanManager;
 import java.util.Properties;
 
 public class BatchEEServiceManager implements ServicesManagerLocator {
@@ -43,6 +47,9 @@ public class BatchEEServiceManager implements ServicesManagerLocator {
         thread.setContextClassLoader(init.getContext().getClassLoader());
         final ServicesManager servicesManager = new ServicesManager();
         try {
+            if (properties.getProperty(BatchArtifactFactory.class.getName()) == null) {
+                properties.setProperty(BatchArtifactFactory.class.getName(), TomEEArtifactFactory.class.getName());
+            }
             servicesManager.init(properties); // will look for batchee.properties so need
the right classloader
         } finally {
             thread.setContextClassLoader(current);
@@ -60,4 +67,11 @@ public class BatchEEServiceManager implements ServicesManagerLocator {
         }
         throw new IllegalStateException("Can't find ServiceManager for " + contextClassLoader);
     }
+
+    public static class TomEEArtifactFactory extends CDIBatchArtifactFactory {
+        @Override
+        protected BeanManager getBeanManager() {
+            return WebBeansContext.currentInstance().getBeanManagerImpl();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/e158fb67/container/openejb-core/src/main/java/org/apache/openejb/cdi/OptimizedLoaderService.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/OptimizedLoaderService.java
b/container/openejb-core/src/main/java/org/apache/openejb/cdi/OptimizedLoaderService.java
index 8a10bcc..1317520 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/OptimizedLoaderService.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/OptimizedLoaderService.java
@@ -18,6 +18,7 @@
 package org.apache.openejb.cdi;
 
 import org.apache.openejb.core.ParentClassLoaderFinder;
+import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.classloader.ClassLoaderAwareHandler;
@@ -25,6 +26,7 @@ import org.apache.webbeans.service.DefaultLoaderService;
 import org.apache.webbeans.spi.LoaderService;
 import org.apache.webbeans.spi.plugins.OpenWebBeansPlugin;
 
+import javax.enterprise.inject.spi.Extension;
 import java.lang.reflect.Proxy;
 import java.net.URL;
 import java.util.ArrayList;
@@ -33,7 +35,6 @@ import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
-import javax.enterprise.inject.spi.Extension;
 
 /**
  * @version $Rev$ $Date$
@@ -120,6 +121,8 @@ public class OptimizedLoaderService implements LoaderService {
                     }
                 }
                 break;
+            case "org.apache.batchee.container.cdi.BatchCDIInjectionExtension": // see org.apache.openejb.batchee.BatchEEServiceManager
+                return "true".equals(SystemInstance.get().getProperty("tomee.batchee.cdi.use-extension",
"false"));
             case "org.apache.commons.jcs.jcache.cdi.MakeJCacheCDIInterceptorFriendly":
                 final String spi = "META-INF/services/javax.cache.spi.CachingProvider";
                 try {


Mime
View raw message