de.dfki.lt.mary
Class RequestHandler

java.lang.Object
  extended by java.lang.Thread
      extended by de.dfki.lt.mary.RequestHandler
All Implemented Interfaces:
java.lang.Runnable

public class RequestHandler
extends java.lang.Thread

A lightweight process handling one Request in a thread of its own. This is to be used when running as a socket server.

Author:
Marc Schröder

Nested Class Summary
static class RequestHandler.StreamingOutputWriter
           
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
RequestHandler(Request request, java.net.Socket infoSocket, java.net.Socket dataSocket, java.io.Reader inputReader)
          Constructor to be used for Socket processing (running as a standalone socket server).
 
Method Summary
 void run()
          Perform the actual processing by calling the appropriate methods of the associated Request object.
 
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RequestHandler

public RequestHandler(Request request,
                      java.net.Socket infoSocket,
                      java.net.Socket dataSocket,
                      java.io.Reader inputReader)
Constructor to be used for Socket processing (running as a standalone socket server). inputReader is a Reader reading from from dataSocket.inputStream(). Passing this on is necessary because the mary server does a buffered read on that input stream, and without passing that buffered reader on, data gets lost.

Method Detail

run

public void run()
Perform the actual processing by calling the appropriate methods of the associated Request object.

Note that while different request handlers run as different threads, they all use the same module objects. How a given module deals with several requests simultaneously is its own problem, the simplest solution being a synchronized process() method.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread
See Also:
Request, MaryModule, ExternalModule, InternalModule