View Javadoc
1   /* 
2    * Licensed under the Apache License, Version 2.0 (the "License");
3    * you may not use this file except in compliance with the License.
4    * You may obtain a copy of the License at
5    *
6    * http://www.apache.org/licenses/LICENSE-2.0
7    *
8    * Unless required by applicable law or agreed to in writing, software
9    * distributed under the License is distributed on an "AS IS" BASIS,
10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11   * See the License for the specific language governing permissions and
12   * limitations under the License.
13   *
14   */
15  
16  package org.esigate.api;
17  
18  import java.io.Serializable;
19  
20  /**
21   * The session can be used to store objects available successibe several http interactions.
22   * 
23   * @author Francois-Xavier Bonnet
24   * 
25   */
26  public interface Session {
27  
28      /**
29       * Stores an object that can be reused across successive http requests from the same user. Implementations can
30       * decide to store the objects serialized in a cookie on the client side or server side with some session tracking
31       * mechanism.
32       * 
33       * @param key
34       *            the key
35       * @param value
36       *            obejct to store
37       */
38      void setAttribute(String key, Serializable value);
39  
40      /**
41       * Retrieves an Object previously stored with method @see #setSessionAttribute(String, Serializable) or
42       * <code>null</code>.
43       * 
44       * @param key
45       *            the key
46       * @return the previously stored object or <code>null</code>
47       */
48      Serializable getAttribute(String key);
49  
50  }