Class ViewPool
java.lang.Object
org.apache.myfaces.view.facelets.pool.ViewPool
- Direct Known Subclasses:
ViewPoolImpl
This class defines the necessary operations that a view pool should comply in
order to be used by MyFaces.
A View Pool is a set of initialized views that are kept ready to use. The idea is reset and reuse views taking advantage of existing Faces 2.0 Partial State Saving algorithm with some small additions to component's saveState() method.
This technique works by these reasons:
- A view is composed by many small objects that are created multiple times per each request, and the time spent creating these objects is usually larger than the time used to traverse the component tree.
- The structure of a view usually does not change over application lifetime.
- The "delta state" or in other words the elements that change in view are small compared with the elements that does not change.
The implementation proposed uses a lock free view pool structure with soft or weak references. The lock free view pool ensures fast access and the soft or weak references ensured the garbage collection algorithm is not affected by the view pool.
- Author:
- Leonardo Uribe
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
Defines if the view pool uses deferred navigation to recycle views when navigation is performed.static final String
Defines the type of memory reference that is used to hold the view into memory.static final String
static final String
Defines the limit of the views that cannot be reused partially.static final int
static final String
Defines the number of views to be hold per each view metadata definition.static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
Indicate if the view pool uses deferred navigation.abstract boolean
isWorthToRecycleThisView
(FacesContext context, UIViewRoot root) abstract ViewEntry
popDynamicStructureView
(FacesContext context, UIViewRoot root, FaceletState faceletDynamicState) abstract ViewEntry
popStaticOrPartialStructureView
(FacesContext context, UIViewRoot root) abstract void
pushDynamicStructureView
(FacesContext context, UIViewRoot root, FaceletState faceletDynamicState) abstract void
pushPartialStructureView
(FacesContext context, UIViewRoot root) abstract void
pushStaticStructureView
(FacesContext context, UIViewRoot root) abstract ViewStructureMetadata
retrieveDynamicViewStructureMetadata
(FacesContext context, UIViewRoot root, FaceletState faceletState) abstract ViewStructureMetadata
retrieveStaticViewStructureMetadata
(FacesContext context, UIViewRoot root) abstract void
storeDynamicViewStructureMetadata
(FacesContext context, UIViewRoot root, FaceletState faceletState) abstract void
storeStaticViewStructureMetadata
(FacesContext context, UIViewRoot root, FaceletState faceletState)
-
Field Details
-
INIT_PARAM_VIEW_POOL_MAX_POOL_SIZE
@JSFWebConfigParam(defaultValue="5", tags="performance") public static final String INIT_PARAM_VIEW_POOL_MAX_POOL_SIZEDefines the number of views to be hold per each view metadata definition. By default is 5. Usually a view is defined by its viewId, locale, renderKitId and active contracts. If a view shares the same values for these parameters belongs to the same group that can be pooled.- See Also:
-
INIT_PARAM_VIEW_POOL_MAX_POOL_SIZE_DEFAULT
public static final int INIT_PARAM_VIEW_POOL_MAX_POOL_SIZE_DEFAULT- See Also:
-
INIT_PARAM_VIEW_POOL_MAX_DYNAMIC_PARTIAL_LIMIT
@JSFWebConfigParam(defaultValue="2", tags="performance") public static final String INIT_PARAM_VIEW_POOL_MAX_DYNAMIC_PARTIAL_LIMITDefines the limit of the views that cannot be reused partially.- See Also:
-
INIT_PARAM_VIEW_POOL_MAX_DYNAMIC_PARTIAL_LIMIT_DEFAULT
public static final int INIT_PARAM_VIEW_POOL_MAX_DYNAMIC_PARTIAL_LIMIT_DEFAULT- See Also:
-
INIT_PARAM_VIEW_POOL_ENTRY_MODE
@JSFWebConfigParam(defaultValue="soft", expectedValues="weak,soft", tags="performance") public static final String INIT_PARAM_VIEW_POOL_ENTRY_MODEDefines the type of memory reference that is used to hold the view into memory. By default a "soft" reference is used.- See Also:
-
ENTRY_MODE_SOFT
- See Also:
-
ENTRY_MODE_WEAK
- See Also:
-
INIT_PARAM_VIEW_POOL_ENTRY_MODE_DEFAULT
- See Also:
-
INIT_PARAM_VIEW_POOL_DEFERRED_NAVIGATION
@JSFWebConfigParam(defaultValue="false", expectedValues="true, false", tags="performance") public static final String INIT_PARAM_VIEW_POOL_DEFERRED_NAVIGATIONDefines if the view pool uses deferred navigation to recycle views when navigation is performed. The difference is a normal navigation is not done when the broadcast is done but at the end of invoke application phase.- See Also:
-
-
Constructor Details
-
ViewPool
public ViewPool()
-
-
Method Details
-
storeStaticViewStructureMetadata
public abstract void storeStaticViewStructureMetadata(FacesContext context, UIViewRoot root, FaceletState faceletState) -
retrieveStaticViewStructureMetadata
public abstract ViewStructureMetadata retrieveStaticViewStructureMetadata(FacesContext context, UIViewRoot root) -
pushStaticStructureView
-
pushPartialStructureView
-
popStaticOrPartialStructureView
-
isWorthToRecycleThisView
-
storeDynamicViewStructureMetadata
public abstract void storeDynamicViewStructureMetadata(FacesContext context, UIViewRoot root, FaceletState faceletState) -
retrieveDynamicViewStructureMetadata
public abstract ViewStructureMetadata retrieveDynamicViewStructureMetadata(FacesContext context, UIViewRoot root, FaceletState faceletState) -
pushDynamicStructureView
public abstract void pushDynamicStructureView(FacesContext context, UIViewRoot root, FaceletState faceletDynamicState) -
popDynamicStructureView
public abstract ViewEntry popDynamicStructureView(FacesContext context, UIViewRoot root, FaceletState faceletDynamicState)