1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.sail.core.session;
24
25 import java.util.Collection;
26 import java.util.Collections;
27 import java.util.HashSet;
28 import java.util.Properties;
29 import java.util.Set;
30
31 import net.sf.sail.core.beans.SessionContext;
32 import net.sf.sail.core.beans.event.SessionEventListener;
33 import net.sf.sail.core.beans.service.SessionService;
34 import net.sf.sail.core.entity.User;
35 import net.sf.sail.core.uuid.SessionUuid;
36
37
38 public class DefaultSessionService implements SessionService {
39
40 SessionContext session;
41
42 Set<User> users = new HashSet<User>();
43 Properties properties = new Properties();
44
45 public DefaultSessionService(SessionContext session) {
46 this.session = session;
47 }
48
49 public void userRequestsTermination() {
50 session.tryToTerminate();
51 }
52
53 public void addSessionEventListener(SessionEventListener sel) {
54 session.addSessionEventListener(sel);
55 }
56
57 public Collection<User> getUsers() {
58 return Collections.unmodifiableCollection(users);
59 }
60
61 public void addUser(User user) {
62 users.add(user);
63 }
64
65 public void removeUser(User user) {
66 users.remove(user);
67 }
68
69 public SessionUuid getSessionId() {
70 return session.getSessionId();
71 }
72
73 public String getProperty(String key, String def) {
74 return properties.getProperty(key, def);
75 }
76
77 public void setProperty(String key, String value) {
78 properties.setProperty(key, value);
79 }
80 }