1 /*
2 * Copyright 2009-2010 Capgemini
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package net.sourceforge.statelessfilter.session;
17
18 import java.io.Serializable;
19 import java.util.Map;
20 import java.util.concurrent.ConcurrentHashMap;
21
22 import net.sourceforge.statelessfilter.backend.ISessionData;
23
24 /**
25 * DTO for session data.
26 *
27 * @author Nicolas Richeton - Capgemini
28 *
29 */
30 public class SessionData implements ISessionData, Serializable {
31 private static final long serialVersionUID = -8150387390531508793L;
32 Map<String, Object> content = new ConcurrentHashMap<String, Object>();
33 long creationTime;
34 String id;
35 long requestId;
36 boolean valid;
37
38 /**
39 * Create a news SessionData object.
40 */
41 public SessionData() {
42 //
43 }
44
45 /**
46 * @see net.sourceforge.statelessfilter.backend.ISessionData#getContent()
47 */
48 public Map<String, Object> getContent() {
49 return content;
50 }
51
52 /**
53 * @see net.sourceforge.statelessfilter.backend.ISessionData#getCreationTime()
54 */
55 public long getCreationTime() {
56 return creationTime;
57 }
58
59 /**
60 * @see net.sourceforge.statelessfilter.backend.ISessionData#getId()
61 */
62 public String getId() {
63 return id;
64 }
65
66 /**
67 * @see net.sourceforge.statelessfilter.backend.ISessionData#getRequestId()
68 */
69 public long getRequestId() {
70 return requestId;
71 }
72
73 /**
74 * @see net.sourceforge.statelessfilter.backend.ISessionData#isValid()
75 */
76 public boolean isValid() {
77 return valid;
78 }
79
80 /**
81 * Set session attributes.
82 *
83 * @param content
84 */
85 public void setContent(Map<String, Object> content) {
86 this.content = new ConcurrentHashMap<String, Object>(content);
87 }
88
89 /**
90 * Set session creation time.
91 *
92 * @param creationTime
93 */
94 public void setCreationTime(long creationTime) {
95 this.creationTime = creationTime;
96 }
97
98 /**
99 * Set sesssion id.
100 *
101 * @param id
102 */
103 public void setId(String id) {
104 this.id = id;
105 }
106
107 /**
108 * Set request id.
109 *
110 * @see ISessionData#getRequestId()
111 * @param requestId
112 */
113 public void setRequestId(long requestId) {
114 this.requestId = requestId;
115 }
116
117 /**
118 * Set session validity.
119 *
120 * @param valid
121 */
122 public void setValid(boolean valid) {
123 this.valid = valid;
124 }
125 }