|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Server
The actual code for operating on elections: maintains the collection of
elections and has methods which Worker
threads and the election server manager
can call. This class is effectively immutable: all operations are passed
through a mapping of election names to
Election
objects, and the mapping does not change once the
server is up and running. Concurrency control is on individual elections,
since we don't need concurrency control on the server itself.
Operations called by the election server manager have a
display
argument, which is
how they display results (i.e. no return values); they may also throw a
DisplayException
to display
an error. Operations called by worker threads throw exceptions to indicate
errors, and return results normally.
Field Summary | |
short |
port
Port to open server socket on. |
Method Summary | |
void |
closeElection(java.lang.String name,
ServerDisplay display)
Close the specified election, called by election server manager only. |
void |
displayElections(ServerDisplay display)
Show the list of elections on the indicated display, called by election server manager only. |
java.util.LinkedList |
getCandidates(java.lang.String poll)
Called by worker thread to get candidates for election " poll ". |
java.util.LinkedList |
getElections()
Called by worker thread to get a list of elections (not used). |
void |
openElection(java.lang.String name,
ServerDisplay display)
Open the specified election, called by election server manager only. |
void |
viewElection(java.lang.String poll,
ServerDisplay display)
|
void |
vote(java.lang.String poll,
java.lang.String candidate)
Called by worker thread to vote for a candidate for election " poll ". |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public short port
Method Detail |
public void openElection(java.lang.String name, ServerDisplay display) throws DisplayException, UndefinedElectionException
DisplayException
UndefinedElectionException
public void closeElection(java.lang.String name, ServerDisplay display) throws DisplayException, UndefinedElectionException
DisplayException
UndefinedElectionException
public void viewElection(java.lang.String poll, ServerDisplay display) throws DisplayException, UndefinedElectionException
DisplayException
UndefinedElectionException
public void displayElections(ServerDisplay display)
public java.util.LinkedList getElections()
public java.util.LinkedList getCandidates(java.lang.String poll) throws UndefinedElectionException, ElectionNotOpenException
poll
".
UndefinedElectionException
ElectionNotOpenException
public void vote(java.lang.String poll, java.lang.String candidate) throws ElectionNotOpenException, UndefinedElectionException, UndefinedCandidateException
poll
".
ElectionNotOpenException
UndefinedElectionException
UndefinedCandidateException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |