You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2014/12/13 00:53:08 UTC
svn commit: r1645097 -
/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
Author: lu4242
Date: Fri Dec 12 23:53:07 2014
New Revision: 1645097
URL: http://svn.apache.org/r1645097
Log:
MYFACES-3940 FlowScopeBeanHolder calls ApplicationContextBean on PreDestroy
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java?rev=1645097&r1=1645096&r2=1645097&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java Fri Dec 12 23:53:07 2014
@@ -25,6 +25,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.context.SessionScoped;
@@ -211,12 +213,26 @@ public class FlowScopeBeanHolder impleme
if (!oldWindowContextStorages.isEmpty())
{
FacesContext facesContext = FacesContext.getCurrentInstance();
+ ServletContext servletContext = null;
+ if (facesContext == null)
+ {
+ try
+ {
+ servletContext = applicationContextBean.getServletContext();
+ }
+ catch (Throwable e)
+ {
+ Logger.getLogger(FlowScopeBeanHolder.class.getName()).log(Level.WARNING,
+ "Cannot locate servletContext to create FacesContext on @PreDestroy flow scope beans. "
+ + "The beans will be destroyed without active FacesContext instance.");
+ servletContext = null;
+ }
+ }
if (facesContext == null &&
- applicationContextBean.getServletContext() != null)
+ servletContext != null)
{
try
{
- ServletContext servletContext = applicationContextBean.getServletContext();
ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext, false);
ExceptionHandler exceptionHandler = new ExceptionHandlerImpl();
facesContext = new StartupFacesContextImpl(externalContext,