Package org.springframework.web.servlet.support

# Class AbstractFlashMapManager

java.lang.Object
org.springframework.web.servlet.support.AbstractFlashMapManager

All Implemented Interfaces:
  `FlashMapManager`

Direct Known Subclasses:
  `SessionFlashMapManager`

public abstract class AbstractFlashMapManager extends Object implements FlashMapManager
A base class for `FlashMapManager` implementations.

Since:
  3.1.1
Author:
  Rossen Stoyanchev, Juergen Hoeller, Sam Brannen

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final org.apache.commons.logging.Log`
`logger`

## Constructor Summary

Constructors
Constructor
Description
`AbstractFlashMapManager()`

## Method Summary

Modifier and Type
Method
Description
`protected Object`
`getFlashMapsMutex(HttpServletRequest request)`
Obtain a mutex for modifying the FlashMap List as handled by `retrieveFlashMaps(jakarta.servlet.http.HttpServletRequest)` and `updateFlashMaps(java.util.List<org.springframework.web.servlet.FlashMap>, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse)`,
`int`
`getFlashMapTimeout()`
Return the amount of time in seconds before a FlashMap expires.
`org.springframework.web.util.UrlPathHelper`
`getUrlPathHelper()`
Return the UrlPathHelper implementation to use.
`protected boolean`
`isFlashMapForRequest(FlashMap flashMap, HttpServletRequest request)`
Whether the given FlashMap matches the current request.
`final 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 List<FlashMap>`
`retrieveFlashMaps(HttpServletRequest request)`
Retrieve saved FlashMap instances from the underlying storage.
`final 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(org.springframework.web.util.UrlPathHelper urlPathHelper)`
Set the UrlPathHelper to use to match FlashMap instances to requests.
`protected abstract void`
`updateFlashMaps(List<FlashMap> flashMaps, HttpServletRequest request, HttpServletResponse response)`
Update the FlashMap instances in the underlying storage.

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

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

## Field Details

### logger

protected final org.apache.commons.logging.Log logger

## Constructor Details

### AbstractFlashMapManager

public AbstractFlashMapManager()

## Method Details

### setFlashMapTimeout

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.

### getFlashMapTimeout

public int getFlashMapTimeout()
Return the amount of time in seconds before a FlashMap expires.

### setUrlPathHelper

public void setUrlPathHelper(org.springframework.web.util.UrlPathHelper urlPathHelper)
Set the UrlPathHelper to use to match FlashMap instances to requests.

### getUrlPathHelper

public org.springframework.web.util.UrlPathHelper getUrlPathHelper()
Return the UrlPathHelper implementation to use.

### retrieveAndUpdate

@Nullable public final FlashMap retrieveAndUpdate(HttpServletRequest request, HttpServletResponse response)
Description copied from interface: `FlashMapManager`
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 `FlashMapManager.saveOutputFlashMap(org.springframework.web.servlet.FlashMap, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse)`, which is invoked only when there are flash attributes to be saved - i.e. before a redirect.

Specified by:
  `retrieveAndUpdate` in interface `FlashMapManager`
Parameters:
  `request` - the current request
  `response` - the current response
Returns:
  a FlashMap matching the current request or `null`

### isFlashMapForRequest

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.

### saveOutputFlashMap

public final void saveOutputFlashMap(FlashMap flashMap, HttpServletRequest request, HttpServletResponse response)
Description copied from interface: `FlashMapManager`
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.

Specified by:
  `saveOutputFlashMap` in interface `FlashMapManager`
Parameters:
  `flashMap` - the FlashMap to save
  `request` - the current request
  `response` - the current response

### retrieveFlashMaps

@Nullable protected abstract List<FlashMap> retrieveFlashMaps(HttpServletRequest request)
Retrieve saved FlashMap instances from the underlying storage.

Parameters:
  `request` - the current request
Returns:
  a List with FlashMap instances, or `null` if none found

### updateFlashMaps

protected abstract void updateFlashMaps(List<FlashMap> flashMaps, HttpServletRequest request, HttpServletResponse response)
Update the FlashMap instances in the underlying storage.

Parameters:
  `flashMaps` - a (potentially empty) list of FlashMap instances to save
  `request` - the current request
  `response` - the current response

### getFlashMapsMutex

@Nullable protected Object getFlashMapsMutex(HttpServletRequest request)
Obtain a mutex for modifying the FlashMap List as handled by `retrieveFlashMaps(jakarta.servlet.http.HttpServletRequest)` and `updateFlashMaps(java.util.List<org.springframework.web.servlet.FlashMap>, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.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.

Parameters:
  `request` - the current request
Returns:
  the mutex to use (may be `null` if none applicable)
Since:
  4.0.3