@ThreadRestricted(value="holds lock()") public abstract class VoterService extends Object
Modifier and Type | Class and Description |
---|---|
static class |
VoterService.ConstructionContext
A context for configuring a voter serivce.
|
static class |
VoterService.IllegalNameException
Thrown when a service with an illegal name is requested.
|
static class |
VoterService.NoSuchServiceException
Thrown when an unknown voter service is requested.
|
Modifier and Type | Field and Description |
---|---|
protected VoterService.ConstructionContext |
constructionContext
Stored as a convenience for subclass initialization, may be nulled afterwards by
subclass.
|
protected ReentrantLock |
lock |
protected String |
name |
static int |
NAME_MAX_LENGTH
The maximum length of a service name.
|
static Pattern |
NAME_PATTERN
The allowable pattern of a service name.
|
protected VoteServer.Run |
vsRun |
Modifier | Constructor and Description |
---|---|
protected |
VoterService(VoteServer.Run _vsRun,
VoterService.ConstructionContext cc)
Partially creates a VoterService.
|
Modifier and Type | Method and Description |
---|---|
Exception |
dispatch(String[] argArray,
CommandResponder.Session commandSession)
Looks up the responder of the specified command, and sends the command
to it.
|
Exception |
dispatch(String[] argArray,
CommandResponder.Session commandSession,
CommandResponder responder)
Sends a command to its responder, if one is specified.
|
boolean |
equals(Object o)
Returns true iff o is a voter service of the same class with the same name.
|
Exception |
help(String[] argv,
CommandResponder.Session session)
Responds to a help command on behalf of the nominal responder, per respond(argv,session).
|
protected void |
helpA_1(CommandResponder.Session session) |
protected void |
helpA_2(CommandResponder.Session session) |
protected void |
helpA_3(CommandResponder.Session session) |
protected void |
helpA(CommandResponder.Session session) |
protected void |
helpB(CommandResponder.Session session) |
protected void |
helpC(CommandResponder.Session session) |
protected void |
init(ArrayList<CommandResponder> responderList) |
static boolean |
isNonPoll(String name)
Answers whether the named service is (or would be) a non-poll service.
|
ReentrantLock |
lock()
Returns the thread access lock for this service.
|
String |
name()
The local name of this service.
|
CommandResponder |
responderByClassName(String className)
Returns the responder of a particular class name, or null if there is none.
|
CommandResponder |
responderForCommand(String[] argArray,
CommandResponder.Session commandSession)
Returns the responder for the specified command, or null if there is none.
|
CommandResponder[] |
responders()
An array of all responders.
|
File |
serviceDirectory()
The directory containing this service's configuration files.
|
abstract File |
startupConfigurationFile()
The startup configuration file for this service.
|
abstract String |
summaryDescription()
A short description that summarizes this service.
|
abstract String |
title()
The title of this service in wiki-style title case.
|
String |
toString()
Returns the service name.
|
VoteServer.Run |
vsRun()
The vote-server run, in which this service is provided.
|
protected final ReentrantLock lock
public static final int NAME_MAX_LENGTH
name()
,
zelea.com/w/Category:Poll,
Constant Field Valuespublic static final Pattern NAME_PATTERN
name()
,
zelea.com/w/Category:Pollprotected final VoteServer.Run vsRun
protected VoterService.ConstructionContext constructionContext
protected VoterService(VoteServer.Run _vsRun, VoterService.ConstructionContext cc)
@ThreadRestricted(value="constructor") protected final void init(ArrayList<CommandResponder> responderList)
responderList
- listing only the service-specific responders;
the general responders will be added by this method.public Exception dispatch(String[] argArray, CommandResponder.Session commandSession)
argArray
- an array containing the command name and arguments,
per CommandResponder.respond(argv,session).CommandResponder.respond(String[],CommandResponder.Session)
public final Exception dispatch(String[] argArray, CommandResponder.Session commandSession, CommandResponder responder)
argArray
- an array containing the command name and arguments,
per CommandResponder.respond(argv,session).responder
- the responder for the command, or null if there is none.responderForCommand(String[],CommandResponder.Session)
,
CommandResponder.respond(String[],CommandResponder.Session)
public Exception help(String[] argv, CommandResponder.Session session)
public static boolean isNonPoll(String name)
public final ReentrantLock lock()
VoteServer.Run.singleServiceLock()
@ThreadSafe public final String name()
NAME_MAX_LENGTH
,
NAME_PATTERN
@ThreadSafe public final VoteServer.Run vsRun()
public final CommandResponder responderByClassName(String className)
public final CommandResponder responderForCommand(String[] argArray, CommandResponder.Session commandSession)
argArray
- array of command name and arguments,
per CommandResponder.respond(argv,session).public final CommandResponder[] responders()
@ThreadSafe public final File serviceDirectory()
@ThreadSafe public abstract File startupConfigurationFile()
public abstract String summaryDescription()
public abstract String title()
@ThreadSafe public final boolean equals(Object o)
@ThreadSafe public final String toString()
protected final void helpA(CommandResponder.Session session)
protected final void helpA_1(CommandResponder.Session session)
protected void helpA_2(CommandResponder.Session session)
protected final void helpA_3(CommandResponder.Session session)
protected final void helpB(CommandResponder.Session session)
protected final void helpC(CommandResponder.Session session)