deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [2/2] git commit: DELTASPIKE-487 removed unused logic
Date Thu, 27 Feb 2014 22:37:33 GMT
DELTASPIKE-487 removed unused logic

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

Branch: refs/heads/master
Commit: 4ff33b15b056f76354d8b06ed05f9795094d2f1e
Parents: 8d23e10
Author: tandraschko <tandraschko@apache.org>
Authored: Thu Feb 27 23:37:20 2014 +0100
Committer: tandraschko <tandraschko@apache.org>
Committed: Thu Feb 27 23:37:20 2014 +0100

----------------------------------------------------------------------
 .../impl/scope/viewaccess/ViewAccessContext.java     | 15 +++++++++++++--
 .../viewaccess/ViewAccessScopedBeanHistory.java      | 12 ++++++++++++
 .../listener/request/DeltaSpikeLifecycleWrapper.java |  2 +-
 3 files changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4ff33b15/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessContext.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessContext.java
index 701e4d0..ba6d90c 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessContext.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessContext.java
@@ -19,6 +19,8 @@
 package org.apache.deltaspike.core.impl.scope.viewaccess;
 
 import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 import javax.enterprise.context.ContextNotActiveException;
 import javax.enterprise.context.spi.Contextual;
@@ -113,19 +115,28 @@ public class ViewAccessContext extends AbstractContext
             destroyExpiredBeans();
             
             // clear list from last request
-            viewAccessScopedBeanHistory.getAccessedBeans().clear();
+            List<String> lastAccessedBeans = viewAccessScopedBeanHistory.getLastAccessedBeans();
+            lastAccessedBeans.clear();
+            
+            // move used beans from this request to last request
+            viewAccessScopedBeanHistory.setLastAccessedBeans(viewAccessScopedBeanHistory.getAccessedBeans());
+            viewAccessScopedBeanHistory.setAccessedBeans(lastAccessedBeans);
         }
     }
     
     private void destroyExpiredBeans()
     {
+        List<String> usedBeans = new ArrayList<String>();
+        usedBeans.addAll(viewAccessScopedBeanHistory.getAccessedBeans());
+        usedBeans.addAll(viewAccessScopedBeanHistory.getLastAccessedBeans());
+
         ContextualStorage storage =
                 viewAccessScopedBeanHolder.getContextualStorage(beanManager, getCurrentWindowId(),
false);
         if (storage != null)
         {
             for (Map.Entry<Object, ContextualInstanceInfo<?>> storageEntry :
storage.getStorage().entrySet())
             {
-                if (!viewAccessScopedBeanHistory.getAccessedBeans().contains((String) storageEntry.getKey()))
+                if (!usedBeans.contains((String) storageEntry.getKey()))
                 {
                     Contextual bean = storage.getBean(storageEntry.getKey());
                     AbstractContext.destroyBean(bean, storageEntry.getValue());

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4ff33b15/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessScopedBeanHistory.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessScopedBeanHistory.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessScopedBeanHistory.java
index 06ddbe9..b422f07 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessScopedBeanHistory.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessScopedBeanHistory.java
@@ -30,11 +30,13 @@ public class ViewAccessScopedBeanHistory implements Serializable
     private static final long serialVersionUID = 3617603930728148927L;
     
     private List<String> accessedBeans;
+    private List<String> lastAccessedBeans;
     private String lastView;
 
     public ViewAccessScopedBeanHistory()
     {
         accessedBeans = new ArrayList<String>();
+        lastAccessedBeans = new ArrayList<String>();
     }
     
     public List<String> getAccessedBeans()
@@ -47,6 +49,16 @@ public class ViewAccessScopedBeanHistory implements Serializable
         this.accessedBeans = accessedBeans;
     }
 
+    public List<String> getLastAccessedBeans()
+    {
+        return lastAccessedBeans;
+    }
+
+    public void setLastAccessedBeans(List<String> lastAccessedBeans)
+    {
+        this.lastAccessedBeans = lastAccessedBeans;
+    }
+
     public String getLastView()
     {
         return lastView;

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4ff33b15/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
index ef8ef57..7e610f1 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
@@ -110,7 +110,7 @@ class DeltaSpikeLifecycleWrapper extends Lifecycle
     {
         this.wrapped.render(facesContext);
         
-        if (facesContext.getViewRoot() != null)
+        if (!facesContext.isPostback() && facesContext.getViewRoot() != null)
         {
             ViewAccessContext viewAccessContext = contextExtension.getViewAccessScopedContext();
             if (viewAccessContext != null)


Mime
View raw message