Top Description Fields Constructors Methods
org.springframework.web.servlet.support

public abstract Class AbstractFlashMapManager

extends Object
implements FlashMapManager
Class Inheritance
All Implemented Interfaces
org.springframework.web.servlet.FlashMapManager
Known Direct Subclasses
org.springframework.web.servlet.support.SessionFlashMapManager
Imports
java.util.ArrayList, .Collections, .List, .Map, java.util.concurrent.CopyOnWriteArrayList, jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, org.apache.commons.logging.Log, .LogFactory, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, .MultiValueMap, .StringUtils, org.springframework.web.servlet.FlashMap, .FlashMapManager, org.springframework.web.util.UrlPathHelper

A base class for FlashMapManager implementations.
Authors
Rossen Stoyanchev, Juergen Hoeller, Sam Brannen
Since
3.1.1

Field Summary

Modifier and TypeField and Description
private static final Object
private int
protected final Log
private UrlPathHelper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private String
private List<FlashMap>
getExpiredFlashMaps(List<FlashMap> allMaps)

Return a list of expired FlashMap instances contained in the given list.

protected Object

Returns:

the mutex to use (may be null if none applicable)
getFlashMapsMutex
(HttpServletRequest
the current request
request
)

Obtain a mutex for modifying the FlashMap List as handled by retrieveFlashMaps and updateFlashMaps,

The default implementation returns a shared static mutex.

public int
getFlashMapTimeout()

Return the amount of time in seconds before a FlashMap expires.

private FlashMap

Returns:

a matching FlashMap or null
getMatchingFlashMap
(List<FlashMap> allMaps, HttpServletRequest request)

Return a FlashMap contained in the given list that matches the request.

private MultiValueMap<String, String>
public UrlPathHelper
getUrlPathHelper()

Return the UrlPathHelper implementation to use.

protected boolean
isFlashMapForRequest(FlashMap flashMap, HttpServletRequest request)

Whether the given FlashMap matches the current request.

public final FlashMap
retrieveAndUpdate(HttpServletRequest
the current request
request
,
HttpServletResponse
the current response
response
)

Implements org.springframework.web.servlet.FlashMapManager.retrieveAndUpdate.

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 List<FlashMap>

Returns:

a List with FlashMap instances, or null if none found
retrieveFlashMaps
(HttpServletRequest
the current request
request
)

Retrieve saved FlashMap instances from the underlying storage.

public final void
saveOutputFlashMap(FlashMap
the FlashMap to save
flashMap
,
HttpServletRequest
the current request
request
,
HttpServletResponse
the current response
response
)

Implements org.springframework.web.servlet.FlashMapManager.saveOutputFlashMap.

Save the given FlashMap, in some underlying storage and set the start of its expiration period.

public void
setFlashMapTimeout(int flashMapTimeout)

Set the amount of time in seconds after a FlashMap is saved (at request completion) and before it expires.

public void
setUrlPathHelper(UrlPathHelper urlPathHelper)

Set the UrlPathHelper to use to match FlashMap instances to requests.

protected abstract void
updateFlashMaps(List<FlashMap>
a (potentially empty) list of FlashMap instances to save
flashMaps
,
HttpServletRequest
the current request
request
,
HttpServletResponse
the current response
response
)

Update the FlashMap instances in the underlying storage.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_FLASH_MAPS_MUTEXback to summary
private static final Object DEFAULT_FLASH_MAPS_MUTEX
flashMapTimeoutback to summary
private int flashMapTimeout
loggerback to summary
protected final Log logger
urlPathHelperback to summary
private UrlPathHelper urlPathHelper

Constructor Detail

AbstractFlashMapManagerback to summary
public AbstractFlashMapManager()

Method Detail

decodeAndNormalizePathback to summary
private String decodeAndNormalizePath(String path, HttpServletRequest request)
Annotations
@Nullable
getExpiredFlashMapsback to summary
private List<FlashMap> getExpiredFlashMaps(List<FlashMap> allMaps)

Return a list of expired FlashMap instances contained in the given list.

getFlashMapsMutexback to summary
protected Object getFlashMapsMutex(HttpServletRequest request)

Obtain a mutex for modifying the FlashMap List as handled by retrieveFlashMaps and updateFlashMaps,

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.

Parameters
request:HttpServletRequest

the current request

Returns:Object

the mutex to use (may be null if none applicable)

Annotations
@Nullable
Since
4.0.3
getFlashMapTimeoutback to summary
public int getFlashMapTimeout()

Return the amount of time in seconds before a FlashMap expires.

getMatchingFlashMapback to summary
private FlashMap getMatchingFlashMap(List<FlashMap> allMaps, HttpServletRequest request)

Return a FlashMap contained in the given list that matches the request.

Returns:FlashMap

a matching FlashMap or null

Annotations
@Nullable
getOriginatingRequestParamsback to summary
private MultiValueMap<String, String> getOriginatingRequestParams(HttpServletRequest request)
getUrlPathHelperback to summary
public UrlPathHelper getUrlPathHelper()

Return the UrlPathHelper implementation to use.

isFlashMapForRequestback to summary
protected boolean isFlashMapForRequest(FlashMap flashMap, HttpServletRequest request)

Whether the given FlashMap matches the current request. Uses the expected request path and query parameters saved in the FlashMap.

retrieveAndUpdateback to summary
public final FlashMap retrieveAndUpdate(HttpServletRequest request, HttpServletResponse response)

Implements org.springframework.web.servlet.FlashMapManager.retrieveAndUpdate.

Doc from org.springframework.web.servlet.FlashMapManager.retrieveAndUpdate.

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.

This method is invoked in the beginning of every request in contrast to saveOutputFlashMap, which is invoked only when there are flash attributes to be saved - i.e. before a redirect.

Parameters
request:HttpServletRequest

the current request

response:HttpServletResponse

the current response

Returns:FlashMap

a FlashMap matching the current request or null

Annotations
@Override
@Nullable
retrieveFlashMapsback to summary
protected abstract List<FlashMap> retrieveFlashMaps(HttpServletRequest request)

Retrieve saved FlashMap instances from the underlying storage.

Parameters
request:HttpServletRequest

the current request

Returns:List<FlashMap>

a List with FlashMap instances, or null if none found

Annotations
@Nullable
saveOutputFlashMapback to summary
public final void saveOutputFlashMap(FlashMap flashMap, HttpServletRequest request, HttpServletResponse response)

Implements org.springframework.web.servlet.FlashMapManager.saveOutputFlashMap.

Doc from org.springframework.web.servlet.FlashMapManager.saveOutputFlashMap.

Save the given FlashMap, in some underlying storage and set the start of its expiration period.

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.

Parameters
flashMap:FlashMap

the FlashMap to save

request:HttpServletRequest

the current request

response:HttpServletResponse

the current response

Annotations
@Override
setFlashMapTimeoutback to summary
public void setFlashMapTimeout(int flashMapTimeout)

Set the amount of time in seconds after a FlashMap is saved (at request completion) and before it expires.

The default value is 180 seconds.

setUrlPathHelperback to summary
public void setUrlPathHelper(UrlPathHelper urlPathHelper)

Set the UrlPathHelper to use to match FlashMap instances to requests.

updateFlashMapsback to summary
protected abstract void updateFlashMaps(List<FlashMap> flashMaps, HttpServletRequest request, HttpServletResponse response)

Update the FlashMap instances in the underlying storage.

Parameters
flashMaps:List<FlashMap>

a (potentially empty) list of FlashMap instances to save

request:HttpServletRequest

the current request

response:HttpServletResponse

the current response