You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2014/12/24 08:34:14 UTC

[1/2] tomee git commit: stupid WBC.findMissingAnnotatedType impl

Repository: tomee
Updated Branches:
  refs/heads/develop bcbbdd84a -> 02818cc38


stupid WBC.findMissingAnnotatedType impl


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

Branch: refs/heads/develop
Commit: 4c620d6bc11594e035192f5ae4475dec865d674d
Parents: bcbbdd8
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Tue Dec 23 22:09:31 2014 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Tue Dec 23 22:09:31 2014 +0100

----------------------------------------------------------------------
 .../org/apache/openejb/cdi/WebappWebBeansContext.java | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/4c620d6b/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappWebBeansContext.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappWebBeansContext.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappWebBeansContext.java
index 548162e..f8c910f 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappWebBeansContext.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappWebBeansContext.java
@@ -23,6 +23,9 @@ import java.util.Properties;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
 
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+
 public class WebappWebBeansContext extends WebBeansContext {
     private final WebBeansContext parent;
     private BeanManagerImpl bm;
@@ -48,4 +51,15 @@ public class WebappWebBeansContext extends WebBeansContext {
     public WebBeansContext getParent() {
         return parent;
     }
+
+    @Override
+    public boolean findMissingAnnotatedType(final Class<?> missing) {
+        // annotated element caches are empty at this point
+        for (final Bean<?> b : getParent().getBeanManagerImpl().getBeans()) {
+            if (b.getBeanClass() == missing) {
+                return true;
+            }
+        }
+        return false;
+    }
 }


[2/2] tomee git commit: trying to guess a bit better the WBC if the request

Posted by rm...@apache.org.
trying to guess a bit better the WBC if the request


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

Branch: refs/heads/develop
Commit: 02818cc3878dde5647efdbd4537e7e8d28f77647
Parents: 4c620d6
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Tue Dec 23 23:55:05 2014 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Tue Dec 23 23:55:05 2014 +0100

----------------------------------------------------------------------
 .../server/httpd/OpenEJBHttpRegistry.java       | 33 +++++++++++++++-----
 tck/cdi-embedded/src/test/resources/failing.xml |  2 +-
 2 files changed, 27 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/02818cc3/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java
index c884a1c..b2dc7a4 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/OpenEJBHttpRegistry.java
@@ -16,9 +16,12 @@
  */
 package org.apache.openejb.server.httpd;
 
+import org.apache.openejb.AppContext;
 import org.apache.openejb.assembler.classic.OpenEjbConfiguration;
 import org.apache.openejb.assembler.classic.ServiceInfo;
+import org.apache.openejb.core.WebContext;
 import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.ContainerSystem;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
 import org.apache.webbeans.config.WebBeansContext;
@@ -100,27 +103,43 @@ public class OpenEJBHttpRegistry {
         }
 
         public void onMessage(HttpRequest request, HttpResponse response) throws Exception {
-            ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
-            Thread.currentThread().setContextClassLoader(classLoader);
+            Thread thread = Thread.currentThread();
+            ClassLoader oldCl = thread.getContextClassLoader();
+            thread.setContextClassLoader(classLoader);
 
+            WebBeansContext wbc = null;
             try {
                 if (request instanceof HttpRequestImpl) {
-                    initCdi((HttpRequestImpl) request).init();
+                    wbc = findWebContext(request.getURI().getPath());
+                    initCdi(wbc, (HttpRequestImpl) request).init();
                 }
 
                 delegate.onMessage(request, response);
             } finally {
-                if (request instanceof HttpRequestImpl) {
+                if (wbc != null) {
                     ((HttpRequestImpl) request).destroy();
                 }
 
-                Thread.currentThread().setContextClassLoader(oldCl);
+                thread.setContextClassLoader(oldCl);
+            }
+        }
+
+        private static WebBeansContext findWebContext(final String path) { // poor impl, would need registration of app etc to be better
+            for (final AppContext app : SystemInstance.get().getComponent(ContainerSystem.class).getAppContexts()) {
+                for (final WebContext web : app.getWebContexts()) {
+                    if (path.startsWith(web.getContextRoot()) || path.startsWith('/' + web.getContextRoot())) {
+                        if (web.getWebBeansContext() != null) {
+                            return web.getWebBeansContext();
+                        }
+                        return app.getWebBeansContext();
+                    }
+                }
             }
+            return WebBeansContext.currentInstance();
         }
 
-        private static HttpRequestImpl initCdi(final HttpRequestImpl request) {
+        private static HttpRequestImpl initCdi(final WebBeansContext context, final HttpRequestImpl request) {
             try {
-                final WebBeansContext context = WebBeansContext.currentInstance();
                 if (context.getBeanManagerImpl().isInUse()) {
                     request.setBeginListener(new BeginWebBeansListener(context));
                     request.setEndListener(new EndWebBeansListener(context));

http://git-wip-us.apache.org/repos/asf/tomee/blob/02818cc3/tck/cdi-embedded/src/test/resources/failing.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-embedded/src/test/resources/failing.xml b/tck/cdi-embedded/src/test/resources/failing.xml
index 3380601..583fe4d 100644
--- a/tck/cdi-embedded/src/test/resources/failing.xml
+++ b/tck/cdi-embedded/src/test/resources/failing.xml
@@ -19,7 +19,7 @@
   <test name="CDI TCK">
     <!-- -Dopenejb.cdi.filter.classloader=false -Dorg.apache.openejb.assembler.classic.WebAppBuilder=org.apache.openejb.web.LightweightWebAppBuilder -Dopenejb.cdi.debug=true -Dopenejb.http.mock-request=true  -->
     <classes>
-      <class name="org.jboss.cdi.tck.tests.lookup.modules.specialization.SpecializationModularity02Test" />
+      <class name="org.jboss.cdi.tck.tests.context.request.event.RequestScopeEventTest" />
     </classes>
   </test>
 </suite>