001/* 002 * Copyright 2002-2017 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.bind.support; 018 019import org.springframework.lang.Nullable; 020import org.springframework.web.context.request.WebRequest; 021 022/** 023 * Strategy interface for storing model attributes in a backend session. 024 * 025 * @author Juergen Hoeller 026 * @since 2.5 027 * @see org.springframework.web.bind.annotation.SessionAttributes 028 */ 029public interface SessionAttributeStore { 030 031 /** 032 * Store the supplied attribute in the backend session. 033 * <p>Can be called for new attributes as well as for existing attributes. 034 * In the latter case, this signals that the attribute value may have been modified. 035 * @param request the current request 036 * @param attributeName the name of the attribute 037 * @param attributeValue the attribute value to store 038 */ 039 void storeAttribute(WebRequest request, String attributeName, Object attributeValue); 040 041 /** 042 * Retrieve the specified attribute from the backend session. 043 * <p>This will typically be called with the expectation that the 044 * attribute is already present, with an exception to be thrown 045 * if this method returns {@code null}. 046 * @param request the current request 047 * @param attributeName the name of the attribute 048 * @return the current attribute value, or {@code null} if none 049 */ 050 @Nullable 051 Object retrieveAttribute(WebRequest request, String attributeName); 052 053 /** 054 * Clean up the specified attribute in the backend session. 055 * <p>Indicates that the attribute name will not be used anymore. 056 * @param request the current request 057 * @param attributeName the name of the attribute 058 */ 059 void cleanupAttribute(WebRequest request, String attributeName); 060 061}