|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.alicebot.server.core.Multiplexor
public abstract class Multiplexor
"To multiplex" means "to select one from many inputs".
A Multiplexor
multiplexes the clients of a bot
and keeps track of all their predicate values.
The following metaphor was supplied by Richard Wallace:
The Multiplexor
controls a
short "carnival ride" for each user. The Multiplexor puts the
client in his/her seat, hands him/her an id card, and closes the door.
The client gets one "turn of the crank". He/she enters
his/her id, multiline query, and then receives the reply. The door opens,
the Multiplexor ushers him/her out, and seats the next client.
Historically, the functionality specified by this class was
implemented in Classifier
. However, Classifier
evolved
to include database access methods that were not desirable for all
implementations. Furthermore, Classifier
lost part of its
original purpose as a "classifier of user inputs into categories".
Hence, the Program D Classifier
has been left as-is, except it
has been changed into an subclass of this abstract class. There are two
new subclasses called FlatFileMultiplexor
and DBMultiplexor
.
Starting in 4.1.5, this became an abstract class instead of an interface,
and introduced the single public getResponse(java.lang.String, java.lang.String, java.lang.String, org.alicebot.server.core.responder.Responder)
method, rather than
allowing multiple public methods for getting responses which can result in
synchronization problems. The former AbstractClassifier
class
was then removed.
FlatFileMultiplexor}
,
DBMultiplexor}
Field Summary | |
---|---|
protected static java.lang.String |
ASTERISK
An asterisk (used in String production) |
protected static float |
avgResponseTime
A counter for tracking average response time. |
protected static java.lang.String |
EMPTY_STRING
An empty string. |
protected static java.lang.String |
HOST_NAME
The host name. |
protected static java.lang.String |
INPUT
The name of the input special predicate. |
protected static java.lang.String |
PREDICATE_EMPTY_DEFAULT
The predicate empty default. |
protected static java.lang.String |
QUOTE_MARK
A quote mark. |
protected static long |
responseCount
A counter for tracking the number of responses produced. |
protected static java.lang.String |
SECRET_KEY
A secret key used for (weakly) authorizing authentication requests. |
protected static boolean |
SHOW_CONSOLE
Whether to show the console. |
protected static boolean |
SHOW_MATCH_TRACE
Whether to show the match trace. |
protected static java.lang.String |
SPACE
A space. |
protected static java.lang.String |
STAR
The name of the star special predicate. |
protected static long |
startTime
The time that the Multiplexor started operation. |
protected static java.lang.String |
THAT
The name of the that special predicate. |
protected static java.lang.String |
TOPIC
The name of the topic special predicate. |
protected static long |
totalTime
The total response time. |
protected static boolean |
USE_TARGETING
Whether to use targeting. |
protected static java.lang.String |
VALUE
The word "value". |
Constructor Summary | |
---|---|
Multiplexor()
|
Method Summary | |
---|---|
static void |
addPulse(Pulse pulse)
Adds a Pulse to the registered list. |
float |
averageResponseTime()
Returns the average response time. |
abstract boolean |
changePassword(java.lang.String userid,
java.lang.String password,
java.lang.String secretKey,
java.lang.String botid)
Changes the password associated with a userid. |
abstract boolean |
checkUser(java.lang.String userid,
java.lang.String password,
java.lang.String secretKey,
java.lang.String botid)
Checks whether a given userid and password combination is valid. |
abstract boolean |
createUser(java.lang.String userid,
java.lang.String password,
java.lang.String secretKey,
java.lang.String botid)
Creates a new user entry, given a userid and password. |
static java.lang.String |
getInternalResponse(java.lang.String input,
java.lang.String userid,
java.lang.String botid,
TemplateParser parser)
Produces a response to an "internal" input sentence -- i.e., an input that has been produced by a srai . |
static java.lang.String |
getResponse(java.lang.String input,
java.lang.String userid,
java.lang.String botid,
Responder responder)
Returns the response to a non-internal input, using a Responder. |
void |
initialize()
Initializes the Multiplexor , creating the secret key
that can be used for a weak form of authentication. |
abstract java.lang.String |
loadPredicate(java.lang.String name,
java.lang.String userid,
java.lang.String botid)
Loads a predicate into memory for a given userid . |
static void |
pulse()
Emits any registered pulses. |
float |
queriesPerHour()
Returns the number of queries per hour. |
abstract void |
savePredicate(java.lang.String name,
java.lang.String value,
java.lang.String userid,
java.lang.String botid)
Saves a predicate for a given userid . |
abstract int |
useridCount(java.lang.String botid)
Returns a count of known userids. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String THAT
that
special predicate.
protected static final java.lang.String TOPIC
topic
special predicate.
protected static final java.lang.String INPUT
input
special predicate.
protected static final java.lang.String STAR
star
special predicate.
protected static final java.lang.String EMPTY_STRING
protected static final java.lang.String SPACE
protected static final java.lang.String VALUE
protected static final java.lang.String ASTERISK
protected static final java.lang.String QUOTE_MARK
protected static final java.lang.String HOST_NAME
protected static final boolean SHOW_CONSOLE
protected static final boolean SHOW_MATCH_TRACE
protected static final boolean USE_TARGETING
protected static final java.lang.String PREDICATE_EMPTY_DEFAULT
protected static java.lang.String SECRET_KEY
protected static long startTime
protected static long responseCount
protected static long totalTime
protected static float avgResponseTime
Constructor Detail |
---|
public Multiplexor()
Method Detail |
---|
public void initialize()
Multiplexor
, creating the secret key
that can be used for a weak form of authentication.
public static java.lang.String getResponse(java.lang.String input, java.lang.String userid, java.lang.String botid, Responder responder)
input
- the "non-internal" (possibly multi-sentence, non-substituted) inputuserid
- the userid for whom the response will be generatedbotid
- the botid from which to get the responseresponder
- the Responder who cares about this responsepublic static java.lang.String getInternalResponse(java.lang.String input, java.lang.String userid, java.lang.String botid, TemplateParser parser)
Produces a response to an "internal" input sentence -- i.e.,
an input that has been produced by a srai
.
The main differences between this and
#getResponse(String,String,TemplateParser,boolean,Responder)
are that this method takes an already-existing TemplateParser
, doesn't
take a Responder
, and assumes that the inputs have already been normalized.
input
- the input sentenceuserid
- the userid requesting the responsebotid
- the botid from which to get the responseparser
- the parser object to update when generating the response#getResponse(String,String,TemplateParser,boolean,Responder)}
public float averageResponseTime()
public float queriesPerHour()
public static void addPulse(Pulse pulse)
pulse
- the Pulse to be addedpublic static void pulse()
public abstract void savePredicate(java.lang.String name, java.lang.String value, java.lang.String userid, java.lang.String botid)
userid
. This only applies to
Multiplexors that provide long-term storage (others may just do nothing).
name
- predicate namevalue
- predicate valueuserid
- user identifierbotid
- public abstract java.lang.String loadPredicate(java.lang.String name, java.lang.String userid, java.lang.String botid) throws NoSuchPredicateException
userid
. This only applies to
Multiplexors that provide long-term storage (others may just do nothing).
name
- predicate nameuserid
- user identifierbotid
-
NoSuchPredicateException
- if there is no predicate with this namepublic abstract boolean checkUser(java.lang.String userid, java.lang.String password, java.lang.String secretKey, java.lang.String botid)
userid
- the userid to checkbotid
- password
- the password to checksecretKey
- the secret key that should authenticate this request
public abstract boolean createUser(java.lang.String userid, java.lang.String password, java.lang.String secretKey, java.lang.String botid)
userid
- the userid to usebotid
- password
- the password to assignsecretKey
- the secret key that should authenticate this request
public abstract boolean changePassword(java.lang.String userid, java.lang.String password, java.lang.String secretKey, java.lang.String botid)
userid
- the useridbotid
- password
- the new passwordsecretKey
- the secret key that should authenticate this request
public abstract int useridCount(java.lang.String botid)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |