deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject git commit: DELTASPIKE-487 accessedBeans can be RequestScoped
Date Sun, 02 Mar 2014 20:58:53 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master d44ed2af5 -> f050f5520


DELTASPIKE-487 accessedBeans can be RequestScoped

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

Branch: refs/heads/master
Commit: f050f55208882124beb0415a719f34b839d38678
Parents: d44ed2a
Author: tandraschko <tandraschko@apache.org>
Authored: Sun Mar 2 21:58:39 2014 +0100
Committer: tandraschko <tandraschko@apache.org>
Committed: Sun Mar 2 21:58:39 2014 +0100

----------------------------------------------------------------------
 .../impl/scope/DeltaSpikeContextExtension.java  | 17 ++++---
 .../viewaccess/ViewAccessBeanAccessHistory.java | 34 ++++++++++++++
 .../scope/viewaccess/ViewAccessBeanHolder.java  | 28 +++++++++++
 .../scope/viewaccess/ViewAccessContext.java     | 31 +++++++------
 .../viewaccess/ViewAccessScopedBeanHistory.java | 49 --------------------
 .../viewaccess/ViewAccessScopedBeanHolder.java  | 28 -----------
 .../scope/viewaccess/ViewAccessViewHistory.java | 40 ++++++++++++++++
 7 files changed, 129 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f050f552/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/DeltaSpikeContextExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/DeltaSpikeContextExtension.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/DeltaSpikeContextExtension.java
index bf64c14..e5ab315 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/DeltaSpikeContextExtension.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/DeltaSpikeContextExtension.java
@@ -28,9 +28,10 @@ import javax.enterprise.inject.spi.Extension;
 import org.apache.deltaspike.core.api.provider.BeanProvider;
 import org.apache.deltaspike.core.impl.scope.conversation.ConversationBeanHolder;
 import org.apache.deltaspike.core.impl.scope.conversation.GroupedConversationContext;
-import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessScopedBeanHistory;
-import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessScopedBeanHolder;
+import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessBeanAccessHistory;
+import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessBeanHolder;
 import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessContext;
+import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessViewHistory;
 import org.apache.deltaspike.core.impl.scope.window.WindowBeanHolder;
 import org.apache.deltaspike.core.impl.scope.window.WindowContextImpl;
 import org.apache.deltaspike.core.impl.scope.window.WindowIdHolder;
@@ -93,11 +94,13 @@ public class DeltaSpikeContextExtension implements Extension, Deactivatable
             BeanProvider.getContextualReference(beanManager, ConversationBeanHolder.class,
false);
         conversationContext.init(conversationBeanHolder);
         
-        ViewAccessScopedBeanHolder viewAccessScopedBeanHolder =
-            BeanProvider.getContextualReference(beanManager, ViewAccessScopedBeanHolder.class,
false);
-        ViewAccessScopedBeanHistory viewAccessScopedBeanHistory =
-            BeanProvider.getContextualReference(beanManager, ViewAccessScopedBeanHistory.class,
false);
-        viewAccessScopedContext.init(viewAccessScopedBeanHolder, viewAccessScopedBeanHistory);
+        ViewAccessBeanHolder viewAccessBeanHolder =
+            BeanProvider.getContextualReference(beanManager, ViewAccessBeanHolder.class,
false);
+        ViewAccessBeanAccessHistory viewAccessBeanAccessHistory =
+            BeanProvider.getContextualReference(beanManager, ViewAccessBeanAccessHistory.class,
false);
+        ViewAccessViewHistory viewAccessViewHistory =
+            BeanProvider.getContextualReference(beanManager, ViewAccessViewHistory.class,
false);
+        viewAccessScopedContext.init(viewAccessBeanHolder, viewAccessBeanAccessHistory, viewAccessViewHistory);
     }
 
     public WindowContextImpl getWindowContext()

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f050f552/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessBeanAccessHistory.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessBeanAccessHistory.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessBeanAccessHistory.java
new file mode 100644
index 0000000..acc9645
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessBeanAccessHistory.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.core.impl.scope.viewaccess;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.enterprise.context.RequestScoped;
+
+@RequestScoped
+public class ViewAccessBeanAccessHistory
+{    
+    private final List<String> accessedBeans = new ArrayList<String>();
+
+    public List<String> getAccessedBeans()
+    {
+        return accessedBeans;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f050f552/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessBeanHolder.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessBeanHolder.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessBeanHolder.java
new file mode 100644
index 0000000..6559745
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessBeanHolder.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.core.impl.scope.viewaccess;
+
+import org.apache.deltaspike.core.api.scope.WindowScoped;
+import org.apache.deltaspike.core.impl.scope.AbstractBeanHolder;
+
+@WindowScoped
+public class ViewAccessBeanHolder extends AbstractBeanHolder<String>
+{
+    private static final long serialVersionUID = 6313403410718143908L;
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f050f552/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 3b358ea..9266dd2 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
@@ -37,8 +37,9 @@ public class ViewAccessContext extends AbstractContext
     private final BeanManager beanManager;
     private final WindowContextImpl windowContext;
 
-    private ViewAccessScopedBeanHolder viewAccessScopedBeanHolder;
-    private ViewAccessScopedBeanHistory viewAccessScopedBeanHistory;
+    private ViewAccessBeanHolder viewAccessBeanHolder;
+    private ViewAccessBeanAccessHistory viewAccessBeanAccessHistory;
+    private ViewAccessViewHistory viewAccessViewHistory;
     
     public ViewAccessContext(BeanManager beanManager, WindowContextImpl windowContext)
     {
@@ -48,11 +49,13 @@ public class ViewAccessContext extends AbstractContext
         this.windowContext = windowContext;
     }
 
-    public void init(ViewAccessScopedBeanHolder viewAccessScopedBeanHolder,
-            ViewAccessScopedBeanHistory viewAccessScopedBeanHistory)
+    public void init(ViewAccessBeanHolder viewAccessBeanHolder,
+            ViewAccessBeanAccessHistory viewAccessBeanAccessHistory,
+            ViewAccessViewHistory viewAccessViewHistory)
     {
-        this.viewAccessScopedBeanHolder = viewAccessScopedBeanHolder;
-        this.viewAccessScopedBeanHistory = viewAccessScopedBeanHistory;
+        this.viewAccessBeanHolder = viewAccessBeanHolder;
+        this.viewAccessBeanAccessHistory = viewAccessBeanAccessHistory;
+        this.viewAccessViewHistory = viewAccessViewHistory;
     }
 
     @Override
@@ -67,7 +70,7 @@ public class ViewAccessContext extends AbstractContext
             if (bean instanceof PassivationCapable)
             {
                 PassivationCapable pc = (PassivationCapable) bean;
-                viewAccessScopedBeanHistory.getAccessedBeans().add(pc.getId());
+                viewAccessBeanAccessHistory.getAccessedBeans().add(pc.getId());
             }
         }
     }
@@ -84,7 +87,7 @@ public class ViewAccessContext extends AbstractContext
             if (bean instanceof PassivationCapable)
             {
                 PassivationCapable pc = (PassivationCapable) bean;
-                viewAccessScopedBeanHistory.getAccessedBeans().add(pc.getId());
+                viewAccessBeanAccessHistory.getAccessedBeans().add(pc.getId());
             }
         }
     }
