com.liferay.faces.bridge.event
Class ManagedBeanScopePhaseListener
java.lang.Object
com.liferay.faces.bridge.event.ManagedBeanScopePhaseListener
- All Implemented Interfaces:
- Serializable, EventListener, javax.faces.event.PhaseListener
public class ManagedBeanScopePhaseListener
- extends Object
- implements javax.faces.event.PhaseListener
According to the JSF 2.0 JavaDocs for ExternalContext.getApplicationMap, before a managed-bean is removed
from the map, any public no-argument void return methods annotated with javax.annotation.PreDestroy must be called
first. This would be equally true of any custom JSF 2.0 scope, such as the bridgeRequestScope. This class is a JSF
PhaseListener that listens after the RENDER_RESPONSE phase completes. Its purpose is to force the managed-beans in
bridgeRequestScope and requestScope to go out-of-scope which will in turn cause any annotated PreDestroy methods to
be called.
Note that this functionality is implemented as a PhaseListener because I couldn't get it to work after the
lifecycle terminated. My suspicion is that Mojarra has some servlet dependency stuff going on. Specifically,
Mojarra's WebappLifecycleListener might be getting invoked or something. The strange thing is that it appears that
Mojarra makes managed-beans go away, but not by calling the map.clear() or map.remove() methods. Mojarra apparently
handles things with a listener that captures ServletContext attribute events, which may also be playing a role.
Anyway, doing this with a PhaseListener seems to work.
- Author:
- Neil Griffin
- See Also:
- Serialized Form
|
Method Summary |
void |
afterPhase(javax.faces.event.PhaseEvent phaseEvent)
|
void |
beforePhase(javax.faces.event.PhaseEvent phaseEvent)
|
javax.faces.event.PhaseId |
getPhaseId()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ManagedBeanScopePhaseListener
public ManagedBeanScopePhaseListener()
afterPhase
public void afterPhase(javax.faces.event.PhaseEvent phaseEvent)
- Specified by:
afterPhase in interface javax.faces.event.PhaseListener
beforePhase
public void beforePhase(javax.faces.event.PhaseEvent phaseEvent)
- Specified by:
beforePhase in interface javax.faces.event.PhaseListener
getPhaseId
public javax.faces.event.PhaseId getPhaseId()
- Specified by:
getPhaseId in interface javax.faces.event.PhaseListener
Copyright © 2014 Liferay, Inc.. All Rights Reserved.