Skip to content

Commit d158579

Browse files
committed
Replaced notion of session uuid by session id which is more generic (could be a uuid, or something else).
Use STRING_TABLE for the implementation of session data container. Added a few missing comments.
1 parent 02f5a09 commit d158579

File tree

4 files changed

+67
-13
lines changed

4 files changed

+67
-13
lines changed

library/server/wsf/session/wsf_cookie_session.e

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ feature {NONE} -- Initialization
6060

6161
feature -- Cookie
6262

63-
apply_to (h: HTTP_HEADER_BUILDER; a_request: WSF_REQUEST; a_path: detachable READABLE_STRING_8)
63+
apply_to (h: HTTP_HEADER_MODIFIER; a_request: WSF_REQUEST; a_path: detachable READABLE_STRING_8)
64+
-- <Precursor>
6465
local
6566
dt: detachable DATE_TIME
6667
l_domain: detachable READABLE_STRING_8
@@ -79,13 +80,18 @@ feature -- Cookie
7980
create dt.make_now_utc
8081
dt.day_add (40)
8182
end
82-
h.put_cookie_with_expiration_date (cookie_name, uuid, dt, a_path, l_domain, False, True)
83+
h.put_cookie_with_expiration_date (cookie_name, id, dt, a_path, l_domain, False, True)
8384
end
8485
end
8586

8687
cookie_name: READABLE_STRING_8
8788

88-
feature -- Access
89+
feature -- Access
90+
91+
id: READABLE_STRING_8
92+
do
93+
Result := uuid
94+
end
8995

9096
uuid: READABLE_STRING_8
9197

@@ -135,8 +141,8 @@ feature {NONE} -- Storage
135141

136142
load
137143
do
138-
if manager.session_exists (uuid) then
139-
if attached manager.session_data (uuid) as d then
144+
if manager.session_exists (id) then
145+
if attached manager.session_data (id) as d then
140146
data := d
141147
set_expiration (data.expiration)
142148
else

library/server/wsf/session/wsf_fs_session_manager.e

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ feature -- Persistence
6868
delete_session (a_session)
6969
else
7070
ensure_session_folder_exists
71-
create f.make_with_path (file_name (a_session.uuid))
71+
create f.make_with_path (file_name (a_session.id))
7272
if not f.exists or else f.is_writable then
7373
f.create_read_write
7474
a_session.data.set_expiration (a_session.expiration)
@@ -91,7 +91,7 @@ feature -- Persistence
9191
rescued: BOOLEAN
9292
do
9393
if not rescued then
94-
create f.make_with_path (file_name (a_session.uuid))
94+
create f.make_with_path (file_name (a_session.id))
9595
if f.exists then
9696
f.delete
9797
end

library/server/wsf/session/wsf_session.e

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,43 @@ note
77
deferred class
88
WSF_SESSION
99

10-
feature -- Access
10+
feature -- Access
11+
12+
id: READABLE_STRING_8
13+
-- Session identifier.
14+
deferred
15+
end
1116

1217
uuid: READABLE_STRING_8
18+
obsolete
19+
"Use `id' which is more general [2014-03]"
1320
deferred
1421
end
1522

1623
data: WSF_SESSION_DATA
24+
-- Data associated with current session.
1725
deferred
1826
end
1927

2028
expiration: detachable DATE_TIME
29+
-- Expiration date for current session, if any.
2130
deferred
2231
end
2332

2433
expired: BOOLEAN
34+
-- Is current session expired now?
35+
do
36+
Result := expired_at (create {DATE_TIME}.make_now_utc)
37+
end
38+
39+
expired_at (dt: DATE_TIME): BOOLEAN
40+
-- Is current session expired at date and time `dt'?
2541
do
2642
if attached expiration as e then
27-
Result := e < (create {DATE_TIME}.make_now_utc)
43+
Result := e < (dt)
2844
end
2945
end
46+
3047
feature -- status
3148

3249
is_pending: BOOLEAN
@@ -36,27 +53,32 @@ feature -- status
3653
end
3754

3855
is_destroyed: BOOLEAN
56+
-- Is current session in destroyed state?
3957
deferred
4058
end
4159

4260
feature -- Entries
4361

44-
table: TABLE_ITERABLE [detachable ANY, READABLE_STRING_32]
62+
table: TABLE_ITERABLE [detachable ANY, READABLE_STRING_GENERAL]
63+
-- Table of session data indexed by key
4564
do
4665
Result := data
4766
end
4867

49-
item (k: READABLE_STRING_GENERAL): detachable ANY
68+
item alias "[]" (k: READABLE_STRING_GENERAL): detachable ANY assign remember
69+
-- Session value associated with key `k'.
5070
do
5171
Result := data.item (table_key (k))
5272
end
5373

5474
remember (v: detachable ANY; k: READABLE_STRING_GENERAL)
75+
-- Remember value `v' in association with key `k'.
5576
do
5677
data.force (v, table_key (k))
5778
end
5879

5980
forget (k: READABLE_STRING_GENERAL)
81+
-- Forget about value associated with key `k'.
6082
do
6183
data.remove (table_key (k))
6284
end
@@ -71,14 +93,16 @@ feature {NONE} -- Implementation
7193
feature -- Control
7294

7395
destroy
96+
-- Destroy current session.
7497
deferred
7598
end
7699

77100
commit
101+
-- Commit current session, including data associated.
78102
deferred
79103
end
80104

81-
apply_to (h: HTTP_HEADER_BUILDER; req: WSF_REQUEST; a_path: detachable READABLE_STRING_8)
105+
apply_to (h: HTTP_HEADER_MODIFIER; req: WSF_REQUEST; a_path: detachable READABLE_STRING_8)
82106
-- Apply current session to header `h' for request `req' and optional path `a_path'.
83107
-- note: either use `apply_to' or `apply', not both.
84108
deferred

library/server/wsf/session/wsf_session_data.e

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ class
88
WSF_SESSION_DATA
99

1010
inherit
11-
HASH_TABLE [detachable ANY, READABLE_STRING_32]
11+
STRING_TABLE [detachable ANY]
12+
rename
13+
make as old_make,
14+
make_caseless as make
15+
redefine
16+
empty_duplicate
17+
end
1218

1319
create
1420
make
@@ -24,4 +30,22 @@ feature -- Element change
2430
expiration := dt
2531
end
2632

33+
feature {NONE} -- Duplication
34+
35+
empty_duplicate (n: INTEGER): like Current
36+
-- Create an empty copy of Current that can accommodate `n' items
37+
do
38+
create Result.make (n)
39+
end
40+
41+
note
42+
copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
43+
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
44+
source: "[
45+
Eiffel Software
46+
5949 Hollister Ave., Goleta, CA 93117 USA
47+
Telephone 805-685-1006, Fax 805-685-6869
48+
Website http://www.eiffel.com
49+
Customer support http://support.eiffel.com
50+
]"
2751
end

0 commit comments

Comments
 (0)