myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r982833 - in /myfaces/extensions/cdi/trunk: core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/spi/ jee-modules/jsf-mo...
Date Thu, 05 Aug 2010 23:51:27 GMT
Author: gpetracek
Date: Thu Aug  5 23:51:26 2010
New Revision: 982833

URL: http://svn.apache.org/viewvc?rev=982833&view=rev
Log:
refactored Conversation#end

Modified:
    myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowContext.java
    myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/spi/EditableConversation.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversation.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultWindowContextManager.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/JsfUtils.java

Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowContext.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowContext.java?rev=982833&r1=982832&r2=982833&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowContext.java
(original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowContext.java
Thu Aug  5 23:51:26 2010
@@ -51,15 +51,19 @@ public interface WindowContext extends A
     Set<Conversation> endConversationGroup(Class conversationGroup);
 
     /**
-     * TODO add: endContext to reset the window scope
      * invalidate all conversations immediately
      * attention: window scoped beans won't get destroyed.
-     * currently there is no api for it.
-     * (if it is needed you have to call {@link #endConversation} in combination with the
{@link WindowScoped})
+     * if you would like to reset the whole context including window scoped beans, use {@link
#end} or
+     * {@link #endConversation} + WindowScoped.class as argument
      */
     void endConversations();
 
     /**
+     * invalidate the whole {@link org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowContext}
+     */
+    void end();
+
+    /**
      * @return configuration of the current context
      */
     WindowContextConfig getConfig();

Modified: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/spi/EditableConversation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/spi/EditableConversation.java?rev=982833&r1=982832&r2=982833&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/spi/EditableConversation.java
(original)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/spi/EditableConversation.java
Thu Aug  5 23:51:26 2010
@@ -18,11 +18,13 @@
  */
 package org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi;
 
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.Conversation;
+
 /**
  * TODO
  * @author Gerhard Petracek
  */
-public interface EditableConversation
+public interface EditableConversation extends Conversation
 {
     /**
      * @return evaluates and returns if the conversation is active
@@ -39,11 +41,6 @@ public interface EditableConversation
      */
     void deactivate();
 
-    /**
-     * deactivates a conversation in any case (independent of the expiration mechanism)
-     */
-    void forceEnd();
-
     <T> void addBean(BeanEntry<T> beanInstance);
 
     /**

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversation.java?rev=982833&r1=982832&r2=982833&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversation.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversation.java
Thu Aug  5 23:51:26 2010
@@ -18,7 +18,6 @@
  */
 package org.apache.myfaces.extensions.cdi.javaee.jsf.impl.scope.conversation;
 
-import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.Conversation;
 import org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.BeanEntry;
 import org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.EditableConversation;
 import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.scope.conversation.spi.ConversationKey;
@@ -31,7 +30,7 @@ import java.io.Serializable;
  * @author Gerhard Petracek
  */
 @Typed()
-public class DefaultConversation implements Conversation, EditableConversation
+public class DefaultConversation implements EditableConversation
 {
     private static final long serialVersionUID = -2958548175169003298L;
 
@@ -72,12 +71,6 @@ public class DefaultConversation impleme
         }
     }
 
-    public void forceEnd()
-    {
-        this.active = false;
-        end();
-    }
-
     public void end()
     {
         if(this.active)

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultWindowContextManager.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultWindowContextManager.java?rev=982833&r1=982832&r2=982833&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultWindowContextManager.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultWindowContextManager.java
Thu Aug  5 23:51:26 2010
@@ -96,15 +96,7 @@ public class DefaultWindowContextManager
             for (Conversation conversation :
                     ((EditableWindowContext)windowContext).getConversations().values())
             {
-                //TODO
-                if(conversation instanceof EditableConversation)
-                {
-                    ((EditableConversation)conversation).forceEnd();
-                }
-                else
-                {
-                    conversation.end();
-                }
+                conversation.end();
             }
 
             //TODO

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.java?rev=982833&r1=982832&r2=982833&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.java
Thu Aug  5 23:51:26 2010
@@ -30,6 +30,7 @@ import org.apache.myfaces.extensions.cdi
 import static org.apache.myfaces.extensions.cdi.javaee.jsf.impl.scope.conversation
         .JsfAwareConversationFactory.ConversationPropertyKeys.TIMEOUT;
 import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.RequestCache;
+import org.apache.myfaces.extensions.cdi.javaee.jsf.impl.util.JsfUtils;
 
 import javax.enterprise.inject.Typed;
 import java.util.Collections;
@@ -70,12 +71,24 @@ public class JsfWindowContext implements
         return this.id;
     }
 
-    public synchronized void endConversations()
+    public void endConversations()
+    {
+        endConversations(false);
+    }
+
+    public void end()
+    {
+        endConversations(true);
+        this.attributes.clear();
+    }
+
+    public synchronized void endConversations(boolean forceEnd)
     {
         for (Map.Entry<ConversationKey, Conversation> conversationEntry : this.groupedConversations.entrySet())
         {
-            endAndRemoveConversation(conversationEntry.getKey(), conversationEntry.getValue());
+            endAndRemoveConversation(conversationEntry.getKey(), conversationEntry.getValue(),
forceEnd);
         }
+        JsfUtils.resetConversationCache();
     }
 
     public Conversation getConversation(Class conversationGroupKey, Annotation... qualifiers)
@@ -91,7 +104,7 @@ public class JsfWindowContext implements
             //TODO
             if (conversation != null && !((EditableConversation)conversation).isActive())
             {
-                endAndRemoveConversation(conversationKey, conversation);
+                endAndRemoveConversation(conversationKey, conversation, true);
                 conversation = null;
             }
 
@@ -111,7 +124,7 @@ public class JsfWindowContext implements
         ConversationKey conversationKey = new DefaultConversationKey(conversationGroupKey,
qualifiers);
 
         Conversation conversation = this.groupedConversations.get(conversationKey);
-        return endAndRemoveConversation(conversationKey, conversation);
+        return endAndRemoveConversation(conversationKey, conversation, true);
     }
 
     public Set<Conversation> endConversationGroup(Class conversationGroupKey)
