[52] | 1 | package geniusweb.protocol.session;
|
---|
| 2 |
|
---|
| 3 | import java.util.List;
|
---|
| 4 |
|
---|
| 5 | import com.fasterxml.jackson.annotation.JsonSubTypes;
|
---|
| 6 |
|
---|
| 7 | import geniusweb.actions.Action;
|
---|
| 8 | import geniusweb.inform.Agreements;
|
---|
| 9 | import geniusweb.progress.Progress;
|
---|
| 10 | import geniusweb.protocol.NegoState;
|
---|
| 11 | import geniusweb.protocol.session.amop.AMOPState;
|
---|
| 12 | import geniusweb.protocol.session.learn.LearnState;
|
---|
| 13 | import geniusweb.protocol.session.mopac.MOPACState;
|
---|
| 14 | import geniusweb.protocol.session.saop.SAOPState;
|
---|
| 15 | import geniusweb.protocol.session.shaop.SHAOPState;
|
---|
| 16 |
|
---|
| 17 | /**
|
---|
| 18 | * The current state of the session. E.g. typically contains the actions so far
|
---|
| 19 | * and the parties currently connected. <br>
|
---|
| 20 | * The state checks if transitions (Actions from the party) are following the
|
---|
| 21 | * protocol, and thus implement most of the protocol . <br>
|
---|
| 22 | *
|
---|
| 23 | * If protocol errors occur, these should be stored in the state and the state
|
---|
| 24 | * should become {@link #isFinal(long)}. Throwing should happen only in case of
|
---|
| 25 | * a bug.<br>
|
---|
| 26 | *
|
---|
| 27 | * Implementations should be immutable (to ensure thread safety, testability
|
---|
| 28 | * etc).
|
---|
| 29 | *
|
---|
| 30 | * States must be serializable so that listeners can follow what is going on in
|
---|
| 31 | * the protocol. As uaual, mark non-serializable fields as transient.
|
---|
| 32 | */
|
---|
| 33 | @JsonSubTypes({ @JsonSubTypes.Type(value = SAOPState.class),
|
---|
| 34 | @JsonSubTypes.Type(value = SHAOPState.class),
|
---|
| 35 | @JsonSubTypes.Type(value = AMOPState.class),
|
---|
| 36 | @JsonSubTypes.Type(value = MOPACState.class),
|
---|
| 37 | @JsonSubTypes.Type(value = LearnState.class) })
|
---|
| 38 | public interface SessionState extends NegoState {
|
---|
| 39 |
|
---|
| 40 | @Override
|
---|
| 41 | SessionSettings getSettings();
|
---|
| 42 |
|
---|
| 43 | /**
|
---|
| 44 | *
|
---|
| 45 | * @return unmodifyable list of actions done so far, in the order in which
|
---|
| 46 | * they arrived. List of list allows implementations to add some
|
---|
| 47 | * extra structure to the actions, eg one list per phase
|
---|
| 48 | */
|
---|
| 49 | List<Action> getActions();
|
---|
| 50 |
|
---|
| 51 | /**
|
---|
| 52 | *
|
---|
| 53 | * @return the progress of the session. Can return null if the session did
|
---|
| 54 | * not even start yet. Notice that the protocol determines when a
|
---|
| 55 | * session officially starts (eg, in SAOP it starts after all
|
---|
| 56 | * parties were connected succesfully).
|
---|
| 57 | */
|
---|
| 58 | Progress getProgress();
|
---|
| 59 |
|
---|
| 60 | /**
|
---|
| 61 | *
|
---|
| 62 | * @return the current standing {@link Agreements}. An agreement does not
|
---|
| 63 | * necessarily mean {@link #isFinal(long)}.
|
---|
| 64 | */
|
---|
| 65 | Agreements getAgreements();
|
---|
| 66 |
|
---|
| 67 | }
|
---|