Package org.apache.myfaces.view.facelets
Class ViewPoolProcessor
java.lang.Object
org.apache.myfaces.view.facelets.ViewPoolProcessor
This class is reponsible for all processing tasks related to the view pool.
For enable the pool only for a subset of your views, you can
add an entry inside faces-config.xml file like this:
<faces-config-extension>
<view-pool-mapping>
<url-pattern>/*</url-pattern>
<parameter>
<name>org.apache.myfaces.VIEW_POOL_MAX_POOL_SIZE</name>
<value>5</value>
</parameter>
</view-pool-mapping>
</faces-config-extension>
- Author:
- Leonardo Uribe
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringFlag to indicate that dispose this view on navigation is valid.static final StringUIViewRoot attribute to enable/disable the view for use pooling.static final StringFlag that indicates to the StateManagementStrategy that no state needs to be stored and we are using saveState() to dispose the view and store it into the pool directly.static final StringParam used to indicate a "deferred navigation" needs to be done.static final IntegerIndicates a hard reset should be done when saveState(...) is performed, which means all transient and delta state should be cleared, destroying all existing state in the process.static final IntegerIndicates no reset should be done on this state savingstatic final IntegerIndicates a soft reset should be done when saveState(...) is performed, which means all transient state should be cleared but the delta state should not be destroyed in the process.static final StringAttribute of UIViewRoot that indicates if a soft (1) or hard(2) (reset and check) reset is required in the call to saveState(). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearTransientAndNonFaceletComponentsForDynamicView(FacesContext context, UIViewRoot root, ViewStructureMetadata viewStructureMetadata) protected voidvoidcloneAndRestoreView(FacesContext context, UIViewRoot newView, ViewEntry entry, ViewStructureMetadata metadata) Takes the newView and restore the state taken as base the provided ViewEntry, and then move all child components from oldView to newView, to finally obtain a clean component tree.voiddisposeView(FacesContext facesContext, UIViewRoot root) static ViewPoolProcessorgetInstance(FacesContext context) getViewPool(FacesContext context, UIViewRoot root) static voidinitialize(FacesContext context) This method should be called at startup to decide if a view processor should be provided or not to the runtime.booleanisViewPoolEnabledForThisView(FacesContext context, UIViewRoot root) booleanisViewPoolStrategyAllowedForThisView(FacesContext context, UIViewRoot root) voidprocessDeferredNavigation(FacesContext facesContext) voidpushPartialView(FacesContext context, UIViewRoot view, FaceletState faceletViewState, int count) voidpushResetableView(FacesContext context, UIViewRoot view, FaceletState faceletViewState) retrieveViewStructureMetadata(FacesContext context, UIViewRoot root) voidsetViewPoolDisabledOnThisView(FacesContext context, UIViewRoot root, boolean value) voidstoreViewStructureMetadata(FacesContext context, UIViewRoot root)
-
Field Details
-
ENABLE_VIEW_POOL
UIViewRoot attribute to enable/disable the view for use pooling.- See Also:
-
FORCE_HARD_RESET
Flag that indicates to the StateManagementStrategy that no state needs to be stored and we are using saveState() to dispose the view and store it into the pool directly.- See Also:
-
DISPOSE_VIEW_NAVIGATION
Flag to indicate that dispose this view on navigation is valid.- See Also:
-
RESET_SAVE_STATE_MODE_KEY
Attribute of UIViewRoot that indicates if a soft (1) or hard(2) (reset and check) reset is required in the call to saveState().- See Also:
-
RESET_MODE_OFF
Indicates no reset should be done on this state saving -
RESET_MODE_SOFT
Indicates a soft reset should be done when saveState(...) is performed, which means all transient state should be cleared but the delta state should not be destroyed in the process. -
RESET_MODE_HARD
Indicates a hard reset should be done when saveState(...) is performed, which means all transient and delta state should be cleared, destroying all existing state in the process. If something cannot be reseted, the state should return non null, so the algorithm can remove the component from the tree and mark the tree as partial (requires refresh before reuse). -
INVOKE_DEFERRED_NAVIGATION
Param used to indicate a "deferred navigation" needs to be done. To allow the view pool to dispose the view properly (and reuse it later), it is necessary to ensure the view is not being used at the moment. If the navigation call occur inside an action listener, the current view is being used and cannot be disposed (because it conflicts with hard/soft reset). This extension allows to call handleNavigation() before end invoke application phase, but after traverse the component tree.- See Also:
-
-
Constructor Details
-
ViewPoolProcessor
-
-
Method Details
-
getInstance
-
initialize
This method should be called at startup to decide if a view processor should be provided or not to the runtime.- Parameters:
context-
-
getViewPool
-
isViewPoolEnabledForThisView
-
isViewPoolStrategyAllowedForThisView
-
setViewPoolDisabledOnThisView
-
cloneAndRestoreView
public void cloneAndRestoreView(FacesContext context, UIViewRoot newView, ViewEntry entry, ViewStructureMetadata metadata) Takes the newView and restore the state taken as base the provided ViewEntry, and then move all child components from oldView to newView, to finally obtain a clean component tree.- Parameters:
context-newView-entry-
-
storeViewStructureMetadata
-
retrieveViewStructureMetadata
-
pushResetableView
-
pushPartialView
public void pushPartialView(FacesContext context, UIViewRoot view, FaceletState faceletViewState, int count) -
clearTransientAndNonFaceletComponentsForStaticView
protected void clearTransientAndNonFaceletComponentsForStaticView(FacesContext context, UIViewRoot root) -
clearTransientAndNonFaceletComponentsForDynamicView
public void clearTransientAndNonFaceletComponentsForDynamicView(FacesContext context, UIViewRoot root, ViewStructureMetadata viewStructureMetadata) -
disposeView
-