Class AbstractFlashMapManager

java.lang.Object
com.aspectran.core.activity.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:
8.4.0
  • 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.
    • retrieveAndUpdate

      @Nullable public final FlashMap retrieveAndUpdate(Translet translet)
      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.saveFlashMap(com.aspectran.core.activity.Translet), which is invoked only when there are flash attributes to be saved - i.e. before a redirect.

      Specified by:
      retrieveAndUpdate in interface FlashMapManager
      Parameters:
      translet - the current translet
      Returns:
      a FlashMap matching the current request or null
    • isFlashMapForRequest

      protected boolean isFlashMapForRequest(@NonNull FlashMap flashMap, Translet translet)
      Whether the given FlashMap matches the current request. Uses the expected request path and query parameters saved in the FlashMap.
    • saveFlashMap

      public final void saveFlashMap(@NonNull Translet translet)
      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:
      saveFlashMap in interface FlashMapManager
      Parameters:
      translet - the current translet
    • retrieveFlashMaps

      @Nullable protected abstract List<FlashMap> retrieveFlashMaps(Translet translet)
      Retrieve saved FlashMap instances from the underlying storage.
      Parameters:
      translet - the current translet
      Returns:
      a List with FlashMap instances, or null if none found
    • updateFlashMaps

      protected abstract void updateFlashMaps(List<FlashMap> flashMaps, Translet translet)
      Update the FlashMap instances in the underlying storage.
      Parameters:
      flashMaps - a (potentially empty) list of FlashMap instances to save
      translet - the current translet
    • getFlashMapsMutex

      @Nullable protected Object getFlashMapsMutex(Translet translet)
      Obtain a mutex for modifying the FlashMap List as handled by retrieveFlashMaps(com.aspectran.core.activity.Translet) and updateFlashMaps(java.util.List<com.aspectran.core.activity.FlashMap>, com.aspectran.core.activity.Translet),

      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:
      translet - the current translet
      Returns:
      the mutex to use (may be null if none applicable)
      Since:
      4.0.3