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/26 22:35:37 UTC

tomee git commit: destroy conversation built with auto session id

Repository: tomee
Updated Branches:
  refs/heads/develop 56bf09992 -> 2a9630a02


destroy conversation built with auto session id


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

Branch: refs/heads/develop
Commit: 2a9630a02faac7073f2f5285d65063dd4db879a7
Parents: 56bf099
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Fri Dec 26 22:34:55 2014 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Fri Dec 26 22:34:55 2014 +0100

----------------------------------------------------------------------
 .../openejb/cdi/CdiAppContextsService.java      | 27 ++++++++++++++------
 .../java/org/apache/openejb/cdi/CdiPlugin.java  |  9 ++++++-
 .../server/httpd/EndWebBeansListener.java       |  5 ++--
 tck/cdi-embedded/src/test/resources/failing.xml |  3 +--
 4 files changed, 31 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/2a9630a0/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
index 6d1a662..28bca5d 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiAppContextsService.java
@@ -134,6 +134,17 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
         endRequestRunnables.get().add(runnable);
     }
 
+    public String currentSessionId() {
+        final ServletRequestContext rc = requestContext.get();
+        if (rc != null) {
+            final HttpServletRequest req = rc.getServletRequest();
+            if (req != null) {
+                return req.getSession().getId();
+            }
+        }
+        return null;
+    }
+
     @Override
     public void init(final Object initializeObject) {
         //Start application context
@@ -652,10 +663,10 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
     }
 
     public static class InitializedLiteral extends AnnotationLiteral<Initialized> implements Initialized {
-        private static final InitializedLiteral APP = new InitializedLiteral(ApplicationScoped.class);
-        private static final InitializedLiteral CONVERSATION = new InitializedLiteral(ConversationScoped.class);
-        private static final InitializedLiteral REQUEST = new InitializedLiteral(RequestScoped.class);
-        private static final InitializedLiteral SESSION = new InitializedLiteral(SessionScoped.class);
+        public static final InitializedLiteral APP = new InitializedLiteral(ApplicationScoped.class);
+        public static final InitializedLiteral CONVERSATION = new InitializedLiteral(ConversationScoped.class);
+        public static final InitializedLiteral REQUEST = new InitializedLiteral(RequestScoped.class);
+        public static final InitializedLiteral SESSION = new InitializedLiteral(SessionScoped.class);
 
         private final Class<? extends Annotation> value;
 
@@ -669,10 +680,10 @@ public class CdiAppContextsService extends AbstractContextsService implements Co
     }
 
     public static class DestroyedLiteral extends AnnotationLiteral<Destroyed> implements Destroyed {
-        private static final DestroyedLiteral APP = new DestroyedLiteral(ApplicationScoped.class);
-        private static final DestroyedLiteral CONVERSATION = new DestroyedLiteral(ConversationScoped.class);
-        private static final DestroyedLiteral REQUEST = new DestroyedLiteral(RequestScoped.class);
-        private static final DestroyedLiteral SESSION = new DestroyedLiteral(SessionScoped.class);
+        public static final DestroyedLiteral APP = new DestroyedLiteral(ApplicationScoped.class);
+        public static final DestroyedLiteral CONVERSATION = new DestroyedLiteral(ConversationScoped.class);
+        public static final DestroyedLiteral REQUEST = new DestroyedLiteral(RequestScoped.class);
+        public static final DestroyedLiteral SESSION = new DestroyedLiteral(SessionScoped.class);
 
         private final Class<? extends Annotation> value;
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/2a9630a0/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java
index 1fd35e2..919bd9b 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java
@@ -41,12 +41,14 @@ import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.portable.events.discovery.BeforeShutdownImpl;
 import org.apache.webbeans.portable.events.generics.GProcessSessionBean;
 import org.apache.webbeans.proxy.NormalScopeProxyFactory;
+import org.apache.webbeans.spi.ContextsService;
 import org.apache.webbeans.spi.ResourceInjectionService;
 import org.apache.webbeans.spi.SecurityService;
 import org.apache.webbeans.spi.TransactionService;
 import org.apache.webbeans.spi.plugins.AbstractOwbPlugin;
 import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
 import org.apache.webbeans.spi.plugins.OpenWebBeansJavaEEPlugin;
+import org.apache.webbeans.spi.plugins.OpenWebBeansWebPlugin;
 import org.apache.webbeans.util.WebBeansUtil;
 
 import javax.enterprise.context.ApplicationScoped;
@@ -90,7 +92,7 @@ import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
 
 
-public class CdiPlugin extends AbstractOwbPlugin implements OpenWebBeansJavaEEPlugin, OpenWebBeansEjbPlugin {
+public class CdiPlugin extends AbstractOwbPlugin implements OpenWebBeansJavaEEPlugin, OpenWebBeansEjbPlugin, OpenWebBeansWebPlugin {
 
     private Map<Class<?>, BeanContext> beans;
 
@@ -110,6 +112,11 @@ public class CdiPlugin extends AbstractOwbPlugin implements OpenWebBeansJavaEEPl
     }
 
     @Override
+    public String currentSessionId() {
+        return CdiAppContextsService.class.cast(webBeansContext.getService(ContextsService.class)).currentSessionId();
+    }
+
+    @Override
     public boolean isEEComponent(final Class<?> impl) {
         return Servlet.class.isAssignableFrom(impl) || Filter.class.isAssignableFrom(impl) || ServletContextListener.class.isAssignableFrom(impl);
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/2a9630a0/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java
----------------------------------------------------------------------
diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java
index df902ef..b17ae58 100644
--- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java
+++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java
@@ -171,9 +171,10 @@ public class EndWebBeansListener implements ServletContextListener, ServletReque
 
         final ConversationManager conversationManager = webBeansContext.getConversationManager();
         final Map<Conversation, ConversationContext> cc = conversationManager.getAndRemoveConversationMapWithSessionId(event.getSession().getId());
-        for (final ConversationContext c : cc.values()) {
+        for (final Map.Entry<Conversation, ConversationContext> c : cc.entrySet()) {
             if (c != null) {
-                c.destroy();
+                c.getValue().destroy();
+                webBeansContext.getBeanManagerImpl().fireEvent(c.getKey().getId(), CdiAppContextsService.DestroyedLiteral.CONVERSATION);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/2a9630a0/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 44dd461..d51d44f 100644
--- a/tck/cdi-embedded/src/test/resources/failing.xml
+++ b/tck/cdi-embedded/src/test/resources/failing.xml
@@ -26,8 +26,7 @@
     -Dopenejb.deploymentId.format={appId}/{ejbJarId}/{ejbName}
     -->
     <classes>
-      <class name="org.jboss.cdi.tck.tests.context.conversation.filter.ConversationFilterTest" />
-      <!--<class name="org.jboss.cdi.tck.tests.context.conversation.event.notattached.DestroyConversationNotAssociatedWithCurrentRequestEventTest" />-->
+      <class name="org.jboss.cdi.tck.tests.context.conversation.event.notattached.DestroyConversationNotAssociatedWithCurrentRequestEventTest" />
     </classes>
   </test>
 </suite>