You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ja...@apache.org on 2010/09/16 14:50:42 UTC
svn commit: r997728 - in
/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces: config/ webapp/
Author: jakobk
Date: Thu Sep 16 12:50:41 2010
New Revision: 997728
URL: http://svn.apache.org/viewvc?rev=997728&view=rev
Log:
MYFACES-2919 LifecycleProvider Based Problems and Tomcat7 LifeCycleProvider Support (refactored ManagedBeanDestroyer(-Listener) configuration)
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ManagedBeanDestroyer.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/ManagedBeanDestroyerListener.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=997728&r1=997727&r2=997728&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java Thu Sep 16 12:50:41 2010
@@ -80,6 +80,8 @@ import org.apache.myfaces.application.Ap
import org.apache.myfaces.application.BackwardsCompatibleNavigationHandlerWrapper;
import org.apache.myfaces.component.visit.VisitContextFactoryImpl;
import org.apache.myfaces.config.annotation.AnnotationConfigurator;
+import org.apache.myfaces.config.annotation.LifecycleProvider;
+import org.apache.myfaces.config.annotation.LifecycleProviderFactory;
import org.apache.myfaces.config.element.Behavior;
import org.apache.myfaces.config.element.ClientBehaviorRenderer;
import org.apache.myfaces.config.element.ManagedBean;
@@ -119,6 +121,7 @@ import org.apache.myfaces.util.ExternalS
import org.apache.myfaces.view.ViewDeclarationLanguageFactoryImpl;
import org.apache.myfaces.view.facelets.tag.jsf.TagHandlerDelegateFactoryImpl;
import org.apache.myfaces.view.facelets.tag.ui.DebugPhaseListener;
+import org.apache.myfaces.webapp.ManagedBeanDestroyerListener;
import org.xml.sax.SAXException;
/**
@@ -440,12 +443,6 @@ public class FacesConfigurator
FacesContext facesContext = FacesContext.getCurrentInstance();
Application application = facesContext.getApplication();
- // TODO: This is a workaround, to make this feature work. In theory, the method update should be called
- // in a way that StartupServletContextListener could "get involved".
- ManagedBeanDestroyer mbDestroyer = new ManagedBeanDestroyer();
- application.subscribeToEvent(PreDestroyCustomScopeEvent.class, mbDestroyer);
- application.subscribeToEvent(PreDestroyViewMapEvent.class, mbDestroyer);
-
application.publishEvent(facesContext, PostConstructApplicationEvent.class, Application.class, application);
}
}
@@ -541,7 +538,7 @@ public class FacesConfigurator
configureRuntimeConfig();
configureLifecycle();
handleSerialFactory();
-
+ configureManagedBeanDestroyer();
// record the time of update
lastUpdate = System.currentTimeMillis();
@@ -2092,11 +2089,6 @@ public class FacesConfigurator
runtimeConfig.setVariableResolverChainHead(getApplicationObject(VariableResolver.class,
dispenser.getVariableResolverIterator(),
new VariableResolverImpl()));
-
- // configure ManagedBeanDestroyer to listen to PreDestroyCustomScopeEvent and PreDestroyViewMapEvent
- //ManagedBeanDestroyer mbDestroyer = new ManagedBeanDestroyer();
- //application.subscribeToEvent(PreDestroyCustomScopeEvent.class, mbDestroyer);
- //application.subscribeToEvent(PreDestroyViewMapEvent.class, mbDestroyer);
}
/**
@@ -2723,4 +2715,41 @@ public class FacesConfigurator
log.info("Serialization provider : " + serialFactory.getClass());
_externalContext.getApplicationMap().put(StateUtils.SERIAL_FACTORY, serialFactory);
}
+
+ private void configureManagedBeanDestroyer()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Map<String, Object> applicationMap = externalContext.getApplicationMap();
+ Application application = facesContext.getApplication();
+
+ // get RuntimeConfig and LifecycleProvider
+ RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext);
+ LifecycleProvider lifecycleProvider = LifecycleProviderFactory
+ .getLifecycleProviderFactory().getLifecycleProvider(externalContext);
+
+ // create ManagedBeanDestroyer
+ ManagedBeanDestroyer mbDestroyer
+ = new ManagedBeanDestroyer(lifecycleProvider, runtimeConfig);
+
+ // subscribe ManagedBeanDestroyer as listener for needed events
+ application.subscribeToEvent(PreDestroyCustomScopeEvent.class, mbDestroyer);
+ application.subscribeToEvent(PreDestroyViewMapEvent.class, mbDestroyer);
+
+ // get ManagedBeanDestroyerListener instance
+ ManagedBeanDestroyerListener listener = (ManagedBeanDestroyerListener)
+ applicationMap.get(ManagedBeanDestroyerListener.APPLICATION_MAP_KEY);
+ if (listener != null)
+ {
+ // set the instance on the listener
+ listener.setManagedBeanDestroyer(mbDestroyer);
+ }
+ else
+ {
+ log.log(Level.SEVERE, "No ManagedBeanDestroyerListener instance found, thus "
+ + "@PreDestroy methods won't get called in every case. "
+ + "This instance needs to be published before configuration is started.");
+ }
+ }
+
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ManagedBeanDestroyer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ManagedBeanDestroyer.java?rev=997728&r1=997727&r2=997728&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ManagedBeanDestroyer.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ManagedBeanDestroyer.java Thu Sep 16 12:50:41 2010
@@ -49,37 +49,21 @@ public class ManagedBeanDestroyer implem
private static Logger log = Logger.getLogger(ManagedBeanDestroyer.class.getName());
- private RuntimeConfig runtimeConfig;
+ private RuntimeConfig _runtimeConfig;
+ private LifecycleProvider _lifecycleProvider;
- private ServletContext servletContext;
-
- public void setRuntimeConfig(RuntimeConfig runtimeConfig)
- {
- this.runtimeConfig = runtimeConfig;
- }
-
- public RuntimeConfig getRuntimeConfig()
- {
- if (runtimeConfig == null)
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if (facesContext != null)
- {
- ExternalContext externalContext = facesContext.getExternalContext();
- runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext);
- }
- }
- return runtimeConfig;
- }
-
- public ServletContext getServletContext()
- {
- return servletContext;
- }
-
- public void setServletContext(ServletContext servletContext)
+ /**
+ * Creates the ManagedBeanDestroyer for the given RuntimeConfig
+ * and LifecycleProvider.
+ *
+ * @param lifecycleProvider
+ * @param runtimeConfig
+ */
+ public ManagedBeanDestroyer(LifecycleProvider lifecycleProvider,
+ RuntimeConfig runtimeConfig)
{
- this.servletContext = servletContext;
+ _lifecycleProvider = lifecycleProvider;
+ _runtimeConfig = runtimeConfig;
}
public boolean isListenerForSource(Object source)
@@ -89,7 +73,6 @@ public class ManagedBeanDestroyer implem
return (source instanceof ScopeContext) || (source instanceof UIViewRoot);
}
-
/**
* Listens to PreDestroyCustomScopeEvent and PreDestroyViewMapEvent
* and invokes destroy() for every managed bean in the associated scope.
@@ -119,11 +102,10 @@ public class ManagedBeanDestroyer implem
return;
}
- LifecycleProvider provider = getCurrentLifecycleProvider();
for (String key : scope.keySet())
{
Object value = scope.get(key);
- this.destroy(key, value, provider);
+ this.destroy(key, value);
}
}
@@ -134,41 +116,21 @@ public class ManagedBeanDestroyer implem
*/
public boolean isManagedBean(String name)
{
- RuntimeConfig config = getRuntimeConfig();
- if (config != null)
- {
- return config.getManagedBean(name) != null;
- }
- // we have no RuntimeConfig, thus theres no FacesContext --> no managed bean
- return false;
+ return (_runtimeConfig.getManagedBean(name) != null);
}
/**
- * Destroys the given managed bean with the current LifecycleProvider.
+ * Destroys the given managed bean.
* @param name
* @param instance
*/
public void destroy(String name, Object instance)
{
- destroy(name, instance, getCurrentLifecycleProvider());
- }
-
- /**
- * Destroys the given managed bean with the given LifecycleProvider
- * @param name
- * @param instance
- * @param provider
- */
- public void destroy(String name, Object instance, LifecycleProvider provider)
- {
- if (isManagedBean(name)) {
- if (provider == null)
- {
- provider = getCurrentLifecycleProvider();
- }
+ if (instance != null && isManagedBean(name))
+ {
try
{
- provider.destroyInstance(instance);
+ _lifecycleProvider.destroyInstance(instance);
}
catch (IllegalAccessException e)
{
@@ -181,21 +143,5 @@ public class ManagedBeanDestroyer implem
}
}
}
-
- /**
- * Retrieves the current LifecycleProvider from the LifecycleProviderFactory
- * @return
- */
- public LifecycleProvider getCurrentLifecycleProvider()
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if (facesContext == null)
- {
- ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext, false);
- return LifecycleProviderFactory.getLifecycleProviderFactory().getLifecycleProvider(externalContext);
- }
- ExternalContext externalContext = facesContext.getExternalContext();
- return LifecycleProviderFactory.getLifecycleProviderFactory().getLifecycleProvider(externalContext);
- }
-
+
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java?rev=997728&r1=997727&r2=997728&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java Thu Sep 16 12:50:41 2010
@@ -18,32 +18,12 @@
*/
package org.apache.myfaces.webapp;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.el.ExpressionFactory;
-import javax.faces.application.Application;
-import javax.faces.application.ProjectStage;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExceptionHandler;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PostConstructApplicationEvent;
-import javax.faces.event.PreDestroyApplicationEvent;
-import javax.faces.event.SystemEvent;
-import javax.servlet.ServletContext;
-
import org.apache.myfaces.application.ApplicationImpl;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
import org.apache.myfaces.config.FacesConfigValidator;
import org.apache.myfaces.config.FacesConfigurator;
import org.apache.myfaces.config.ManagedBeanBuilder;
import org.apache.myfaces.config.RuntimeConfig;
-import org.apache.myfaces.config.annotation.DefaultLifecycleProviderFactory;
import org.apache.myfaces.config.element.ManagedBean;
import org.apache.myfaces.context.ReleaseableExternalContext;
import org.apache.myfaces.context.servlet.StartupFacesContextImpl;
@@ -52,6 +32,24 @@ import org.apache.myfaces.shared_impl.co
import org.apache.myfaces.shared_impl.util.StateUtils;
import org.apache.myfaces.shared_impl.webapp.webxml.WebXml;
+import javax.el.ExpressionFactory;
+import javax.faces.application.Application;
+import javax.faces.application.ProjectStage;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExceptionHandler;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PostConstructApplicationEvent;
+import javax.faces.event.PreDestroyApplicationEvent;
+import javax.faces.event.SystemEvent;
+import javax.servlet.ServletContext;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
/**
* Performs common initialization tasks.
*/
@@ -133,12 +131,6 @@ public abstract class AbstractFacesIniti
_dispatchApplicationEvent(servletContext, PostConstructApplicationEvent.class);
- //initialize LifecycleProvider.
- //if not set here, first call of getLifecycleProvider is invoked with null external context
- //and org.apache.myfaces.config.annotation.LifecycleProvider context parameter is ignored.
- //see MYFACES-2555 and MYFACES-2919
- DefaultLifecycleProviderFactory.getLifecycleProviderFactory().getLifecycleProvider(externalContext);
-
// print out a very prominent log message if the project stage is != Production
if (!facesContext.isProjectStage(ProjectStage.Production))
{
@@ -179,7 +171,7 @@ public abstract class AbstractFacesIniti
/**
* Checks for application scoped managed-beans with eager=true,
* creates them and stores them in the application map.
- * @param externalContext
+ * @param facesContext
*/
private void _createEagerBeans(FacesContext facesContext)
{
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/ManagedBeanDestroyerListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/ManagedBeanDestroyerListener.java?rev=997728&r1=997727&r2=997728&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/ManagedBeanDestroyerListener.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/ManagedBeanDestroyerListener.java Thu Sep 16 12:50:41 2010
@@ -61,10 +61,27 @@ public class ManagedBeanDestroyerListene
ServletContextListener, ServletContextAttributeListener,
ServletRequestListener, ServletRequestAttributeListener
{
-
- private ManagedBeanDestroyer destroyer = new ManagedBeanDestroyer();
- /* Session related methods */
+ /**
+ * The instance of the ManagedBeanDestroyerListener created by
+ * StartupServletContextListener is stored under this key in the
+ * ApplicationMap.
+ */
+ public static final String APPLICATION_MAP_KEY = "org.apache.myfaces.ManagedBeanDestroyerListener";
+
+ private ManagedBeanDestroyer _destroyer = null;
+
+ /**
+ * Sets the ManagedBeanDestroyer instance to use.
+ *
+ * @param destroyer
+ */
+ public void setManagedBeanDestroyer(ManagedBeanDestroyer destroyer)
+ {
+ _destroyer = destroyer;
+ }
+
+ /* Session related methods ***********************************************/
public void attributeAdded(HttpSessionBindingEvent event)
{
@@ -73,12 +90,18 @@ public class ManagedBeanDestroyerListene
public void attributeRemoved(HttpSessionBindingEvent event)
{
- destroyer.destroy(event.getName(), event.getValue());
+ if (_destroyer != null)
+ {
+ _destroyer.destroy(event.getName(), event.getValue());
+ }
}
public void attributeReplaced(HttpSessionBindingEvent event)
{
- destroyer.destroy(event.getName(), event.getValue());
+ if (_destroyer != null)
+ {
+ _destroyer.destroy(event.getName(), event.getValue());
+ }
}
public void sessionCreated(HttpSessionEvent event)
@@ -89,25 +112,26 @@ public class ManagedBeanDestroyerListene
@SuppressWarnings("unchecked")
public void sessionDestroyed(HttpSessionEvent event)
{
- HttpSession session = event.getSession();
- Enumeration<String> attributes = session.getAttributeNames();
- if (!attributes.hasMoreElements())
- {
- // nothing to do
- return;
- }
- // optimization: provide the LifecycleProvider, because there could be a lot of elements
- LifecycleProvider provider = destroyer.getCurrentLifecycleProvider();
-
- while (attributes.hasMoreElements())
+ if (_destroyer != null)
{
- String name = attributes.nextElement();
- Object value = session.getAttribute(name);
- destroyer.destroy(name, value, provider);
+ HttpSession session = event.getSession();
+ Enumeration<String> attributes = session.getAttributeNames();
+ if (!attributes.hasMoreElements())
+ {
+ // nothing to do
+ return;
+ }
+
+ while (attributes.hasMoreElements())
+ {
+ String name = attributes.nextElement();
+ Object value = session.getAttribute(name);
+ _destroyer.destroy(name, value);
+ }
}
}
- /* Context related methods */
+ /* Context related methods ***********************************************/
public void attributeAdded(ServletContextAttributeEvent event)
{
@@ -116,57 +140,48 @@ public class ManagedBeanDestroyerListene
public void attributeRemoved(ServletContextAttributeEvent event)
{
- destroyer.destroy(event.getName(), event.getValue());
+ if (_destroyer != null)
+ {
+ _destroyer.destroy(event.getName(), event.getValue());
+ }
}
public void attributeReplaced(ServletContextAttributeEvent event)
{
- destroyer.destroy(event.getName(), event.getValue());
+ if (_destroyer != null)
+ {
+ _destroyer.destroy(event.getName(), event.getValue());
+ }
}
public void contextInitialized(ServletContextEvent event)
{
- // set the RuntimeConfig of ManagedBeanDestroyer, because
- // in requestDestroyed, contextDestroyed FacesContext.getCurrentInstance() returns
- // null and so we wouln't get the RuntimeConfig.
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if (facesContext == null)
- {
- return;
- }
- ExternalContext externalContext = facesContext.getExternalContext();
- RuntimeConfig config = RuntimeConfig.getCurrentInstance(externalContext);
- destroyer.setRuntimeConfig(config);
- destroyer.setServletContext(event.getServletContext());
-
- // configure ManagedBeanDestroyer to listen to PreDestroyCustomScopeEvent and PreDestroyViewMapEvent
- facesContext.getApplication().subscribeToEvent(PreDestroyCustomScopeEvent.class, destroyer);
- facesContext.getApplication().subscribeToEvent(PreDestroyViewMapEvent.class, destroyer);
+ // noop
}
@SuppressWarnings("unchecked")
public void contextDestroyed(ServletContextEvent event)
{
- ServletContext ctx = event.getServletContext();
- Enumeration<String> attributes = ctx.getAttributeNames();
- if (!attributes.hasMoreElements())
+ if (_destroyer != null)
{
- // nothing to do
- return;
+ ServletContext ctx = event.getServletContext();
+ Enumeration<String> attributes = ctx.getAttributeNames();
+ if (!attributes.hasMoreElements())
+ {
+ // nothing to do
+ return;
+ }
+
+ while (attributes.hasMoreElements())
+ {
+ String name = attributes.nextElement();
+ Object value = ctx.getAttribute(name);
+ _destroyer.destroy(name, value);
+ }
}
- // optimization: provide the LifecycleProvider, because there could be a lot of elements
- LifecycleProvider provider = destroyer.getCurrentLifecycleProvider();
-
- while (attributes.hasMoreElements())
- {
- String name = attributes.nextElement();
- Object value = ctx.getAttribute(name);
- destroyer.destroy(name, value, provider);
- }
-
}
- /* Request related methods */
+ /* Request related methods ***********************************************/
public void attributeAdded(ServletRequestAttributeEvent event)
{
@@ -175,12 +190,18 @@ public class ManagedBeanDestroyerListene
public void attributeRemoved(ServletRequestAttributeEvent event)
{
- destroyer.destroy(event.getName(), event.getValue());
+ if (_destroyer != null)
+ {
+ _destroyer.destroy(event.getName(), event.getValue());
+ }
}
public void attributeReplaced(ServletRequestAttributeEvent event)
{
- destroyer.destroy(event.getName(), event.getValue());
+ if (_destroyer != null)
+ {
+ _destroyer.destroy(event.getName(), event.getValue());
+ }
}
public void requestInitialized(ServletRequestEvent event)
@@ -190,22 +211,23 @@ public class ManagedBeanDestroyerListene
@SuppressWarnings("unchecked")
public void requestDestroyed(ServletRequestEvent event)
- {
- ServletRequest request = event.getServletRequest();
- Enumeration<String> attributes = request.getAttributeNames();
- if (!attributes.hasMoreElements())
- {
- // nothing to do
- return;
- }
- // optimization: provide the LifecycleProvider, because there could be a lot of elements
- LifecycleProvider provider = destroyer.getCurrentLifecycleProvider();
-
- while (attributes.hasMoreElements())
- {
- String name = attributes.nextElement();
- Object value = request.getAttribute(name);
- destroyer.destroy(name, value, provider);
+ {
+ if (_destroyer != null)
+ {
+ ServletRequest request = event.getServletRequest();
+ Enumeration<String> attributes = request.getAttributeNames();
+ if (!attributes.hasMoreElements())
+ {
+ // nothing to do
+ return;
+ }
+
+ while (attributes.hasMoreElements())
+ {
+ String name = attributes.nextElement();
+ Object value = request.getAttribute(name);
+ _destroyer.destroy(name, value);
+ }
}
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java?rev=997728&r1=997727&r2=997728&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/webapp/StartupServletContextListener.java Thu Sep 16 12:50:41 2010
@@ -23,6 +23,7 @@ import org.apache.myfaces.buildtools.mav
import org.apache.myfaces.shared_impl.util.ClassUtils;
import javax.faces.FactoryFinder;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextAttributeEvent;
@@ -37,6 +38,7 @@ import javax.servlet.http.HttpSessionAtt
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -101,12 +103,15 @@ public class StartupServletContextListen
// Create startup FacesContext before initializing
FacesContext facesContext = _facesInitializer.initStartupFacesContext(_servletContext);
+
+ // publish the ManagedBeanDestroyerListener instance in the application map
+ _publishManagedBeanDestroyerListener(facesContext);
dispatchInitializationEvent(event, FACES_INIT_PHASE_PREINIT);
- _facesInitializer.initFaces(_servletContext);
+ _facesInitializer.initFaces(_servletContext); //TODO maybe return value not needed
dispatchInitializationEvent(event, FACES_INIT_PHASE_POSTINIT);
_servletContext.setAttribute(FACES_INIT_DONE, Boolean.TRUE);
-
+
// call contextInitialized on ManagedBeanDestroyerListener
_detroyerListener.contextInitialized(event);
@@ -118,6 +123,21 @@ public class StartupServletContextListen
log.info("MyFaces already initialized");
}
}
+
+ /**
+ * Publishes the ManagedBeanDestroyerListener instance in the application map.
+ * This allows the FacesConfigurator to access the instance and to set the
+ * correct ManagedBeanDestroyer instance on it.
+ *
+ * @param facesContext
+ */
+ private void _publishManagedBeanDestroyerListener(FacesContext facesContext)
+ {
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Map<String, Object> applicationMap = externalContext.getApplicationMap();
+
+ applicationMap.put(ManagedBeanDestroyerListener.APPLICATION_MAP_KEY, _detroyerListener);
+ }
public void contextDestroyed(ServletContextEvent event)
{
@@ -225,7 +245,7 @@ public class StartupServletContextListen
}
/* the following methods are needed to serve ManagedBeanDestroyerListener */
- /* Session related methods */
+ /* Session related methods ***********************************************/
public void attributeAdded(HttpSessionBindingEvent event)
{
@@ -252,7 +272,7 @@ public class StartupServletContextListen
_detroyerListener.sessionDestroyed(event);
}
- /* Context related methods */
+ /* Context related methods ***********************************************/
public void attributeAdded(ServletContextAttributeEvent event)
{
@@ -269,7 +289,7 @@ public class StartupServletContextListen
_detroyerListener.attributeReplaced(event);
}
- /* Request related methods */
+ /* Request related methods ***********************************************/
public void attributeAdded(ServletRequestAttributeEvent event)
{