001/* 002 * Copyright 2002-2014 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.web.servlet; 018 019import javax.servlet.http.HttpServletRequest; 020import javax.servlet.http.HttpServletResponse; 021 022/** 023 * A strategy interface for retrieving and saving FlashMap instances. 024 * See {@link FlashMap} for a general overview of flash attributes. 025 * 026 * @author Rossen Stoyanchev 027 * @since 3.1 028 * @see FlashMap 029 */ 030public interface FlashMapManager { 031 032 /** 033 * Find a FlashMap saved by a previous request that matches to the current 034 * request, remove it from underlying storage, and also remove other 035 * expired FlashMap instances. 036 * <p>This method is invoked in the beginning of every request in contrast 037 * to {@link #saveOutputFlashMap}, which is invoked only when there are 038 * flash attributes to be saved - i.e. before a redirect. 039 * @param request the current request 040 * @param response the current response 041 * @return a FlashMap matching the current request or {@code null} 042 */ 043 FlashMap retrieveAndUpdate(HttpServletRequest request, HttpServletResponse response); 044 045 /** 046 * Save the given FlashMap, in some underlying storage and set the start 047 * of its expiration period. 048 * <p><strong>NOTE:</strong> Invoke this method prior to a redirect in order 049 * to allow saving the FlashMap in the HTTP session or in a response 050 * cookie before the response is committed. 051 * @param flashMap the FlashMap to save 052 * @param request the current request 053 * @param response the current response 054 */ 055 void saveOutputFlashMap(FlashMap flashMap, HttpServletRequest request, HttpServletResponse response); 056 057}