openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1678176 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation: ConversationManager.java ConversationStorageBean.java
Date Thu, 07 May 2015 12:19:50 GMT
Author: struberg
Date: Thu May  7 12:19:50 2015
New Revision: 1678176

URL: http://svn.apache.org/r1678176
Log:
OWB-1050 implement Serializable for internal conversation contexts bean

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationStorageBean.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java?rev=1678176&r1=1678175&r2=1678176&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java
Thu May  7 12:19:50 2015
@@ -56,6 +56,7 @@ public class ConversationManager
 
 
     private final WebBeansContext webBeansContext;
+    private final ConversationStorageBean conversationStorageBean;
 
     /**
      * Creates new conversation manager
@@ -64,8 +65,8 @@ public class ConversationManager
     {
         this.webBeansContext = webBeansContext;
 
-        // we need to register this for serialisation in clusters
-        webBeansContext.getBeanManagerImpl().addInternalBean(ConversationStorageBean.INSTANCE);
+        conversationStorageBean = new ConversationStorageBean(webBeansContext);
+        webBeansContext.getBeanManagerImpl().addInternalBean(conversationStorageBean);
     }
 
 
@@ -223,14 +224,14 @@ public class ConversationManager
         {
             if (!create)
             {
-                conversationContexts = sessionContext.get(ConversationStorageBean.INSTANCE);
+                conversationContexts = sessionContext.get(conversationStorageBean);
             }
             else
             {
                 CreationalContextImpl<Set<ConversationContext>> creationalContext
-                        = webBeansContext.getBeanManagerImpl().createCreationalContext(ConversationStorageBean.INSTANCE);
+                        = webBeansContext.getBeanManagerImpl().createCreationalContext(conversationStorageBean);
 
-                conversationContexts = sessionContext.get(ConversationStorageBean.INSTANCE,
creationalContext);
+                conversationContexts = sessionContext.get(conversationStorageBean, creationalContext);
             }
         }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationStorageBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationStorageBean.java?rev=1678176&r1=1678175&r2=1678176&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationStorageBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationStorageBean.java
Thu May  7 12:19:50 2015
@@ -24,6 +24,7 @@ import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.PassivationCapable;
 
+import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.util.Collections;
@@ -34,12 +35,24 @@ import java.util.concurrent.ConcurrentHa
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.ConversationContext;
 
+
 /**
  * Bean used to create the map of conversations in a session
  */
-public class ConversationStorageBean implements Bean<Set<ConversationContext>>,
PassivationCapable
+public class ConversationStorageBean implements Bean<Set<ConversationContext>>,
PassivationCapable, Serializable
 {
-    public static final ConversationStorageBean INSTANCE = new ConversationStorageBean();
+    private static final String OWB_INTERNAL_CONVERSATION_STORAGE_BEAN_PASSIVATION_ID = "OwbInternalConversationStorageBean";
+    private final transient WebBeansContext webBeansContext;
+
+    public ConversationStorageBean()
+    {
+        webBeansContext = WebBeansContext.currentInstance();
+    }
+
+    public ConversationStorageBean(WebBeansContext webBeansContext)
+    {
+        this.webBeansContext = webBeansContext;
+    }
 
     @Override
     public Set<ConversationContext> create(CreationalContext<Set<ConversationContext>>
creationalContext)
@@ -55,7 +68,7 @@ public class ConversationStorageBean imp
             return;
         }
 
-        ConversationManager conversationManager = WebBeansContext.currentInstance().getConversationManager();
+        ConversationManager conversationManager = webBeansContext.getConversationManager();
         for (ConversationContext conversationContext : instance)
         {
             conversationManager.destroyConversationContext(conversationContext);
@@ -119,6 +132,29 @@ public class ConversationStorageBean imp
     @Override
     public String getId()
     {
-        return "OwbInternalConversationStorageBean";
+        return OWB_INTERNAL_CONVERSATION_STORAGE_BEAN_PASSIVATION_ID;
+    }
+
+    @Override
+    public boolean equals(Object o)
+    {
+        if (this == o)
+        {
+            return true;
+        }
+
+        if (o == null || getClass() != o.getClass())
+        {
+            return false;
+        }
+        ConversationStorageBean that = (ConversationStorageBean) o;
+
+        return getId().equals(that.getId());
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return getId().hashCode();
     }
 }



Mime
View raw message