How this implementation works
This class is an application singleton. It has one ivar, innerMap. Entries are added to and removed from this map as needed according to how the flash scope is defined in the spec. This implementation never touches the session, nor does it cause the session to be created.
Most of the hairy logic is encapsulated with in the inner class PreviousNextFlashInfoManager. An instance of this class is obtained by calling one of the variants of getCurrentFlashManager(). When the instance is no longer needed for this request, call releaseCurrentFlashManager().
Two very important methods are getPhaseMapForWriting() and getPhaseMapForReading(). These methods are the basis for the Map implementation methods. Methods that need to write to the map use getPhaseMapForWriting(), those that need to read use getPhaseMapForReading(). These methods allow for the laziness that allows us to only incur a cost when the flash is actually written to.
The operation of this class is intimately tied to the request processing lifecycle. Let's break down every run thru the request processing lifecycle into two parts called "previous" and "next". We use the names "previous" and "next" to indicate the persistence and timing of the data that is stored in the flash. Consider two runs through the requset processing lifecle: N and N+1. On request N, there is no "previous" request. On Request N, any writes to the flash that happen during RENDER RESPONSE go to the "next" flash map. This means they are available for the ENTIRE run though the request processing lifecycle on request N+1. Any entries put into the "next" flash map on request N will be expired at the end of request N+1. Now, when we get into request N+1 what was considered "next" on request N, is now called "previous" from the perspective of request N+1. Any reads from the flash during request N+1 come from the "previous" map. Any writes to the flash before RENDER RESPONSE go to the "previous" map. Any writes to the flash during RENDER RESPNOSE go to the "next" map.
| Modifier and Type | Class and Description |
|---|---|
| private static enum | |
| private static class | ELFlash.FlashInfo
Encapsulate one of the two maps that back the flash for the current request. |
| private static enum | |
| private static class | ELFlash.PreviousNextFlashInfoManager
On any given request, there are actually two maps behind the flash. |
| Modifier and Type | Field and Description |
|---|---|
| public static final String | |
| private final boolean | |
| private static final String | |
| pack-priv static final String | FLASH_ATTRIBUTE_NAME
This constant is used as the key in the application map that stores the singleton ELFlash instance. |
| pack-priv static final String | FLASH_COOKIE_NAME
This constant is used as the name of the cookie sent to the client. |
| pack-priv static final String | FLASH_NOW_REQUEST_KEY
This constant is used as the key the request map used, in the FlashELResolver, to convey the name of the property being accessed via 'now'. |
| private Map | flashInnerMap
Keys in this map are the string version of sequence numbers
obtained via calls to |
| private ByteArrayGuardAESCTR | |
| private static final Logger | |
| private int | |
| private long | |
| pack-priv static final String | PREFIX
These constants are referenced from other source files in this package. |
| private final AtomicLong |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Implements java. |
| pack-priv void | |
| protected Object | |
| public boolean | containsKey(Object
key whose presence in this map is to be tested key)Implements java. true if this map contains a mapping for the specified
key.
|
| public boolean | containsValue(Object
value whose presence in this map is to be tested value)Implements java. true if this map maps one or more keys to the
specified value.
|
| public void | doLastPhaseActions(FacesContext context, boolean outgoingResponseIsRedirect)
This is the most magic of methods. |
| public void | doPostPhaseActions(FacesContext
the context)FacesContext for this request.Implements abstract javax. Called after the execution of every lifecycle phase, this method allows implementations to take the necessary actions to provide the Flash scope contract as it applies to the request procesing lifecycle. |
| public void | doPrePhaseActions(FacesContext
the context)FacesContext for this request.Implements abstract javax. Called before the execution of every lifecycle phase, this method allows implementations to take the necessary actions to provide the Flash scope contract as it applies to the request procesing lifecycle. |
| public Set | entrySet()
Implements java. Set view of the mappings contained in this map.
|
| public Object | get(Object
the key whose associated value is to be returned key)Implements java. null if this map contains no mapping for the key.
|
| private Cookie | |
| private ELFlash. | getCurrentFlashManager(Map<Object, Object> contextMap, boolean create)
Called when you need to get access to the flashManager. |
| private ELFlash. | getCurrentFlashManager(FacesContext context, Map<Object, Object> contextMap, Cookie cookie)
Called on the preRestoreView phase if the browser sent us a cookie. |
| public static Map | |
| pack-priv static ELFlash | Returns: The flashMap for this session.the extContext, boolean ExternalContext for this request.true to create a new instance for this request if
necessary; false to return null if there's no
instance in the current session.
|
| pack-priv Map | |
| private static String | |
| private long | |
| private Map | |
| private Map | getPhaseMapForWriting()
If the current phase is earlier than RENDER_RESPONSE, return the map for the "previous" request. |
| public boolean | |
| pack-priv boolean | |
| public boolean | isKeepMessages()
Implements abstract javax. Return the value of this JavaBeans property for the flash for this session. |
| public boolean | isRedirect()
Implements abstract javax. Return the value of this property for the flash for this session. |
| public void | keep(String
if argument key)key is the name of an entry
previously stored to the flash on this traversal through the
lifecycle via a call to putNow, or to a set to the EL
expression #{flash.now.<key>}, or to the
request Map, to be promoted to the flash as if a call
to put() or a set to the expression
#{flash.<key>} was being called.Implements abstract javax. Causes a value stored with a
previous call to |
| public Set | |
| private Map | |
| private Map | |
| private void | |
| public Object | put(String
key with which the specified value is to be associated key, Object value to be associated with the specified key value)Implements java. |
| public void | putAll(Map<? extends String, ?>
mappings to be stored in this map t)Implements java. |
| public void | putNow(String
the key for this entry key, Object the value for this entry value)Implements abstract javax. Puts a value in the flash so that it can be accessed on this traversal of the lifecycle, rather than on the next traversal. |
| private void | |
| private void | |
| public Object | remove(Object
key whose mapping is to be removed from the map key)Implements java. |
| private void | |
| private boolean | |
| pack-priv void | |
| pack-priv void | |
| private void | setCookie(FacesContext context, ELFlash.
Set the cookie iff the response was not yet committed. |
| pack-priv void | |
| pack-priv static void | |
| public void | setKeepMessages(boolean
the new value for this property on this session. newValue)Implements abstract javax. Setter for |
| public void | setRedirect(boolean
the new value for this property on this session. newValue)Implements abstract javax. Setting this property to
|
| public int | |
| public String | |
| public Collection | values()
Implements java. Collection view of the values contained in this map.
|