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.logging.Level;
27 import java.util.logging.Logger;
28
29 import net.sf.sail.core.beans.SessionContext;
30 import net.sf.sail.core.curnit.ICurnit;
31 import net.sf.sail.core.entity.Offering;
32 import net.sf.sail.core.entity.User;
33 import net.sf.sail.core.uuid.SessionUuid;
34 import net.sf.sail.core.uuid.UserUuid;
35
36
37
38
39
40 public class SessionFactory {
41
42
43
44 private static final Logger logger = Logger.getLogger(SessionFactory.class
45 .getName());
46
47 public static SessionContext getLearningSession(SessionConfiguration conf) {
48 if (logger.isLoggable(Level.CONFIG)) {
49 logger.config("getLearningSession received " + conf);
50 }
51 SessionContext session = getBasicSession(conf);
52
53 ICurnit curnit = session.getOffering().getCurnit();
54
55
56
57 Object rootBean = curnit.getRootBean();
58 session.add(rootBean);
59
60 if (logger.isLoggable(Level.CONFIG)) {
61 logger.config(" and is returning " + session);
62 }
63
64 return session;
65 }
66
67
68
69
70
71
72 public static SessionContext getBasicSession(SessionConfiguration conf) {
73 SessionContext session = new SessionContext();
74 session.setDesignTime(false);
75
76 SessionUuid sessionUuid = conf.getSessionUuid();
77 session.setSessionId(sessionUuid);
78
79 SessionDataService sds = conf.getSessionDataService();
80 session.setSessionDataService(sds);
81
82 Offering offering = sds.getOffering();
83 session.setOffering(offering);
84
85 Collection<UserUuid> participants = conf.getParticipants();
86 for (UserUuid uuid : participants) {
87 User user = sds.getUser(uuid);
88 session.addUser(user);
89 }
90
91 ICurnit curnit = offering.getCurnit();
92 curnit.initialize();
93 return session;
94 }
95
96 }