myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Nicolucci" <pnico...@us.ibm.com>
Subject Re: CDIEnabled app does not invoke PreDestroy on javax.faces.bean.ViewScoped ManagedBeans
Date Wed, 18 May 2016 20:26:19 GMT

Thanks for the feedback Leonardo. I opened the following issue and provided
a potential fix: https://issues.apache.org/jira/browse/MYFACES-4047

I'd like a review and then I can commit the fix.

Thanks,

Paul Nicolucci




From:	Leonardo Uribe <lu4242@gmail.com>
To:	MyFaces Development <dev@myfaces.apache.org>
Date:	05/17/2016 03:31 PM
Subject:	Re: CDIEnabled app does not invoke PreDestroy on
            javax.faces.bean.ViewScoped ManagedBeans



Hi

It is not a common case, but it could be valid. It is not supposed to use
javax.faces.bean.ViewScoped on CDI enabled container because the idea was
to replace all managed beans with CDI beans. But cases like this one should
work.

+1 for create an issue for this one in the issue tracker.

regards,

Leonardo Uribe

2016-05-17 11:23 GMT-05:00 Paul Nicolucci <pnicoluc@us.ibm.com>:
  Hi,

  I've been reviewing a scenario the past couple of days. Consider the
  following:

  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 hear thoughts on this before I open a JIRA or provide a patch
  for both scenarios to ensure I'm not overlooking something here.

  Thanks,

  Paul Nicolucci







Mime
View raw message