com.bitmechanic.maxq
Class ProxyServer

java.lang.Object
  extended by java.lang.Thread
      extended by com.bitmechanic.maxq.ProxyServer
All Implemented Interfaces:
java.lang.Runnable

public class ProxyServer
extends java.lang.Thread

A proxy server. Creates a RequestHandler in a separate thread to handle each connection it receives. RequestHandlers call back here with the data for the requests and response being handled, and we pass this on to any observers that register themselves.


Nested Class Summary
static interface ProxyServer.Observer
           
 
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
ProxyServer()
           
ProxyServer(int port)
          Attempts to start a proxy server on the specified port.
 
Method Summary
 void addObserver(ProxyServer.Observer proxy)
           
 void processRequest(HttpRequestHeader header, byte[] requestBody)
           
 void processResponse(HttpRequestHeader header, byte[] response)
           
 void removeObserver(ProxyServer.Observer proxy)
           
 void run()
           
 
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

ProxyServer

public ProxyServer()
            throws java.io.IOException
Throws:
java.io.IOException

ProxyServer

public ProxyServer(int port)
            throws java.io.IOException
Attempts to start a proxy server on the specified port.

if successful,it starts the proxy server on a new thread.

Throws:
java.io.IOException
Method Detail

addObserver

public void addObserver(ProxyServer.Observer proxy)

removeObserver

public void removeObserver(ProxyServer.Observer proxy)

processRequest

public void processRequest(HttpRequestHeader header,
                           byte[] requestBody)
                    throws java.lang.Exception
Throws:
java.lang.Exception

processResponse

public void processResponse(HttpRequestHeader header,
                            byte[] response)
                     throws java.lang.Exception
Throws:
java.lang.Exception

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread