org.apache.jdo.impl.fostore
Class Main

java.lang.Object
  extended byorg.apache.jdo.impl.fostore.Main

public class Main
extends java.lang.Object

Standalone server for FOStore databases.

This class is public because it has a main entry point for running as a standalone program.

Version:
1.0
Author:
Craig Russell

Nested Class Summary
(package private)  class Main.ConnectionRunnable
          The Runnable class for incoming connections.
(package private)  class Main.ListenerRunnable
          The Listener Thread class.
(package private)  class Main.TimeoutRunnable
          The Timeout Runnable class.
 
Field Summary
(package private)  int backlog
          The backlog for Socket.listen.
private static int DEFAULT_BACKLOG
          Default backlog.
private static int DEFAULT_TIMEOUT
          Default timeout.
(package private)  java.lang.Thread listenerThread
          The Thread responsible for listening for incoming connection requests.
(package private) static org.apache.commons.logging.Log logger
          Logger
private static org.apache.jdo.util.I18NHelper msg
          I18N support.
(package private)  int port
          The port number to use for incoming connections.
(package private)  java.lang.String root
          The root of the file system for database path names.
(package private)  java.util.HashSet serviceThreads
          The set of Threads servicing incoming connections.
(package private) static boolean shutdown
          A flag indicating that the server is shutting down.
(package private) static java.lang.Object shutdownSynchronizer
          The synchronizing Object for the shutdown flag.
(package private)  java.util.Date startTime
          The time this server started running.
(package private)  int timeout
          The number of seconds with no activity before shutting down.
(package private) static java.lang.Thread timeoutThread
          The Thread responsible for detecting inactivity.
 
Constructor Summary
Main()
          Creates new Main
 
Method Summary
(package private) static void flush()
          Flush the standard output.
(package private) static boolean getShutdown()
          Test if the server is shutting down.
(package private)  void handleConnection(java.net.Socket socket)
          Handle the incoming connection.
static void main(java.lang.String[] args)
          The main routine.
(package private) static void print(java.lang.String s)
          Print a message on the standard output.
(package private) static void resetTimeout()
           
(package private)  void run(java.lang.String[] args)
          Run the main program.
(package private) static void setShutdown()
          Set the shutdown flag.
(package private)  void startListenerThread()
          Start the Listener Thread.
(package private)  void startTimeoutThread()
          Start the TimeoutThread.
(package private) static void usage()
          Print the usage message on standard output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

msg

private static final org.apache.jdo.util.I18NHelper msg
I18N support.


logger

static final org.apache.commons.logging.Log logger
Logger


port

int port
The port number to use for incoming connections.


backlog

int backlog
The backlog for Socket.listen.


DEFAULT_BACKLOG

private static final int DEFAULT_BACKLOG
Default backlog.

See Also:
Constant Field Values

timeout

int timeout
The number of seconds with no activity before shutting down.


DEFAULT_TIMEOUT

private static final int DEFAULT_TIMEOUT
Default timeout.

See Also:
Constant Field Values

root

java.lang.String root
The root of the file system for database path names. Currently this property is ignored.


startTime

final java.util.Date startTime
The time this server started running.


shutdown

static boolean shutdown
A flag indicating that the server is shutting down.


shutdownSynchronizer

static java.lang.Object shutdownSynchronizer
The synchronizing Object for the shutdown flag.


timeoutThread

static java.lang.Thread timeoutThread
The Thread responsible for detecting inactivity.


listenerThread

java.lang.Thread listenerThread
The Thread responsible for listening for incoming connection requests.


serviceThreads

java.util.HashSet serviceThreads
The set of Threads servicing incoming connections.

Constructor Detail

Main

public Main()
Creates new Main

Method Detail

main

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

Parameters:
args - the command line arguments

usage

static void usage()
Print the usage message on standard output.


run

void run(java.lang.String[] args)
Run the main program.

Parameters:
args - the command line arguments

startTimeoutThread

void startTimeoutThread()
Start the TimeoutThread.


resetTimeout

static void resetTimeout()

startListenerThread

void startListenerThread()
Start the Listener Thread.


handleConnection

void handleConnection(java.net.Socket socket)
Handle the incoming connection. This method should create a new handler instance to read the messages from the connection, parse the message, determine which database is being used, and handle the requests.

Parameters:
socket - the socket connected by the listener

getShutdown

static boolean getShutdown()
Test if the server is shutting down.

Returns:
if the server is shutting down.

setShutdown

static void setShutdown()
Set the shutdown flag.


print

static void print(java.lang.String s)
Print a message on the standard output.

Parameters:
s - the message to print.

flush

static void flush()
Flush the standard output.