rita
Class RiTaServer

java.lang.Object
  extended by java.lang.Thread
      extended by rita.RiTaServer
All Implemented Interfaces:
java.lang.Runnable, RemoteConstants

public class RiTaServer
extends java.lang.Thread
implements java.lang.Runnable, RemoteConstants

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]);

Note: before enabling the server from your code (as above), make sure to start the server using either run-server.sh (mac/linux) or run-server.bat (win), both of which can be found in the SKETCH_FOLDER/libraries/rita/ folder (On the Mac, this is (most likely): ~/Documents/Processing/libraries/rita/)


Current objects supporting server-based operation include:


Note: although the default (and most common case) is to run the server locally, it may also be run on a remote machine, and can even provide content for publicly accessible applets.


See related:

Invisible:

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

port

public static int port
Invisible:
Constructor Detail

RiTaServer

public RiTaServer(java.net.Socket cs)
Invisible:
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread
Invisible:

refresh

public void refresh()
Clears all objects from the server so that new ones will be created on subsequent calls.

Invisible:

getObjectCount

public static int getObjectCount()
Invisible:

getObjectNames

public static java.lang.String[] getObjectNames()
Invisible:

init

public static void init(java.lang.String[] args)
Invisible:

main

public static void main(java.lang.String[] args)