View Javadoc

1   /*
2    * Copyright (c) 2005-2007 Creative Sphere Limited.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *
10   *   Creative Sphere - initial API and implementation
11   *
12   */
13  package org.abstracthorizon.danube.http.session;
14  
15  import java.util.HashMap;
16  import java.util.Map;
17  
18  /**
19   * Simple session object
20   *
21   * @author Daniel Sendula
22   */
23  public class Session {
24  
25      /** Session attributes */
26      protected Map<String, Object> attributes = new HashMap<String, Object>();
27  
28      /** Time when session is accessed */
29      protected long lastAccessed;
30  
31      /** Session id */
32      protected String sessionId;
33  
34      /**
35       * Constructor
36       * @param sessionId session id
37       */
38      public Session(String sessionId) {
39          this.sessionId = sessionId;
40      }
41  
42      /**
43       * Returns session id
44       * @return session id
45       */
46      public String getSessionId() {
47          return sessionId;
48      }
49  
50      /**
51       * Returns session attributes
52       * @return session attributes
53       */
54      public Map<String, Object> getAttributes() {
55          return attributes;
56      }
57  
58      /**
59       * Returns value of {{@link #lastAccessed } field.
60       * @return value of {{@link #lastAccessed } field.
61       */
62      public long getLastAccessed() {
63          return lastAccessed;
64      }
65  
66      /**
67       * Sets {@link #lastAccessed} field to current time.
68       */
69      protected void resetAccess() {
70          lastAccessed = System.currentTimeMillis();
71      }
72  
73  }