com.prolixtech.jaminid
Class Daemon

java.lang.Object
  extended by java.lang.Thread
      extended by com.prolixtech.jaminid.Daemon
All Implemented Interfaces:
java.lang.Runnable

public class Daemon
extends java.lang.Thread

As in most HTTP implementations, the Daemon opens a port, listens for incoming connections, and then spawns the connections to serve that connection. Sometimes this is called the server, we already have plenty of things in the works that will be called servers, so we're going for the what was the original name of the process before Marketting got to it. We're going for a no frills implementation that handles all the law level stuff and delegates the production of content to what we call a ContentOracle. This is a nice clean design that makes this code reusable. On the subject of why an HTTP server vs a JSP implementation, we find this to be a better approach. Less messy, makes the whole thing easier to install, more controllable, faster - this is no frills. The code is centralized, almost all of it in the server itself.

Author:
Constantinos Michael TODO

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static java.lang.String VERSION
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Daemon(int serverPort, ContentOracle cOra)
          creates a new daemon and opens on specific port
 
Method Summary
 ContentOracle getOracle()
           
 Protocol getProtocol()
           
 int getServerPort()
          returns the server port
 boolean isRunning()
           
static void main(java.lang.String[] args)
           
 void printlog(java.lang.String message)
           
 void run()
          Handles listening for new connections and launching client threads
 void tearDown()
          tears down server
 void tearDownAndWait()
          Tears down server and waits for it to tear down
 java.lang.String toString()
           
 
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, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
See Also:
Constant Field Values
Constructor Detail

Daemon

public Daemon(int serverPort,
              ContentOracle cOra)
creates a new daemon and opens on specific port

Parameters:
serverPort - the port to open on
cOra - the content oracle to use
Method Detail

getServerPort

public int getServerPort()
returns the server port

Returns:
the server port

getProtocol

public Protocol getProtocol()
Returns:
the protocol instance

getOracle

public ContentOracle getOracle()
Returns:
the oracle instance

run

public void run()
Handles listening for new connections and launching client threads

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Thread

main

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

printlog

public void printlog(java.lang.String message)

isRunning

public boolean isRunning()
Returns:
true if the server is up

tearDown

public void tearDown()
tears down server


tearDownAndWait

public void tearDownAndWait()
Tears down server and waits for it to tear down