View Javadoc
1   /*
2    * Copyright 2002-2012 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.web.bind.support;
18  
19  import org.springframework.web.context.request.WebRequest;
20  
21  /**
22   * Strategy interface for storing model attributes in a backend session.
23   *
24   * @author Juergen Hoeller
25   * @since 2.5
26   * @see org.springframework.web.bind.annotation.SessionAttributes
27   */
28  public interface SessionAttributeStore {
29  
30  	/**
31  	 * Store the supplied attribute in the backend session.
32  	 * <p>Can be called for new attributes as well as for existing attributes.
33  	 * In the latter case, this signals that the attribute value may have been modified.
34  	 * @param request the current request
35  	 * @param attributeName the name of the attribute
36  	 * @param attributeValue the attribute value to store
37  	 */
38  	void storeAttribute(WebRequest request, String attributeName, Object attributeValue);
39  
40  	/**
41  	 * Retrieve the specified attribute from the backend session.
42  	 * <p>This will typically be called with the expectation that the
43  	 * attribute is already present, with an exception to be thrown
44  	 * if this method returns {@code null}.
45  	 * @param request the current request
46  	 * @param attributeName the name of the attribute
47  	 * @return the current attribute value, or {@code null} if none
48  	 */
49  	Object retrieveAttribute(WebRequest request, String attributeName);
50  
51  	/**
52  	 * Clean up the specified attribute in the backend session.
53  	 * <p>Indicates that the attribute name will not be used anymore.
54  	 * @param request the current request
55  	 * @param attributeName the name of the attribute
56  	 */
57  	void cleanupAttribute(WebRequest request, String attributeName);
58  
59  }