MyFaces Core
  1. MyFaces Core
  2. MYFACES-1960

Make the state-manager (JspStateManagerImpl) behaviour storing the previous view-states in MyFaces optional

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.6, 1.2.4
    • Fix Version/s: 1.2.5
    • Component/s: None
    • Labels:
      None

      Description

      Actually the class org.apache.myfaces.application.jsp.JspStateManagerImpl.SerializedViewCollection store the old views using:

      protected Map getOldSerializedViewsMap() {
      if (_oldSerializedViews == null)

      { _oldSerializedViews = new ReferenceMap(AbstractReferenceMap.WEAK, AbstractReferenceMap.WEAK, true); }

      return _oldSerializedViews;
      }

      Right now, this part is used when server side saving is enabled, as a second level cache. If the view is not available on _serializedViews (the map that holds the views in first place) , it tries to get it from _oldSerializedViews. If it is found use it but if not just return null.

      The default should be that this behaviour is off (contrary to the current case).

      It is more, there should be the possibility to use soft references instead weak references, so the user can tune this by its own needs.

      The idea for solve this is create a param called org.apache.myfaces.CACHE_OLD_VIEWS_IN_SESSION_MODE with the possible values:

      soft: use an ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.SOFT, true)
      weak: use an ReferenceMap(AbstractReferenceMap.WEAK, AbstractReferenceMap.WEAK, true)
      off, no: default, no cache is used

      The changes should be applied on 1.1 and 1.2.

      1. MYFACES-1960-JSF11.patch
        5 kB
        Leonardo Uribe
      2. MYFACES-1960-JSF12.patch
        5 kB
        Leonardo Uribe
      3. MYFACES-1960-JSF11-v2.patch
        7 kB
        Leonardo Uribe
      4. MYFACES-1960-JSF12-v2.patch
        7 kB
        Leonardo Uribe

        Activity

        Hide
        Leonardo Uribe added a comment -

        patch proposed for myfaces core 1.1

        Show
        Leonardo Uribe added a comment - patch proposed for myfaces core 1.1
        Hide
        Leonardo Uribe added a comment -

        patch proposed for jsf 1.2

        Show
        Leonardo Uribe added a comment - patch proposed for jsf 1.2
        Hide
        Leonardo Uribe added a comment -

        If no objections I'll commit this patch soon. The only thing that I don't like is the call to FacesContext.getCurrentInstance in get method, but change the signature of this function is worse (I prefer remain stable the api, because some users used to subclass JspStateManagerImpl).

        Show
        Leonardo Uribe added a comment - If no objections I'll commit this patch soon. The only thing that I don't like is the call to FacesContext.getCurrentInstance in get method, but change the signature of this function is worse (I prefer remain stable the api, because some users used to subclass JspStateManagerImpl).
        Hide
        Leonardo Uribe added a comment -

        After revision, added:

        hard-soft: use an ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.SOFT)
        soft-weak: use an ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.WEAK, true)

        Use a hard-soft mode could lead to a memory leak (MYFACES-1660). I don't like add this mode, but does not harm.

        Show
        Leonardo Uribe added a comment - After revision, added: hard-soft: use an ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.SOFT) soft-weak: use an ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.WEAK, true) Use a hard-soft mode could lead to a memory leak ( MYFACES-1660 ). I don't like add this mode, but does not harm.

          People

          • Assignee:
            Leonardo Uribe
            Reporter:
            Leonardo Uribe
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development