org.apache.axis2.transport.http.server
Class SimpleHttpServer

java.lang.Object
  extended byorg.apache.axis2.transport.http.server.SimpleHttpServer
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
SimpleProxy

public class SimpleHttpServer
extends java.lang.Object
implements java.lang.Runnable

A simple, but extensible HTTP server, mostly for testing purposes.


Constructor Summary
SimpleHttpServer()
          Creates a new HTTP server instance, using an arbitrary free TCP port
SimpleHttpServer(int port)
          Creates a new HTTP server instance, using the specified TCP port
SimpleHttpServer(SimpleSocketFactory socketfactory, int port)
          Creates a new HTTP server instance, using the specified socket factory and the TCP port
 
Method Summary
 void destroy()
          Stops this HTTP server instance.
 java.lang.String getLocalAddress()
          Returns the IP address that this HTTP server instance is bound to.
 int getLocalPort()
          Returns the TCP port that this HTTP server instance is bound to.
 HttpRequestHandler getRequestHandler()
          Returns the currently used HttpRequestHandler by this SimpleHttpServer
 java.lang.String getTestname()
           
 boolean isRunning()
          Checks if this HTTP server instance is running.
 void run()
           
 void setHttpService(HttpService service)
           
 void setRequestHandler(HttpRequestHandler rh)
          Sets the HttpRequestHandler to be used for this SimpleHttpServer.
 void setTestname(java.lang.String testname)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleHttpServer

public SimpleHttpServer()
                 throws java.io.IOException
Creates a new HTTP server instance, using an arbitrary free TCP port

Throws:
java.io.IOException - if anything goes wrong during initialization

SimpleHttpServer

public SimpleHttpServer(SimpleSocketFactory socketfactory,
                        int port)
                 throws java.io.IOException
Creates a new HTTP server instance, using the specified socket factory and the TCP port

Parameters:
port - Desired TCP port
Throws:
java.io.IOException - if anything goes wrong during initialization

SimpleHttpServer

public SimpleHttpServer(int port)
                 throws java.io.IOException
Creates a new HTTP server instance, using the specified TCP port

Parameters:
port - Desired TCP port
Throws:
java.io.IOException - if anything goes wrong during initialization
Method Detail

getTestname

public java.lang.String getTestname()

setTestname

public void setTestname(java.lang.String testname)

getLocalPort

public int getLocalPort()
Returns the TCP port that this HTTP server instance is bound to.

Returns:
TCP port, or -1 if not running

getLocalAddress

public java.lang.String getLocalAddress()
Returns the IP address that this HTTP server instance is bound to.

Returns:
String representation of the IP address or null if not running

isRunning

public boolean isRunning()
Checks if this HTTP server instance is running.

Returns:
true/false

destroy

public void destroy()
Stops this HTTP server instance.


getRequestHandler

public HttpRequestHandler getRequestHandler()
Returns the currently used HttpRequestHandler by this SimpleHttpServer

Returns:
The used HttpRequestHandler, or null.

setRequestHandler

public void setRequestHandler(HttpRequestHandler rh)
Sets the HttpRequestHandler to be used for this SimpleHttpServer.

Parameters:
rh - Request handler to be used, or null to disable.

setHttpService

public void setHttpService(HttpService service)

run

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