public abstract class AbstractFlashMapManager extends java.lang.Object implements FlashMapManager
FlashMapManager
implementations.Modifier and Type | Field and Description |
---|---|
private static java.lang.Object |
DEFAULT_FLASH_MAPS_MUTEX |
private int |
flashMapTimeout |
protected Log |
logger |
private UrlPathHelper |
urlPathHelper |
Constructor and Description |
---|
AbstractFlashMapManager() |
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
decodeAndNormalizePath(java.lang.String path,
HttpServletRequest request) |
private java.util.List<FlashMap> |
getExpiredFlashMaps(java.util.List<FlashMap> allMaps)
Return a list of expired FlashMap instances contained in the given list.
|
protected java.lang.Object |
getFlashMapsMutex(HttpServletRequest request)
Obtain a mutex for modifying the FlashMap List as handled by
retrieveFlashMaps(HttpServletRequest) and updateFlashMaps(java.util.List<org.springframework.web.servlet.FlashMap>, HttpServletRequest, HttpServletResponse) , |
int |
getFlashMapTimeout()
Return the amount of time in seconds before a FlashMap expires.
|
private FlashMap |
getMatchingFlashMap(java.util.List<FlashMap> allMaps,
HttpServletRequest request)
Return a FlashMap contained in the given list that matches the request.
|
UrlPathHelper |
getUrlPathHelper()
Return the UrlPathHelper implementation to use.
|
protected boolean |
isFlashMapForRequest(FlashMap flashMap,
HttpServletRequest request)
Whether the given FlashMap matches the current request.
|
FlashMap |
retrieveAndUpdate(HttpServletRequest request,
HttpServletResponse response)
Find a FlashMap saved by a previous request that matches to the current
request, remove it from underlying storage, and also remove other
expired FlashMap instances.
|
protected abstract java.util.List<FlashMap> |
retrieveFlashMaps(HttpServletRequest request)
Retrieve saved FlashMap instances from the underlying storage.
|
void |
saveOutputFlashMap(FlashMap flashMap,
HttpServletRequest request,
HttpServletResponse response)
Save the given FlashMap, in some underlying storage and set the start
of its expiration period.
|
void |
setFlashMapTimeout(int flashMapTimeout)
Set the amount of time in seconds after a
FlashMap is saved
(at request completion) and before it expires. |
void |
setUrlPathHelper(UrlPathHelper urlPathHelper)
Set the UrlPathHelper to use to match FlashMap instances to requests.
|
protected abstract void |
updateFlashMaps(java.util.List<FlashMap> flashMaps,
HttpServletRequest request,
HttpServletResponse response)
Update the FlashMap instances in the underlying storage.
|
private static final java.lang.Object DEFAULT_FLASH_MAPS_MUTEX
protected final Log logger
private int flashMapTimeout
private UrlPathHelper urlPathHelper
public void setFlashMapTimeout(int flashMapTimeout)
FlashMap
is saved
(at request completion) and before it expires.
The default value is 180 seconds.
public int getFlashMapTimeout()
public void setUrlPathHelper(UrlPathHelper urlPathHelper)
public UrlPathHelper getUrlPathHelper()
public final FlashMap retrieveAndUpdate(HttpServletRequest request, HttpServletResponse response)
FlashMapManager
This method is invoked in the beginning of every request in contrast
to FlashMapManager.saveOutputFlashMap(org.springframework.web.servlet.FlashMap, HttpServletRequest, HttpServletResponse)
, which is invoked only when there are
flash attributes to be saved - i.e. before a redirect.
retrieveAndUpdate
in interface FlashMapManager
request
- the current requestresponse
- the current responsenull
private java.util.List<FlashMap> getExpiredFlashMaps(java.util.List<FlashMap> allMaps)
private FlashMap getMatchingFlashMap(java.util.List<FlashMap> allMaps, HttpServletRequest request)
null
protected boolean isFlashMapForRequest(FlashMap flashMap, HttpServletRequest request)
public final void saveOutputFlashMap(FlashMap flashMap, HttpServletRequest request, HttpServletResponse response)
FlashMapManager
NOTE: Invoke this method prior to a redirect in order to allow saving the FlashMap in the HTTP session or in a response cookie before the response is committed.
saveOutputFlashMap
in interface FlashMapManager
flashMap
- the FlashMap to saverequest
- the current requestresponse
- the current responseprivate java.lang.String decodeAndNormalizePath(java.lang.String path, HttpServletRequest request)
protected abstract java.util.List<FlashMap> retrieveFlashMaps(HttpServletRequest request)
request
- the current requestnull
if none foundprotected abstract void updateFlashMaps(java.util.List<FlashMap> flashMaps, HttpServletRequest request, HttpServletResponse response)
flashMaps
- a (potentially empty) list of FlashMap instances to saverequest
- the current requestresponse
- the current responseprotected java.lang.Object getFlashMapsMutex(HttpServletRequest request)
retrieveFlashMaps(HttpServletRequest)
and updateFlashMaps(java.util.List<org.springframework.web.servlet.FlashMap>, HttpServletRequest, HttpServletResponse)
,
The default implementation returns a shared static mutex.
Subclasses are encouraged to return a more specific mutex, or
null
to indicate that no synchronization is necessary.
request
- the current requestnull
if none applicable)