source: src/main/java/genius/core/session/SessionConfiguration.java

Last change on this file was 1, checked in by Wouter Pasman, 7 years ago

Initial import : Genius 9.0.0

File size: 2.2 KB
Line 
1package genius.core.session;
2
3import java.util.ArrayList;
4import java.util.Collections;
5import java.util.List;
6
7import genius.core.Deadline;
8import genius.core.persistent.PersistentDataType;
9import genius.core.repository.MultiPartyProtocolRepItem;
10import genius.core.repository.ParticipantRepItem;
11import genius.core.repository.PartyRepItem;
12import genius.core.repository.boa.BoaPartyRepItem;
13
14/**
15 * Holds all information to start and run a session. Contains only references,
16 * no actual agent instantiations. Immutable implementation
17 */
18public class SessionConfiguration implements MultilateralSessionConfiguration {
19
20 private MultiPartyProtocolRepItem protocol;
21 private List<Participant> parties;
22 private Deadline deadline;
23 private Participant mediator;
24 private PersistentDataType persistentDataType;
25
26 public SessionConfiguration(MultiPartyProtocolRepItem protocol, Participant mediator, List<Participant> parties,
27 Deadline deadline, PersistentDataType type) {
28 this.protocol = protocol;
29 this.parties = parties;
30 this.deadline = deadline;
31 this.mediator = mediator;
32 this.persistentDataType = type;
33 }
34
35 @Override
36 public MultiPartyProtocolRepItem getProtocol() {
37 return protocol;
38 }
39
40 @Override
41 public List<Participant> getParties() {
42 return Collections.unmodifiableList(parties);
43 }
44
45 @Override
46 public Deadline getDeadline() {
47 return deadline;
48 }
49
50 @Override
51 public String toString() {
52 return "SessionConfiguration[" + protocol + "," + parties + "," + deadline + "]";
53 }
54
55 @Override
56 public Participant getMediator() {
57 return mediator;
58 }
59
60 @Override
61 public PersistentDataType getPersistentDataType() {
62 return persistentDataType;
63 }
64
65 /**
66 * @return simple list of names
67 */
68 public List<String> getParticipantNames() {
69 List<String> participantnames = new ArrayList<String>();
70 for (Participant config : getParties()) {
71 ParticipantRepItem repitem = config.getStrategy();
72 String itemname;
73 if (repitem instanceof BoaPartyRepItem) {
74 itemname = ((BoaPartyRepItem) repitem).getUniqueName();
75 } else if (repitem instanceof PartyRepItem) {
76 itemname = ((PartyRepItem) repitem).getClassPath();
77 } else {
78 itemname = "unknown repitem " + repitem;
79 }
80 participantnames.add(itemname);
81 }
82
83 return participantnames;
84 }
85
86}
Note: See TracBrowser for help on using the repository browser.