org.jcoderz.commons.connector.http.transport
Class SimpleServer

java.lang.Object
  extended by java.lang.Thread
      extended by org.jcoderz.commons.connector.http.transport.SimpleServer
All Implemented Interfaces:
Runnable

public class SimpleServer
extends Thread

This class defines a simple http server used for testing the HttpConnectionImpl based on the commons-httpclient lib.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SimpleServer(int port)
          Constructor.
 
Method Summary
 void doStop()
          Sets the flag for stopping the server.
 boolean haveToStop()
          Checks the flag for stopping the server.
 boolean isServerStarted()
          Returns true if the server has been started.
static void main(String[] args)
          Main method.
 void run()
          Starts the server thread.
 void startServer()
          Creates a client socket for every incoming request and creates a ClientHandler thread to handle the request/response.
 void stopServer()
          Stops the client handler threads.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleServer

public SimpleServer(int port)
Constructor.

Parameters:
port - the server port in use
Method Detail

main

public static void main(String[] args)
Main method. Starts a thread for terminating the server and starts a ClientHandler thread for every incomming request.

Parameters:
args - args include the port number to use

run

public void run()
Starts the server thread.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

startServer

public void startServer()
Creates a client socket for every incoming request and creates a ClientHandler thread to handle the request/response. Server will be stopped after a certain timeframe.


doStop

public void doStop()
Sets the flag for stopping the server.


haveToStop

public boolean haveToStop()
Checks the flag for stopping the server.

Returns:
boolean the flag for stopping the server

stopServer

public void stopServer()
Stops the client handler threads.


isServerStarted

public boolean isServerStarted()
Returns true if the server has been started.

Returns:
true if the server has been started; false otherwise.


Copyright 2007 The jCoderZ Project.