1
2
3
4
5
6
7
8
9
10
11 package psiprobe.model;
12
13 import java.util.ArrayList;
14 import java.util.Date;
15 import java.util.List;
16 import java.util.Locale;
17
18
19
20
21 public class ApplicationSession {
22
23
24 public static final String LAST_ACCESSED_BY_IP = "__psiprobe_la_ip";
25
26
27 public static final String LAST_ACCESSED_LOCALE = "__psiprobe_la_local";
28
29
30 private String id;
31
32
33 private String applicationName;
34
35
36 private Date creationTime;
37
38
39 private Date lastAccessTime;
40
41
42 private int maxIdleTime;
43
44
45 private boolean valid;
46
47
48 private boolean serializable;
49
50
51 private long objectCount;
52
53
54 private String info;
55
56
57 private String managerType;
58
59
60 private List<Attribute> attributes = new ArrayList<>();
61
62
63 private long size;
64
65
66 private boolean allowedToViewValues;
67
68
69 private String lastAccessedIp;
70
71
72 private Locale lastAccessedIpLocale;
73
74
75
76
77
78
79 public String getId() {
80 return id;
81 }
82
83
84
85
86
87
88 public void setId(String id) {
89 this.id = id;
90 }
91
92
93
94
95
96
97 public String getApplicationName() {
98 return applicationName;
99 }
100
101
102
103
104
105
106 public void setApplicationName(String applicationName) {
107 this.applicationName = applicationName;
108 }
109
110
111
112
113
114
115 public Date getCreationTime() {
116 return creationTime == null ? null : new Date(creationTime.getTime());
117 }
118
119
120
121
122
123
124 public void setCreationTime(Date creationTime) {
125 this.creationTime = creationTime == null ? null : new Date(creationTime.getTime());
126 }
127
128
129
130
131
132
133 public Date getLastAccessTime() {
134 return lastAccessTime == null ? null : new Date(lastAccessTime.getTime());
135 }
136
137
138
139
140
141
142 public void setLastAccessTime(Date lastAccessTime) {
143 this.lastAccessTime = lastAccessTime == null ? null : new Date(lastAccessTime.getTime());
144 }
145
146
147
148
149
150
151 public int getMaxIdleTime() {
152 return maxIdleTime;
153 }
154
155
156
157
158
159
160 public void setMaxIdleTime(int maxIdleTime) {
161 this.maxIdleTime = maxIdleTime;
162 }
163
164
165
166
167
168
169 public boolean isValid() {
170 return valid;
171 }
172
173
174
175
176
177
178 public void setValid(boolean valid) {
179 this.valid = valid;
180 }
181
182
183
184
185
186
187 public long getObjectCount() {
188 return objectCount;
189 }
190
191
192
193
194
195
196 public void setObjectCount(long objectCount) {
197 this.objectCount = objectCount;
198 }
199
200
201
202
203
204
205 public List<Attribute> getAttributes() {
206 return attributes;
207 }
208
209
210
211
212
213
214 public void setAttributes(List<Attribute> attributes) {
215 this.attributes = attributes;
216 }
217
218
219
220
221
222
223 public void addAttribute(Attribute sa) {
224 attributes.add(sa);
225 }
226
227
228
229
230
231
232 public String getInfo() {
233 return info;
234 }
235
236
237
238
239
240
241 public void setInfo(String info) {
242 this.info = info;
243 }
244
245
246
247
248
249
250 public String getManagerType() {
251 return managerType;
252 }
253
254
255
256
257
258
259 public void setManagerType(String managerType) {
260 this.managerType = managerType;
261 }
262
263
264
265
266
267
268 public long getAge() {
269 if (creationTime == null) {
270 return 0;
271 }
272 return System.currentTimeMillis() - creationTime.getTime();
273 }
274
275
276
277
278
279
280 public long getIdleTime() {
281 if (lastAccessTime == null) {
282 return getAge();
283 }
284 return System.currentTimeMillis() - lastAccessTime.getTime();
285 }
286
287
288
289
290
291
292 public Date getExpiryTime() {
293 if (getMaxIdleTime() <= 0) {
294 return null;
295 }
296 return new Date(System.currentTimeMillis() + getMaxIdleTime() - getIdleTime());
297 }
298
299
300
301
302
303
304 public boolean isSerializable() {
305 return serializable;
306 }
307
308
309
310
311
312
313 public void setSerializable(boolean serializable) {
314 this.serializable = serializable;
315 }
316
317
318
319
320
321
322 public long getSize() {
323 return size;
324 }
325
326
327
328
329
330
331 public void setSize(long size) {
332 this.size = size;
333 }
334
335
336
337
338
339
340 public boolean isAllowedToViewValues() {
341 return allowedToViewValues;
342 }
343
344
345
346
347
348
349 public void setAllowedToViewValues(boolean allowedToViewValues) {
350 this.allowedToViewValues = allowedToViewValues;
351 }
352
353
354
355
356
357
358 public String getLastAccessedIp() {
359 return lastAccessedIp;
360 }
361
362
363
364
365
366
367 public void setLastAccessedIp(String lastAccessedIp) {
368 this.lastAccessedIp = lastAccessedIp;
369 }
370
371
372
373
374
375
376 public Locale getLastAccessedIpLocale() {
377 return lastAccessedIpLocale;
378 }
379
380
381
382
383
384
385 public void setLastAccessedIpLocale(Locale lastAccessedIpLocale) {
386 this.lastAccessedIpLocale = lastAccessedIpLocale;
387 }
388
389 }