Example usage for org.springframework.web.servlet FlashMap startExpirationPeriod

List of usage examples for org.springframework.web.servlet FlashMap startExpirationPeriod

Introduction

In this page you can find the example usage for org.springframework.web.servlet FlashMap startExpirationPeriod.

Prototype

public void startExpirationPeriod(int timeToLive) 

Source Link

Document

Start the expiration period for this instance.

Usage

From source file:org.springframework.web.servlet.support.AbstractFlashMapManager.java

@Override
public final void saveOutputFlashMap(FlashMap flashMap, HttpServletRequest request,
        HttpServletResponse response) {//w  w w.j  ava2  s. com
    if (CollectionUtils.isEmpty(flashMap)) {
        return;
    }

    String path = decodeAndNormalizePath(flashMap.getTargetRequestPath(), request);
    flashMap.setTargetRequestPath(path);

    if (logger.isDebugEnabled()) {
        logger.debug("Saving FlashMap=" + flashMap);
    }
    flashMap.startExpirationPeriod(getFlashMapTimeout());

    Object mutex = getFlashMapsMutex(request);
    if (mutex != null) {
        synchronized (mutex) {
            List<FlashMap> allFlashMaps = retrieveFlashMaps(request);
            allFlashMaps = (allFlashMaps != null ? allFlashMaps : new CopyOnWriteArrayList<>());
            allFlashMaps.add(flashMap);
            updateFlashMaps(allFlashMaps, request, response);
        }
    } else {
        List<FlashMap> allFlashMaps = retrieveFlashMaps(request);
        allFlashMaps = (allFlashMaps != null ? allFlashMaps : new LinkedList<>());
        allFlashMaps.add(flashMap);
        updateFlashMaps(allFlashMaps, request, response);
    }
}

From source file:org.springframework.web.servlet.support.DefaultFlashMapManager.java

/**
 * Update a FlashMap before it is stored in the HTTP Session.
 * <p>The default implementation starts the expiration period and ensures the
 * target request path is decoded and normalized if it is relative. 
 * @param flashMap the flash map to be saved
 * @param request the current request//w  w w.j av a 2 s. com
 */
protected void onSaveFlashMap(FlashMap flashMap, HttpServletRequest request) {
    String targetPath = flashMap.getTargetRequestPath();
    flashMap.setTargetRequestPath(decodeAndNormalizePath(targetPath, request));
    flashMap.startExpirationPeriod(this.flashTimeout);
}