|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
rita.RiTaServer
public class RiTaServer
Another way of using the RiTa objects is in a server mode. In server mode, the RiTaServer keeps running indefinitely; it accepts commands via a socket, executes these commands, and sends the results back through the socket. You can start the RiTaServer by double-clicking on the run-server script for your platform (see below) found within the standard RiTa distibution (or from the command line).
One common use of the RiTaServer is for objects that may have expensive initialization routines (e.g. building a large n-gram model from text files). Rather than incurring this loading cost each time the program is run (in development, for example), the RiTaServer enables the model to remain in memory while your program can be stopped and started as often as you like.
For example:
RiTa.useServer(); // add this one line
RiMarkov rm = new RiMarkov(this, 3);
rm.loadFile("war_peace.txt");
String[] sents = rm.generateSentences(10);
for (int i = 0; i < sents.length; i++)
System.out.println(sents[i]);
Current objects supporting server-based operation include:
See related:
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
static int |
port
|
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Fields inherited from interface rita.support.remote.RemoteConstants |
|---|
ARG_DELIM, ARR_DELIM, CHUNKER, DELIM, FS, LB, LP, MARKOV, PARSER, QQ, RB, RP, SPC, TAGGER, TYPE_DELIM |
| Constructor Summary | |
|---|---|
RiTaServer(java.net.Socket cs)
|
|
| Method Summary | |
|---|---|
static int |
getObjectCount()
|
static java.lang.String[] |
getObjectNames()
|
static void |
init(java.lang.String[] args)
|
static void |
main(java.lang.String[] args)
|
void |
refresh()
Clears all objects from the server so that new ones will be created on subsequent calls. |
void |
run()
|
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static int port
| Constructor Detail |
|---|
public RiTaServer(java.net.Socket cs)
| Method Detail |
|---|
public void run()
run in interface java.lang.Runnablerun in class java.lang.Threadpublic void refresh()
public static int getObjectCount()
public static java.lang.String[] getObjectNames()
public static void init(java.lang.String[] args)
public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||