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 022import org.springframework.lang.Nullable; 023 024/** 025 * A strategy interface for retrieving and saving FlashMap instances. 026 * See {@link FlashMap} for a general overview of flash attributes. 027 * 028 * @author Rossen Stoyanchev 029 * @since 3.1 030 * @see FlashMap 031 */ 032public interface FlashMapManager { 033 034 /** 035 * Find a FlashMap saved by a previous request that matches to the current 036 * request, remove it from underlying storage, and also remove other 037 * expired FlashMap instances. 038 * <p>This method is invoked in the beginning of every request in contrast 039 * to {@link #saveOutputFlashMap}, which is invoked only when there are 040 * flash attributes to be saved - i.e. before a redirect. 041 * @param request the current request 042 * @param response the current response 043 * @return a FlashMap matching the current request or {@code null} 044 */ 045 @Nullable 046 FlashMap retrieveAndUpdate(HttpServletRequest request, HttpServletResponse response); 047 048 /** 049 * Save the given FlashMap, in some underlying storage and set the start 050 * of its expiration period. 051 * <p><strong>NOTE:</strong> Invoke this method prior to a redirect in order 052 * to allow saving the FlashMap in the HTTP session or in a response 053 * cookie before the response is committed. 054 * @param flashMap the FlashMap to save 055 * @param request the current request 056 * @param response the current response 057 */ 058 void saveOutputFlashMap(FlashMap flashMap, HttpServletRequest request, HttpServletResponse response); 059 060}