You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2023/03/06 10:52:12 UTC

[myfaces] branch main updated: MYFACES-4578

This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/main by this push:
     new 6090f15d2 MYFACES-4578
6090f15d2 is described below

commit 6090f15d204901a9f920aae163d5d0d522f6de52
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Mon Mar 6 11:52:02 2023 +0100

    MYFACES-4578
---
 .../org/apache/myfaces/cdi/FacesScopeContext.java  |   2 +-
 .../ClientWindowScopeContextualStorageHolder.java  |  10 +-
 .../apache/myfaces/cdi/util/AbstractContext.java   | 189 ---------------------
 .../cdi/util/AbstractContextualStorageHolder.java  |  12 +-
 .../apache/myfaces/cdi/util/ContextualStorage.java |  11 +-
 .../apache/myfaces/cdi/view/ViewScopeCDIMap.java   |   5 +-
 .../apache/myfaces/cdi/view/ViewScopeContext.java  |   9 +-
 .../cdi/view/ViewScopeContextualStorage.java       |  38 -----
 .../cdi/view/ViewScopeContextualStorageHolder.java |  15 +-
 .../cdi/view/ViewTransientScopeContext.java        |   2 +-
 .../flow/cdi/FlowScopeContextualStorageHolder.java |  10 +-
 11 files changed, 58 insertions(+), 245 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/cdi/FacesScopeContext.java b/impl/src/main/java/org/apache/myfaces/cdi/FacesScopeContext.java
index a9762e41c..1111b2785 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/FacesScopeContext.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/FacesScopeContext.java
@@ -141,7 +141,7 @@ public class FacesScopeContext implements Context
         ContextualStorage storage = (ContextualStorage) facesContext.getAttributes().get(FACES_SCOPED_STORAGE);
         if (storage == null && createIfNotExist)
         {
-            storage = new ContextualStorage(beanManager, false);
+            storage = new ContextualStorage(beanManager, false, false);
             facesContext.getAttributes().put(FACES_SCOPED_STORAGE, storage);
         }
         return storage;
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/clientwindow/ClientWindowScopeContextualStorageHolder.java b/impl/src/main/java/org/apache/myfaces/cdi/clientwindow/ClientWindowScopeContextualStorageHolder.java
index d928c6572..c24513b15 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/clientwindow/ClientWindowScopeContextualStorageHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/clientwindow/ClientWindowScopeContextualStorageHolder.java
@@ -24,7 +24,9 @@ import jakarta.enterprise.context.spi.Contextual;
 import jakarta.enterprise.inject.Typed;
 import jakarta.faces.context.FacesContext;
 import jakarta.faces.lifecycle.ClientWindow;
+import jakarta.faces.lifecycle.ClientWindowScoped;
 import java.io.Serializable;
+import java.lang.annotation.Annotation;
 import java.util.Map;
 import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
 import org.apache.myfaces.cdi.util.ContextualStorage;
@@ -80,7 +82,7 @@ public class ClientWindowScopeContextualStorageHolder
     @Override
     protected ContextualStorage newContextualStorage(String slotId)
     {
-        return new ContextualStorage(beanManager, true);
+        return new ContextualStorage(beanManager, true, isPassivating());
     }
 
     public void pushClientWindow(FacesContext facesContext, ClientWindow clientWindow)
@@ -95,6 +97,12 @@ public class ClientWindowScopeContextualStorageHolder
         }
     }
 