@@ -122,21 +135,33 @@ public class JsfWindowContext implements
             if(conversationGroupKey.isAssignableFrom(conversationEntry.getKey().getConversationGroup()))
             {
                 removedConversations.add(
-                        endAndRemoveConversation(conversationEntry.getKey(), conversationEntry.getValue()));
+                        endAndRemoveConversation(conversationEntry.getKey(), conversationEntry.getValue(),
true));
             }
         }
         return removedConversations;
     }
 
-    private Conversation endAndRemoveConversation(ConversationKey conversationKey, Conversation
conversation)
+    private Conversation endAndRemoveConversation(ConversationKey conversationKey,
+                                                  Conversation conversation,
+                                                  boolean forceEnd)
     {
-        //TODO
-        if (((EditableConversation)conversation).isActive())
+        if (forceEnd)
         {
             conversation.end();
+            return this.groupedConversations.remove(conversationKey);
+        }
+        else if(conversation instanceof EditableConversation)
+        {
+            ((EditableConversation)conversation).deactivate();
+
+            if(!((EditableConversation)conversation).isActive())
+            {
+                conversation.end();
+                return this.groupedConversations.remove(conversationKey);
+            }
         }
 
-        return this.groupedConversations.remove(conversationKey);
+        return null;
     }
 
     public Conversation createConversation(Class conversationGroupKey, Annotation... qualifiers)

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/JsfUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/JsfUtils.java?rev=982833&r1=982832&r2=982833&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/JsfUtils.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/JsfUtils.java
Thu Aug  5 23:51:26 2010
@@ -37,6 +37,11 @@ import java.util.Locale;
  */
 public class JsfUtils
 {
+    public static void resetConversationCache()
+    {
+        RequestCache.resetConversationCache();
+    }
+
     public static void resetCaches()
     {
         RequestCache.resetCache();



Mime
View raw message