org.apache.myfaces.trinidad.bean.util

## Class StateUtils

- java.lang.Object
- - org.apache.myfaces.trinidad.bean.util.StateUtils

-     public final class StateUtils
      extends Object

  Utilities for handling state persistance.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StateUtils()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `checkApplicationSerialization(javax.faces.context.ExternalContext extContext)` Returns `true` if Object written to the ExternalContext's Application Map should be checked for Serializability when `put` is called.
    `static boolean` | `checkComponentStateSerialization(javax.faces.context.FacesContext context)` Returns `true` if components should be checked for serializability when when generating the view's state object.
    `static boolean` | `checkComponentTreeStateSerialization(javax.faces.context.FacesContext context)` Returns `true` if the component tree should be checked for serializability when when generating the view's state object.
    `static boolean` | `checkManagedBeanMutation(javax.faces.context.ExternalContext extContext)` Returns `true` if the attributes of the session and application Maps should be checked for cases where the attribute was mutated but not dirtied for failover.
    `static boolean` | `checkScopesAtEndOfRequest(javax.faces.context.ExternalContext extContext)` Returns `true` if all attributes in the session Map should be checked for serializability at the end of each request.
    `static boolean` | `checkSessionSerialization(javax.faces.context.ExternalContext extContext)` Returns `true` if Object written to the ExternalContext's Session Map should be checked for Serializability when `put` is called.
    `static PropertyKey` | `restoreKey(FacesBean.Type type, Object value)` Restores a persisted PropertyKey.
    `static Object` | `restoreList(javax.faces.context.FacesContext context, Object savedValue)` Restores a List whose elements may implement StateHolder.
    `static void` | `restoreState(PropertyMap map, javax.faces.context.FacesContext context, FacesBean.Type type, Object state, boolean useStateHolder)` Generic (unoptimized) version of PropertyMap state restoring.
    `static Object` | `restoreStateHolder(javax.faces.context.FacesContext context, Object savedValue)` Restores an object that was saved using saveStateHolder()
    `static Object` | `saveKey(PropertyKey key)` Persists a property key.
    `static Object` | `saveList(javax.faces.context.FacesContext context, Object value)` Saves a List whose elements may implement StateHolder.
    `static Object` | `saveState(PropertyMap map, javax.faces.context.FacesContext context, boolean useStateHolder)` Generic (unoptimized) version of PropertyMap state saving.
    `static Object` | `saveStateHolder(javax.faces.context.FacesContext context, Object value)` Saves an object that may implement StateHolder.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StateUtils

          public StateUtils()

  - ### Method Detail

    - #### checkComponentStateSerialization

          public static boolean checkComponentStateSerialization(javax.faces.context.FacesContext context)

      Returns `true` if components should be checked for serializability when when generating the view's state object.

      By default component state serialization checking is off. It can be enabled by setting the system property `org.apache.myfaces.trinidad.CHECK_STATE_SERIALIZATION` to `all` or, more rarely, adding `component` to the comma-separated list of serialization checks to perform.

      As property serialization checking is expensive, it is usually only enabled after component tree serialization checking has detected a problem. In addition, since component serialization checking only detects the problem component, it is usually combined with property state serialization checking either by specifying `all`.

      Returns:
      See Also:
        `checkComponentTreeStateSerialization(javax.faces.context.FacesContext)`

    - #### checkComponentTreeStateSerialization

          public static boolean checkComponentTreeStateSerialization(javax.faces.context.FacesContext context)

      Returns `true` if the component tree should be checked for serializability when when generating the view's state object.

      By default component tree state serialization checking is off. It can be enabled by setting the system property `org.apache.myfaces.trinidad.CHECK_STATE_SERIALIZATION` to `all` or, more commonly, adding `tree` to the comma-separated list of serialization checks to perform.

      Because unserializable objects defeat fail-over, it is important to check for serializability when testing applications. While component tree state serializability checking isn't cheap, it is much faster to initially only enable checking of the component tree and then switch to `all` testing to determine the problem component and property when the component tree testing determines a problem.

      Returns:
      See Also:
        `checkComponentStateSerialization(javax.faces.context.FacesContext)`

    - #### checkSessionSerialization

          public static boolean checkSessionSerialization(javax.faces.context.ExternalContext extContext)

      Returns `true` if Object written to the ExternalContext's Session Map should be checked for Serializability when `put` is called.

      Configuring this property allows this aspect of high-availability to be tested without configuring the server to run in high-availability mode.

      By default session serialization checking is off. It can be enabled by setting the system property `org.apache.myfaces.trinidad.CHECK_STATE_SERIALIZATION` to `all` or, more commonly, adding `session` to the comma-separated list of serialization checks to perform.

      Returns:
      See Also:
        `checkComponentStateSerialization(javax.faces.context.FacesContext)`, `checkComponentTreeStateSerialization(javax.faces.context.FacesContext)`, `checkApplicationSerialization(javax.faces.context.ExternalContext)`, `checkManagedBeanMutation(javax.faces.context.ExternalContext)`

    - #### checkApplicationSerialization

          public static boolean checkApplicationSerialization(javax.faces.context.ExternalContext extContext)

      Returns `true` if Object written to the ExternalContext's Application Map should be checked for Serializability when `put` is called.

      Configuring this property allows this aspect of high-availability to be tested without configuring the server to run in high-availability mode.

      By default application serialization checking is off. It can be enabled by setting the system property `org.apache.myfaces.trinidad.CHECK_STATE_SERIALIZATION` to `all` or, more commonly, adding `application` to the comma-separated list of serialization checks to perform.

      Returns:
      See Also:
        `checkComponentStateSerialization(javax.faces.context.FacesContext)`, `checkComponentTreeStateSerialization(javax.faces.context.FacesContext)`, `checkSessionSerialization(javax.faces.context.ExternalContext)`, `checkManagedBeanMutation(javax.faces.context.ExternalContext)`

    - #### checkManagedBeanMutation

          public static boolean checkManagedBeanMutation(javax.faces.context.ExternalContext extContext)

      Returns `true` if the attributes of the session and application Maps should be checked for cases where the attribute was mutated but not dirtied for failover. If `checkSessionSerialization` returns `true`, the contents of the Session should be checked. If `checkApplicationSerialization` returns `true`, the Serializable content of the Application should be checked.
      Returns:
        true if the contents of scopes should be checked for mutation without dirtying.
      See Also:
        `checkApplicationSerialization(javax.faces.context.ExternalContext)`, `checkSessionSerialization(javax.faces.context.ExternalContext)`

    - #### checkScopesAtEndOfRequest

          public static boolean checkScopesAtEndOfRequest(javax.faces.context.ExternalContext extContext)

      Returns `true` if all attributes in the session Map should be checked for serializability at the end of each request. This check should only be performed if `checkSessionSerialization` also returns `true`.
      See Also:
        `checkSessionSerialization(javax.faces.context.ExternalContext)`

    - #### saveKey

          public static Object saveKey(PropertyKey key)

      Persists a property key.

    - #### restoreKey

          public static PropertyKey restoreKey(FacesBean.Type type,
                               Object value)

      Restores a persisted PropertyKey.

    - #### saveState

          public static Object saveState(PropertyMap map,
                         javax.faces.context.FacesContext context,
                         boolean useStateHolder)

      Generic (unoptimized) version of PropertyMap state saving.

    - #### restoreState

          public static void restoreState(PropertyMap map,
                          javax.faces.context.FacesContext context,
                          FacesBean.Type type,
                          Object state,
                          boolean useStateHolder)

      Generic (unoptimized) version of PropertyMap state restoring.

    - #### saveStateHolder

          public static Object saveStateHolder(javax.faces.context.FacesContext context,
                               Object value)

      Saves an object that may implement StateHolder.

    - #### restoreStateHolder

          public static Object restoreStateHolder(javax.faces.context.FacesContext context,
                                  Object savedValue)

      Restores an object that was saved using saveStateHolder()

    - #### saveList

          public static Object saveList(javax.faces.context.FacesContext context,
                        Object value)

      Saves a List whose elements may implement StateHolder.

    - #### restoreList

          public static Object restoreList(javax.faces.context.FacesContext context,
                           Object savedValue)

      Restores a List whose elements may implement StateHolder.

Copyright © 2001-2017 The Apache Software Foundation. All Rights Reserved.