+    @Override
+    public Class<? extends Annotation> getScope()
+    {
+        return ClientWindowScoped.class;
+    }
+    
     public static ClientWindowScopeContextualStorageHolder getInstance(FacesContext facesContext)
     {
         return getInstance(facesContext, false);
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/util/AbstractContext.java b/impl/src/main/java/org/apache/myfaces/cdi/util/AbstractContext.java
deleted file mode 100644
index 604acafd3..000000000
--- a/impl/src/main/java/org/apache/myfaces/cdi/util/AbstractContext.java
+++ /dev/null
@@ -1,189 +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.myfaces.cdi.util;
-
-import jakarta.enterprise.context.ContextNotActiveException;
-import jakarta.enterprise.context.spi.Context;
-import jakarta.enterprise.context.spi.Contextual;
-import jakarta.enterprise.context.spi.CreationalContext;
-import jakarta.enterprise.inject.spi.BeanManager;
-import jakarta.enterprise.inject.spi.PassivationCapable;
-import java.util.Map;
-
-/**
- * A skeleton containing the most important parts of a custom CDI Context.
- * An implementing Context needs to implement the missing methods from the
- * {@link Context} interface and {@link #getContextualStorage(boolean)}.
- * 
- * NOTE: Taken from Apache DeltaSpike
- */
-public abstract class AbstractContext implements Context
-{
-    /**
-     * Whether the Context is for a passivating scope.
-     */
-    private boolean passivatingScope;
-
-    protected AbstractContext(BeanManager beanManager)
-    {
-        passivatingScope = beanManager.isPassivatingScope(getScope());
-    }
-
-    /**
-     * An implementation has to return the underlying storage which
-     * contains the items held in the Context.
-     * @param createIfNotExist whether a ContextualStorage shall get created if it doesn't yet exist.
-     * @return the underlying storage
-     */
-    protected abstract ContextualStorage getContextualStorage(boolean createIfNotExist);
-
-    /**
-     * @return whether the served scope is a passivating scope
-     */
-    public boolean isPassivatingScope()
-    {
-        return passivatingScope;
-    }
-
-    @Override
-    public <T> T get(Contextual<T> bean)
-    {
-        checkActive();
-
-        ContextualStorage storage = getContextualStorage(false);
-        if (storage == null)
-        {
-            return null;
-        }
-
-        Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
-        ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
-        if (contextualInstanceInfo == null)
-        {
-            return null;
-        }
-
-        return (T) contextualInstanceInfo.getContextualInstance();
-    }
-
-    @Override
-    public <T> T get(Contextual<T> bean, CreationalContext<T> creationalContext)
-    {
-        checkActive();
-
-        if (passivatingScope)
-        {
-            if (!(bean instanceof PassivationCapable))
-            {
-                throw new IllegalStateException(bean.toString() +
-                        " doesn't implement " + PassivationCapable.class.getName());
-            }
-        }
-
-        ContextualStorage storage = getContextualStorage(true);
-
-        Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
-        ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
-
-        if (contextualInstanceInfo != null)
-        {
-            @SuppressWarnings("unchecked")
-            final T instance =  (T) contextualInstanceInfo.getContextualInstance();
-
-            if (instance != null)
-            {
-                return instance;
-            }
-        }
-
-        return storage.createContextualInstance(bean, creationalContext);
-    }
-
-    /**
-     * Destroy the Contextual Instance of the given Bean.
-     * @param bean dictates which bean shall get cleaned up
-     * @return <code>true</code> if the bean was destroyed, <code>false</code> if there was no such bean.
-     */
-    public boolean destroy(Contextual bean)
-    {
-        ContextualStorage storage = getContextualStorage(false);
-        if (storage == null)
-        {
-            return false;
-        }
-        ContextualInstanceInfo<?> contextualInstanceInfo = storage.getStorage().get(storage.getBeanKey(bean));
-
-        if (contextualInstanceInfo == null)
-        {
-            return false;
-        }
-
-        bean.destroy(contextualInstanceInfo.getContextualInstance(), contextualInstanceInfo.getCreationalContext());
-
-        return true;
-    }
-
-    /**
-     * destroys all the Contextual Instances in the Storage returned by
-     * {@link #getContextualStorage(boolean)}.
-     */
-    public void destroyAllActive()
-    {
-        ContextualStorage storage = getContextualStorage(false);
-        if (storage == null)
-        {
-            return;
-        }
-
-        destroyAllActive(storage);
-    }
-
-    /**
-     * Destroys all the Contextual Instances in the specified ContextualStorage.
-     * This is a static method to allow various holder objects to cleanup
-     * properly in &#064;PreDestroy.
-     */
-    public static void destroyAllActive(ContextualStorage storage)
-    {
-        Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
-        for (Map.Entry<Object, ContextualInstanceInfo<?>> entry : contextMap.entrySet())
-        {
-            Contextual bean = storage.getBean(entry.getKey());
-
-            ContextualInstanceInfo<?> contextualInstanceInfo = entry.getValue();
-            bean.destroy(contextualInstanceInfo.getContextualInstance(), contextualInstanceInfo.getCreationalContext());
-        }
-    }
-
-    /**
-     * Make sure that the Context is really active.
-     * @throws ContextNotActiveException if there is no active
-     *         Context for the current Thread.
-     */
-    protected void checkActive()
-    {
-        if (!isActive())
-        {
-            throw new ContextNotActiveException("CDI context with scope annotation @"
-                + getScope().getName() + " is not active with respect to the current thread");
-        }
-    }
-
-}
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/util/AbstractContextualStorageHolder.java b/impl/src/main/java/org/apache/myfaces/cdi/util/AbstractContextualStorageHolder.java
index fa677fb61..303df3d05 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/util/AbstractContextualStorageHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/util/AbstractContextualStorageHolder.java
@@ -28,6 +28,7 @@ import jakarta.faces.context.FacesContext;
 import jakarta.inject.Inject;
 import jakarta.servlet.ServletContext;
 import java.io.Serializable;
+import java.lang.annotation.Annotation;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import org.apache.myfaces.cdi.FacesApplicationArtifactHolder;
@@ -44,6 +45,8 @@ public abstract class AbstractContextualStorageHolder<T extends ContextualStorag
     protected BeanManager beanManager;
     
     protected Map<String, T> storageMap;
+    
+    protected boolean passivating;
 
     public AbstractContextualStorageHolder()
     {
@@ -53,7 +56,8 @@ public abstract class AbstractContextualStorageHolder<T extends ContextualStorag
     public void init()
     {
         storageMap = new ConcurrentHashMap<>();
-        
+        passivating = beanManager.isPassivatingScope(getScope());
+
         FacesContext facesContext = FacesContext.getCurrentInstance();
 
         Object context = facesContext.getExternalContext().getContext();
@@ -297,4 +301,10 @@ public abstract class AbstractContextualStorageHolder<T extends ContextualStorag
         return cached;
     }
 
+    public boolean isPassivating()
+    {
+        return passivating;
+    }
+
+    public abstract Class<? extends Annotation> getScope();
 }
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/util/ContextualStorage.java b/impl/src/main/java/org/apache/myfaces/cdi/util/ContextualStorage.java
index 6aac5e486..f1b5569e9 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/util/ContextualStorage.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/util/ContextualStorage.java
@@ -42,6 +42,7 @@ public class ContextualStorage implements Serializable
     protected Map<Object, ContextualInstanceInfo<?>> contextualInstances;
     protected BeanManager beanManager;
     protected boolean concurrent;
+    protected boolean passivating;
     protected transient volatile boolean activated;
 
     public ContextualStorage()
@@ -52,11 +53,13 @@ public class ContextualStorage implements Serializable
     /**
      * @param beanManager is needed for serialisation
      * @param concurrent whether the ContextualStorage might get accessed concurrently by different threads
+     * @param passivating whether the served scope is a passivating scope
      */
-    public ContextualStorage(BeanManager beanManager, boolean concurrent)
+    public ContextualStorage(BeanManager beanManager, boolean concurrent, boolean passivating)
     {
         this.beanManager = beanManager;
         this.concurrent = concurrent;
+        this.passivating = passivating;
         if (concurrent)
         {
             contextualInstances = new ConcurrentHashMap<>();
@@ -127,7 +130,7 @@ public class ContextualStorage implements Serializable
         else
         {
             // simply create the contextual instance
-            ContextualInstanceInfo<T> instanceInfo = new ContextualInstanceInfo<T>();
+            ContextualInstanceInfo<T> instanceInfo = new ContextualInstanceInfo<>();
             instanceInfo.setCreationalContext(creationalContext);
             instanceInfo.setContextualInstance(bean.create(creationalContext));
 
@@ -147,7 +150,7 @@ public class ContextualStorage implements Serializable
      */
     public <T> Object getBeanKey(Contextual<T> bean)
     {
-        if (bean instanceof PassivationCapable)
+        if (bean instanceof PassivationCapable && passivating)
         {
             // if the
             return ((PassivationCapable) bean).getId();
@@ -162,7 +165,7 @@ public class ContextualStorage implements Serializable
      */
     public Contextual<?> getBean(Object beanKey)
     {
-        if (beanKey instanceof String)
+        if (beanKey instanceof String && passivating)
         {
             // If the beanKey is a String, it was generated by PassivationCapable#getId().
             return beanManager.getPassivationCapableBean((String) beanKey);
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeCDIMap.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeCDIMap.java
index d7d37269f..af1275c3f 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeCDIMap.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeCDIMap.java
@@ -29,6 +29,7 @@ import jakarta.faces.context.FacesContext;
 import java.util.stream.Collectors;
 import org.apache.myfaces.cdi.util.CDIUtils;
 import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
+import org.apache.myfaces.cdi.util.ContextualStorage;
 
 /**
  *
@@ -37,14 +38,14 @@ import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
 public class ViewScopeCDIMap implements Map<String, Object>
 {
     private String viewScopeId;
-    private ViewScopeContextualStorage storage;
+    private ContextualStorage storage;
 
     public ViewScopeCDIMap(String viewScopeId)
     {
         this.viewScopeId = viewScopeId;
     }
     
-    private ViewScopeContextualStorage getStorage()
+    private ContextualStorage getStorage()
     {
         if (storage != null && !storage.isActivated())
         {
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContext.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContext.java
index ef828cd37..1608993de 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContext.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContext.java
@@ -32,6 +32,7 @@ import jakarta.faces.context.FacesContext;
 import jakarta.faces.view.ViewScoped;
 
 import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
+import org.apache.myfaces.cdi.util.ContextualStorage;
 import org.apache.myfaces.view.ViewScopeProxyMap;
 
 /**
@@ -79,7 +80,7 @@ public class ViewScopeContext implements Context
         return null;
     }
 
-    protected ViewScopeContextualStorage getContextualStorage(FacesContext facesContext, boolean createIfNotExist)
+    protected ContextualStorage getContextualStorage(FacesContext facesContext, boolean createIfNotExist)
     {
         String viewScopeId = getCurrentViewScopeId(createIfNotExist);
         if (createIfNotExist && viewScopeId == null)
@@ -126,7 +127,7 @@ public class ViewScopeContext implements Context
         // force session creation if ViewScoped is used
         facesContext.getExternalContext().getSession(true);
         
-        ViewScopeContextualStorage storage = getContextualStorage(facesContext, false);
+        ContextualStorage storage = getContextualStorage(facesContext, false);
         if (storage == null)
         {
             return null;
@@ -158,7 +159,7 @@ public class ViewScopeContext implements Context
         // force session creation if ViewScoped is used
         facesContext.getExternalContext().getSession(true);
         
-        ViewScopeContextualStorage storage = getContextualStorage(facesContext, true);
+        ContextualStorage storage = getContextualStorage(facesContext, true);
 
         Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
         ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
@@ -187,7 +188,7 @@ public class ViewScopeContext implements Context
 
     public boolean destroy(Contextual bean)
     {
-        ViewScopeContextualStorage storage = getContextualStorage(FacesContext.getCurrentInstance(), false);
+        ContextualStorage storage = getContextualStorage(FacesContext.getCurrentInstance(), false);
         if (storage == null)
         {
             return false;
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorage.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorage.java
deleted file mode 100644
index 3de20f1a8..000000000
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorage.java
+++ /dev/null
@@ -1,38 +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.myfaces.cdi.view;
-
-import jakarta.enterprise.inject.spi.BeanManager;
-import org.apache.myfaces.cdi.util.ContextualStorage;
-
-/**
- * This Storage holds all information needed for storing
- * View Scope instances in a context.
- * 
- * This scope requires passivation and is not concurrent.
- */
-public class ViewScopeContextualStorage extends ContextualStorage
-{
-    private static final long serialVersionUID = 1L;
-    
-    public ViewScopeContextualStorage(BeanManager beanManager)
-    {
-        super(beanManager, false);
-    }
-}
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorageHolder.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorageHolder.java
index 1a4ad780f..b8dde7320 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorageHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextualStorageHolder.java
@@ -23,7 +23,10 @@ import java.util.Random;
 import jakarta.enterprise.context.SessionScoped;
 import jakarta.enterprise.inject.Typed;
 import jakarta.faces.context.FacesContext;
+import jakarta.faces.view.ViewScoped;
+import java.lang.annotation.Annotation;
 import org.apache.myfaces.cdi.util.AbstractContextualStorageHolder;
+import org.apache.myfaces.cdi.util.ContextualStorage;
 
 /**
  *
@@ -32,7 +35,7 @@ import org.apache.myfaces.cdi.util.AbstractContextualStorageHolder;
 @Typed(ViewScopeContextualStorageHolder.class)
 @SessionScoped
 public class ViewScopeContextualStorageHolder
-        extends AbstractContextualStorageHolder<ViewScopeContextualStorage>
+        extends AbstractContextualStorageHolder<ContextualStorage>
         implements Serializable
 {    
     private static final Random RANDOM_GENERATOR = new Random();
@@ -54,9 +57,9 @@ public class ViewScopeContextualStorageHolder
     }
 
     @Override
-    protected ViewScopeContextualStorage newContextualStorage(String slotId)
+    protected ContextualStorage newContextualStorage(String slotId)
     {
-        return new ViewScopeContextualStorage(beanManager);
+        return new ContextualStorage(beanManager, false, isPassivating());
     }
 
     protected static ViewScopeContextualStorageHolder getInstance(FacesContext facesContext)
@@ -68,4 +71,10 @@ public class ViewScopeContextualStorageHolder
     {
         return getInstance(facesContext, ViewScopeContextualStorageHolder.class, create);
     }
+
+    @Override
+    public Class<? extends Annotation> getScope()
+    {
+        return ViewScoped.class;
+    }
 }
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewTransientScopeContext.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewTransientScopeContext.java
index 9ba9b34ff..b4ee8814f 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewTransientScopeContext.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewTransientScopeContext.java
@@ -139,7 +139,7 @@ public class ViewTransientScopeContext implements Context
                 facesContext.getViewRoot().getTransientStateHelper().getTransient(VIEW_TRANSIENT_SCOPED_STORAGE);
         if (contextualStorage == null && createIfNotExist)
         {
-            contextualStorage = new ContextualStorage(beanManager, false);
+            contextualStorage = new ContextualStorage(beanManager, false, false);
             facesContext.getViewRoot().getTransientStateHelper()
                     .putTransient(VIEW_TRANSIENT_SCOPED_STORAGE, contextualStorage);
         }
diff --git a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeContextualStorageHolder.java b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeContextualStorageHolder.java
index dfc1ebfe1..96864d833 100644
--- a/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeContextualStorageHolder.java
+++ b/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeContextualStorageHolder.java
@@ -38,6 +38,7 @@ import jakarta.faces.flow.FlowHandler;
 import jakarta.faces.flow.FlowScoped;
 import jakarta.faces.lifecycle.ClientWindow;
 import jakarta.inject.Inject;
+import java.lang.annotation.Annotation;
 import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
 import org.apache.myfaces.cdi.util.ContextualStorage;
 import org.apache.myfaces.config.webparameters.MyfacesConfig;
@@ -223,9 +224,15 @@ public class FlowScopeContextualStorageHolder
     @Override
     protected ContextualStorage newContextualStorage(String slotId)
     {
-        return new ContextualStorage(beanManager, true);
+        return new ContextualStorage(beanManager, true, isPassivating());
     }
 
+    @Override
+    public Class<? extends Annotation> getScope()
+    {
+        return FlowScoped.class;
+    }
+    
     public static FlowScopeContextualStorageHolder getInstance(FacesContext facesContext)
     {
         return getInstance(facesContext, false);
@@ -235,4 +242,5 @@ public class FlowScopeContextualStorageHolder
     {
         return getInstance(facesContext, FlowScopeContextualStorageHolder.class, create);
     }
+
 }