com.prolixtech.jaminid

Class Daemon


public class Daemon
extends 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.

Field Summary

static String
VERSION

Constructor Summary

Daemon(int serverPort, ContentOracle cOra)
creates a new daemon and opens on specific port
Daemon(int serverPort, int backLog, InetAddress adr, 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(args[] )
void
printlog(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
String
toString()

Field Details

VERSION

public static final String VERSION

Constructor Details

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

Daemon

public Daemon(int serverPort,
              int backLog,
              InetAddress adr,
              ContentOracle cOra)
creates a new daemon and opens on specific port
Parameters:
serverPort - the port to open on
backLog - maximum queue length. more concurrent connections will be rejected. default: 50
adr - the address to bind to. null means any address found.
cOra - the content oracle to use

Method Details

getOracle

public ContentOracle getOracle()
Returns:
the oracle instance

getProtocol

public Protocol getProtocol()
Returns:
the protocol instance

getServerPort

public int getServerPort()
returns the server port
Returns:
the server port

isRunning

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

main

public static void main(args[] )

printlog

public void printlog(String message)

run

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

tearDown

public void tearDown()
tears down server

tearDownAndWait

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

toString

public String toString()