[
https://issues.apache.org/jira/browse/MYFACES-4047?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15292525#comment-15292525
]
Leonardo Uribe commented on MYFACES-4047:
-----------------------------------------
I have attached a patch (untested and only for the default viewscope
implementation, could be an error on the viewScopeId extraction), which shows a
possible solution. The idea is extract the viewScopeIds from the session scope
and then destroy each scope one by one. Also, invoke the managed bean destroyer
for each entry on the view scope map, so the algorithm can identify which
values are managed beans and which ones are not.
For CDI it should be something similar, the only different is in
ViewScopeBeanHolder there is a storage map with the viewScopeId as key. Maybe
the right location is add the code in
ViewScopeContextImpl.destroyAllActive(ViewScopeContextualStorage storage)
> @PreDestroy method not invokved on javax.faces.bean.ViewScoped beans on
> Session invalidation
> --------------------------------------------------------------------------------------------
>
> Key: MYFACES-4047
> URL: https://issues.apache.org/jira/browse/MYFACES-4047
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-344
> Affects Versions: 2.2.10
> Reporter: Paul Nicolucci
> Priority: Minor
> Attachments: MYFACES-4047-2-UNTESTED-ONLY-DEFAULT-VIEWSCOPE.patch,
> myfaces-4047.patch
>
>
> Consider the following scenario:
> Bean1:
> @Named
> @ViewScoped (javax.faces.view.ViewScoped)
> Bean2:
> @ManagedBean
> @ViewScoped (javax.faces.bean.ViewScoped)
> When the session is invalidated the
> org.apache.myfaces.cdi.impl.CDIManagedBeanHandlerImpl.onSessionDestroyed()
> method is invoked. Here, MyFaces destroys all of the
> javax.faces.view.ViewScoped @Named beans and @PreDestroy is invoked on these
> beans. However, the @ManagedBean /ViewScoped bean does not have its
> @PreDestroy invoked.
> I believe this is because the assumption was made that if an Application is
> CDI enabled it will contain all CDI @Named beans and not any @ManagedBeans.
> There is also the DefaultViewScopeHandler which is not yet implemented for
> "onSessionDestroyed" that would be used in the case when CDI is not enabled,
> that is when only @ManagedBeans are contained in the application.
> I believe it is possible to update the CDIManagedBeanHandlerImpl to be aware
> of the ViewScoped ManagedBeans and destroy them onSessionDestroy first by
> just getting the viewMap and iterating over the entries as we do when the
> PreDestroyViewMapEvent is processed.
> I'd like to use this issue to resolve the problem in
> CDIManagedBeanHandlerImpl as well as implement onSessionDestroy in
> DefaultViewScopeHandler.java
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)