@@ -92,7 +95,7 @@ public class ViewAccessContext extends AbstractContext
     @Override
     protected ContextualStorage getContextualStorage(Contextual<?> contextual, boolean
createIfNotExist)
     {
-        return this.viewAccessScopedBeanHolder.getContextualStorage(this.beanManager, KEY,
createIfNotExist);
+        return this.viewAccessBeanHolder.getContextualStorage(this.beanManager, KEY, createIfNotExist);
     }
 
     @Override
@@ -110,25 +113,25 @@ public class ViewAccessContext extends AbstractContext
     public void onProcessingViewFinished(String view)
     {
         // destroy beans only if the view has been changed
-        if (!view.equals(viewAccessScopedBeanHistory.getLastView()))
+        if (!view.equals(viewAccessViewHistory.getLastView()))
         {
-            viewAccessScopedBeanHistory.setLastView(view);
+            viewAccessViewHistory.setLastView(view);
             
             destroyExpiredBeans();
         }
         
         // clear history after each rendering process
-        viewAccessScopedBeanHistory.getAccessedBeans().clear();
+        viewAccessBeanAccessHistory.getAccessedBeans().clear();
     }
     
     private void destroyExpiredBeans()
     {
-        ContextualStorage storage = viewAccessScopedBeanHolder.getContextualStorage(beanManager,
KEY, false);
+        ContextualStorage storage = viewAccessBeanHolder.getContextualStorage(beanManager,
KEY, false);
         if (storage != null)
         {
             for (Map.Entry<Object, ContextualInstanceInfo<?>> storageEntry :
storage.getStorage().entrySet())
             {
-                if (!viewAccessScopedBeanHistory.getAccessedBeans().contains((String) storageEntry.getKey()))
+                if (!viewAccessBeanAccessHistory.getAccessedBeans().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/f050f552/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
deleted file mode 100644
index 390688b..0000000
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessScopedBeanHistory.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.deltaspike.core.impl.scope.viewaccess;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.deltaspike.core.api.scope.WindowScoped;
-
-@WindowScoped
-public class ViewAccessScopedBeanHistory implements Serializable
-{
-    private static final long serialVersionUID = 3617603930728148927L;
-    
-    private List<String> accessedBeans = new ArrayList<String>();
-    private String lastView;
-
-    public List<String> getAccessedBeans()
-    {
-        return accessedBeans;
-    }
-
-    public String getLastView()
-    {
-        return lastView;
-    }
-
-    public void setLastView(String lastView)
-    {
-        this.lastView = lastView;
-    }
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f050f552/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessScopedBeanHolder.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessScopedBeanHolder.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessScopedBeanHolder.java
deleted file mode 100644
index 87279df..0000000
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessScopedBeanHolder.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.deltaspike.core.impl.scope.viewaccess;
-
-import org.apache.deltaspike.core.api.scope.WindowScoped;
-import org.apache.deltaspike.core.impl.scope.AbstractBeanHolder;
-
-@WindowScoped
-public class ViewAccessScopedBeanHolder extends AbstractBeanHolder<String>
-{
-    private static final long serialVersionUID = 6313403410718143908L;
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f050f552/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessViewHistory.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessViewHistory.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessViewHistory.java
new file mode 100644
index 0000000..5d8ff05
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessViewHistory.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.core.impl.scope.viewaccess;
+
+import java.io.Serializable;
+import org.apache.deltaspike.core.api.scope.WindowScoped;
+
+@WindowScoped
+public class ViewAccessViewHistory implements Serializable
+{
+    private static final long serialVersionUID = 8917607910721148527L;
+    
+    private String lastView;
+
+    public String getLastView()
+    {
+        return lastView;
+    }
+
+    public void setLastView(String lastView)
+    {
+        this.lastView = lastView;
+    }
+}


Mime
View raw message