For Trinidad-1856, I would like to add the following public apis:

New apis:

on org.apache.myfaces.trinidad.bean.util.StateUtils:
 /**
  * Returns <code>true</code> 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
  * <code>checkSessionSerialization</code> returns <code>true</code>, the 
contents of the
  * Session should be checked.  If <code>checkApplicationSerialization</code> 
returns
  * <code>true</code>, the Serializable content of the Application should be 
checked.
  * @return true if the contents of scopes should be checked for mutation 
without dirtying.
  * @see #checkApplicationSerialization
  * @see #checkSessionSerialization
  */
 public static boolean checkManagedBeanMutation(ExternalContext extContext)
 {
   return _CHECK_MANAGED_BEAN_MUTATATION;
 }

In order to catch mutations to non-HTTP servlet environments we need need to 
wrap the Session and Application Maps.  (for HttpRequests, we wrpa the 
underlying ServletContext and Session objects in order to catch direct 
mutations).  To do so, the following apis are added to

org.apache.myfaces.trinidad.util.CollectionUtils

 /**
  * Interface for trapping mutations to a Map.
  * @param <K> the type of the keys of the Map that MapMutationHooks are 
associated with
  * @param <V> the type of the values of the Map that MapMutationHooks are 
associated with
  * @see #newMutationHookedMap
  */
 public interface MapMutationHooks<K, V>
 {
   /**
    * Called when the associated Map of the MapMutationHooks is written to
    * @param key   key of entry that has changed
    * @param value value of entry that has changed
    */
   public void writeNotify(K key, V value);

   /**
    * Called when an entry is removed from the associated Map of the 
MapMutationHooks
    * @param key   key of entry that has been removed
    */
   public void removeNotify(Object key);
 }

 /**
  * Creates a new Map that informs the MapMutationHooks of any direct 
mutations.  Mutations to
  * the underlying Map will not be caught.
  * If the base map is Serializable, the returned Map will be Serializable
  * @param <K> type of the keys of the Map
  * @param <V> type of the values of the Map
  * @param map Underlying map to trap mutations of
  * @param hooks MapMutationHooks to inform of mutations to the returned Map
  * @return a new Map that traps the mutations to the underlying Map
  * @throws NullPointerException if map or hooks are null
  */
 public static <K,V> Map<K, V> newMutationHookedMap(Map<K, V> map, 
MapMutationHooks<K, V> hooks)

The JIRA contains more information about the purpose.

-- Blake Sullivan

Reply via email to