de.unkrig.commons.net.http
Class HttpClientConnectionHandler

java.lang.Object
  extended by de.unkrig.commons.net.http.HttpClientConnectionHandler
All Implemented Interfaces:
Stoppable

public class HttpClientConnectionHandler
extends java.lang.Object
implements Stoppable

A container of Servletts that handle requests that are received from a client connection.


Constructor Summary
HttpClientConnectionHandler()
           
HttpClientConnectionHandler(java.lang.Iterable<Servlett> servletts)
           
HttpClientConnectionHandler(Servlett servlett)
           
 
Method Summary
 java.lang.Iterable<Servlett> getServletts()
           
 void handleConnection(java.io.InputStream in, java.io.OutputStream out, java.net.InetSocketAddress localSocketAddress, java.net.InetSocketAddress remoteSocketAddress, Stoppable stoppable)
          This one is called from the HttpServer.
 void handleConnection(java.nio.channels.ReadableByteChannel in, java.nio.channels.WritableByteChannel out, java.net.InetSocketAddress localSocketAddress, java.net.InetSocketAddress remoteSocketAddress, Multiplexer multiplexer, Stoppable stoppable)
          This one is called from the NioHttpServer.
protected  void processRequests(java.io.InputStream in, java.io.OutputStream out, Stoppable stoppable)
          Processes HTTP requests from the client until the connection breaks.
 void setServlett(Servlett servlett)
          Clears the set of currently registerd Servletts and registers the given servlett.
 void setServletts(java.lang.Iterable<Servlett> servletts)
          Clears the set of currently registerd Servletts and registers the given servletts.
 void stop()
          Returns when this Stoppable has completely stopped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpClientConnectionHandler

public HttpClientConnectionHandler()

HttpClientConnectionHandler

public HttpClientConnectionHandler(Servlett servlett)

HttpClientConnectionHandler

public HttpClientConnectionHandler(java.lang.Iterable<Servlett> servletts)
Method Detail

getServletts

public java.lang.Iterable<Servlett> getServletts()
Returns:
The Servletts currently registered with this HttpClientConnectionHandler

setServlett

public void setServlett(Servlett servlett)
Clears the set of currently registerd Servletts and registers the given servlett.


setServletts

public void setServletts(java.lang.Iterable<Servlett> servletts)
Clears the set of currently registerd Servletts and registers the given servletts.


handleConnection

public void handleConnection(java.io.InputStream in,
                             java.io.OutputStream out,
                             java.net.InetSocketAddress localSocketAddress,
                             java.net.InetSocketAddress remoteSocketAddress,
                             Stoppable stoppable)
                      throws java.io.IOException,
                             InvalidHttpMessageException
This one is called from the HttpServer. Override if you want to process the connection before request processing begins.

Parameters:
localSocketAddress - Could be examined by implementations that override this method
remoteSocketAddress - Could be examined by implementations that override this method
stoppable - Stopping this will break the connection
Throws:
java.io.IOException
InvalidHttpMessageException

handleConnection

public void handleConnection(java.nio.channels.ReadableByteChannel in,
                             java.nio.channels.WritableByteChannel out,
                             java.net.InetSocketAddress localSocketAddress,
                             java.net.InetSocketAddress remoteSocketAddress,
                             Multiplexer multiplexer,
                             Stoppable stoppable)
                      throws java.io.IOException
This one is called from the NioHttpServer. Override if you want to process the connection before request processing begins.

Parameters:
localSocketAddress - Could be examined by implementations that override this method
remoteSocketAddress - Could be examined by implementations that override this method
stoppable - Stopping this will break the connection
Throws:
java.io.IOException

processRequests

protected void processRequests(java.io.InputStream in,
                               java.io.OutputStream out,
                               Stoppable stoppable)
                        throws java.io.IOException,
                               InvalidHttpMessageException
Processes HTTP requests from the client until the connection breaks.

Parameters:
stoppable - Stopping this will break the connection
Throws:
java.io.IOException
InvalidHttpMessageException

stop

public void stop()
Description copied from interface: Stoppable
Returns when this Stoppable has completely stopped.

Specified by:
stop in interface Stoppable