Class ViewPool
- java.lang.Object
-
- org.apache.myfaces.view.facelets.pool.ViewPool
-
- Direct Known Subclasses:
ViewPoolImpl
public abstract class ViewPool extends Object
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
Fields Modifier and Type Field Description static String
ENTRY_MODE_SOFT
static String
ENTRY_MODE_WEAK
static String
INIT_PARAM_VIEW_POOL_DEFERRED_NAVIGATION
Defines if the view pool uses deferred navigation to recycle views when navigation is performed.static String
INIT_PARAM_VIEW_POOL_ENTRY_MODE
Defines the type of memory reference that is used to hold the view into memory.static String
INIT_PARAM_VIEW_POOL_ENTRY_MODE_DEFAULT
static String
INIT_PARAM_VIEW_POOL_MAX_DYNAMIC_PARTIAL_LIMIT
Defines the limit of the views that cannot be reused partially.static int
INIT_PARAM_VIEW_POOL_MAX_DYNAMIC_PARTIAL_LIMIT_DEFAULT
static String
INIT_PARAM_VIEW_POOL_MAX_POOL_SIZE
Defines the number of views to be hold per each view metadata definition.static int
INIT_PARAM_VIEW_POOL_MAX_POOL_SIZE_DEFAULT
-
Constructor Summary
Constructors Constructor Description ViewPool()
-
Method Summary
-
-
-
Field Detail
-
INIT_PARAM_VIEW_POOL_MAX_POOL_SIZE
@JSFWebConfigParam(defaultValue="5", tags="performance") public static final String INIT_PARAM_VIEW_POOL_MAX_POOL_SIZE
Defines 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:
- Constant Field Values
-
INIT_PARAM_VIEW_POOL_MAX_POOL_SIZE_DEFAULT
public static final int INIT_PARAM_VIEW_POOL_MAX_POOL_SIZE_DEFAULT
- See Also:
- Constant Field Values
-
INIT_PARAM_VIEW_POOL_MAX_DYNAMIC_PARTIAL_LIMIT
@JSFWebConfigParam(defaultValue="2", tags="performance") public static final String INIT_PARAM_VIEW_POOL_MAX_DYNAMIC_PARTIAL_LIMIT
Defines the limit of the views that cannot be reused partially.- See Also:
- Constant Field Values
-
INIT_PARAM_VIEW_POOL_MAX_DYNAMIC_PARTIAL_LIMIT_DEFAULT
public static final int INIT_PARAM_VIEW_POOL_MAX_DYNAMIC_PARTIAL_LIMIT_DEFAULT
- See Also:
- Constant Field Values
-
INIT_PARAM_VIEW_POOL_ENTRY_MODE
@JSFWebConfigParam(defaultValue="soft", expectedValues="weak,soft", tags="performance") public static final String INIT_PARAM_VIEW_POOL_ENTRY_MODE
Defines the type of memory reference that is used to hold the view into memory. By default a "soft" reference is used.- See Also:
- Constant Field Values
-
ENTRY_MODE_SOFT
public static final String ENTRY_MODE_SOFT
- See Also:
- Constant Field Values
-
ENTRY_MODE_WEAK
public static final String ENTRY_MODE_WEAK
- See Also:
- Constant Field Values
-
INIT_PARAM_VIEW_POOL_ENTRY_MODE_DEFAULT
public static final String INIT_PARAM_VIEW_POOL_ENTRY_MODE_DEFAULT
- See Also:
- Constant Field Values
-
INIT_PARAM_VIEW_POOL_DEFERRED_NAVIGATION
@JSFWebConfigParam(defaultValue="false", expectedValues="true, false", tags="performance") public static final String INIT_PARAM_VIEW_POOL_DEFERRED_NAVIGATION
Defines 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:
- Constant Field Values
-
-
Method Detail
-
isDeferredNavigationEnabled
public abstract boolean isDeferredNavigationEnabled()
Indicate if the view pool uses deferred navigation.- Returns:
-
storeStaticViewStructureMetadata
public abstract void storeStaticViewStructureMetadata(FacesContext context, UIViewRoot root, FaceletState faceletState)
-
retrieveStaticViewStructureMetadata
public abstract ViewStructureMetadata retrieveStaticViewStructureMetadata(FacesContext context, UIViewRoot root)
-
pushStaticStructureView
public abstract void pushStaticStructureView(FacesContext context, UIViewRoot root)
-
pushPartialStructureView
public abstract void pushPartialStructureView(FacesContext context, UIViewRoot root)
-
popStaticOrPartialStructureView
public abstract ViewEntry popStaticOrPartialStructureView(FacesContext context, UIViewRoot root)
-
isWorthToRecycleThisView
public abstract boolean isWorthToRecycleThisView(FacesContext context, UIViewRoot root)
-
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)
-
-