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 Details

    • 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:
    • 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_LIMIT
      Defines 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_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:
    • ENTRY_MODE_SOFT

      public static final String ENTRY_MODE_SOFT
      See Also:
    • ENTRY_MODE_WEAK

      public static final String ENTRY_MODE_WEAK
      See Also:
    • INIT_PARAM_VIEW_POOL_ENTRY_MODE_DEFAULT

      public static final String 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_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:
  • Constructor Details

    • ViewPool

      public ViewPool()
  • Method Details