Keel 2.1RC2

org.apache.excalibur.instrument.manager.http.server
Class HTTPServer

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.excalibur.instrument.AbstractLogEnabledInstrumentable
          extended byorg.apache.excalibur.instrument.manager.http.server.AbstractLogEnabledInstrumentableStartable
              extended byorg.apache.excalibur.instrument.manager.http.server.AbstractSocketServer
                  extended byorg.apache.excalibur.instrument.manager.http.server.HTTPServer
All Implemented Interfaces:
Instrumentable, LogEnabled, java.lang.Runnable, Startable

public class HTTPServer
extends AbstractSocketServer

Since:
4.1
Version:
CVS $Revision: 1.6 $ $Date: 2004/03/10 13:59:34 $
Author:

Field Summary
private  HTTPURLHandler[] m_handlerArray
          Optimized array of the handler list that lets us avoid synchronization
private  java.util.List m_handlers
          List of registered HTTPURLHandlers.
private  CounterInstrument m_instrumentRequests
          Number of requests.
 
Fields inherited from class org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable
 
Fields inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
 
Fields inherited from interface org.apache.excalibur.instrument.Instrumentable
EMPTY_INSTRUMENT_ARRAY, EMPTY_INSTRUMENTABLE_ARRAY
 
Constructor Summary
HTTPServer(int port, java.net.InetAddress bindAddress)
          Creates a new HTTPServer.
 
Method Summary
private  void decodeParameter(java.util.Map params, java.lang.String pair, java.lang.String encoding)
           
private  void decodeQuery(java.util.Map params, java.lang.String query, java.lang.String encoding)
           
private  HTTPURLHandler[] getHandlers()
           
protected  int getSoTimeout()
           
private  boolean handleRequest(java.io.InputStream is, java.io.OutputStream os)
           
protected  void handleSocket(java.net.Socket socket)
          Handle a newly connected socket.
 boolean isStopping()
          Returns true when the component is in the process of being stopped.
 void registerHandler(HTTPURLHandler handler)
          Registers a new HTTP URL Handler with the server.
 void run()
          Run method which is responsible for launching the runner method and handling the shutdown cycle.
protected  void runner()
          Runner method that will be called when the component is started.
 void setParameter(java.util.Map params, java.lang.String param, java.lang.String value)
           
 void start()
          Starts the runner thread.
 void stop()
          Stops the runner thread, blocking until it has stopped.
protected  void stopRunner()
          Called when the component is being stopped, the isStopping method will always return true when this method is called.
 
Methods inherited from class org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable
addChildInstrumentable, addInstrument, getChildInstrumentables, getInstrumentableName, getInstruments, setInstrumentableName
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_handlers

private java.util.List m_handlers
List of registered HTTPURLHandlers.


m_handlerArray

private HTTPURLHandler[] m_handlerArray
Optimized array of the handler list that lets us avoid synchronization


m_instrumentRequests

private CounterInstrument m_instrumentRequests
Number of requests.

Constructor Detail

HTTPServer

public HTTPServer(int port,
                  java.net.InetAddress bindAddress)
Creates a new HTTPServer.

Parameters:
port - The port on which the server will listen.
bindAddress - The address on which the server will listen for connections.
Method Detail

handleSocket

protected void handleSocket(java.net.Socket socket)
Handle a newly connected socket. The implementation need not worry about closing the socket.

Specified by:
handleSocket in class AbstractSocketServer
Parameters:
socket - Newly connected Socket to be handled.

registerHandler

public void registerHandler(HTTPURLHandler handler)
Registers a new HTTP URL Handler with the server.

Parameters:
handler - The handler to register.

handleRequest

private boolean handleRequest(java.io.InputStream is,
                              java.io.OutputStream os)
                       throws java.io.IOException
Throws:
java.io.IOException

setParameter

public void setParameter(java.util.Map params,
                         java.lang.String param,
                         java.lang.String value)

decodeParameter

private void decodeParameter(java.util.Map params,
                             java.lang.String pair,
                             java.lang.String encoding)

decodeQuery

private void decodeQuery(java.util.Map params,
                         java.lang.String query,
                         java.lang.String encoding)

getHandlers

private HTTPURLHandler[] getHandlers()

start

public void start()
           throws java.lang.Exception
Starts the runner thread.

Specified by:
start in interface Startable
Overrides:
start in class AbstractLogEnabledInstrumentableStartable
Throws:
java.lang.Exception - If there are any problems.

stopRunner

protected void stopRunner()
                   throws java.lang.Exception
Called when the component is being stopped, the isStopping method will always return true when this method is called.

Overrides:
stopRunner in class AbstractLogEnabledInstrumentableStartable
Throws:
java.lang.Exception - If there are any problems

runner

protected void runner()
Runner method that will be called when the component is started. The method must monitor the isStopping() method and make sure that it returns in a timely manner when the isStopping() method returns true.

Specified by:
runner in class AbstractLogEnabledInstrumentableStartable

getSoTimeout

protected int getSoTimeout()

stop

public void stop()
          throws java.lang.Exception
Stops the runner thread, blocking until it has stopped.

Specified by:
stop in interface Startable
Throws:
java.lang.Exception - If there are any problems stopping the component.

run

public void run()
Run method which is responsible for launching the runner method and handling the shutdown cycle.

Specified by:
run in interface java.lang.Runnable

isStopping

public boolean isStopping()
Returns true when the component is in the process of being stopped.

Returns:
True when the component is in the process of being stopped.

Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.