org.codehaus.spice.netserve.connection.handlers
Class AbstractRequestHandler

java.lang.Object
  extended byorg.codehaus.spice.netserve.connection.handlers.AbstractRequestHandler
All Implemented Interfaces:
RequestHandler
Direct Known Subclasses:
DelegatingRequestHandler, ManagedRequestHandler

public abstract class AbstractRequestHandler
extends Object
implements RequestHandler

Abstract base class for request handlers.

Version:
$Revision: 1.2 $ $Date: 2004/03/21 23:42:58 $
Author:
Peter Donald

Constructor Summary
AbstractRequestHandler()
           
 
Method Summary
protected  Runnable createRunnable(Socket socket)
          Create Runnable to perform the request.
protected abstract  void doPerformRequest(Socket socket)
          Method implemented to actually do the work.
protected  void endConnection(Socket socket)
          End connection for socket.
protected  void errorClosingConnection(Socket socket, Throwable t)
          Notify handler of an error closing socket.
protected  void errorHandlingConnection(Socket socket, Throwable t)
          Notify handler of an error handling socket.
protected  String getThreadName(Socket socket)
          Return the name should be set for current thread.
 void handleConnection(Socket socket)
          Handle a connection.
protected  boolean isShutdown()
          Return true if handler has been shutdown.
protected  void markAsShutdown()
          Mark request handler as shutdown.
protected  void performRequest(Socket socket)
          Perform the request for socket by delegating to underlying handler.
protected  void setupThreadName(Socket socket)
          Setup the name of the thread.
 void shutdown(long timeout)
          Shutdown the handler and any requests currently being handled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRequestHandler

public AbstractRequestHandler()
Method Detail

handleConnection

public void handleConnection(Socket socket)
Handle a connection.

Specified by:
handleConnection in interface RequestHandler
Parameters:
socket - the socket

shutdown

public void shutdown(long timeout)
Description copied from interface: RequestHandler
Shutdown the handler and any requests currently being handled. The timeout specifies the time to wait while shutting down request handlers. A timeout of 0 indicates that should wait indefinetly.

Specified by:
shutdown in interface RequestHandler
Parameters:
timeout - the timeout
See Also:
RequestHandler.shutdown(long)

markAsShutdown

protected void markAsShutdown()
Mark request handler as shutdown.


isShutdown

protected boolean isShutdown()
Return true if handler has been shutdown.

Returns:
true if handler has been shutdown.

performRequest

protected void performRequest(Socket socket)
Perform the request for socket by delegating to underlying handler.

Parameters:
socket - the socket to handle

doPerformRequest

protected abstract void doPerformRequest(Socket socket)
                                  throws Exception
Method implemented to actually do the work.

Parameters:
socket - the socket
Throws:
Exception - if an error occurs

setupThreadName

protected void setupThreadName(Socket socket)
Setup the name of the thread.

Parameters:
socket - the socket associated with request

endConnection

protected void endConnection(Socket socket)
End connection for socket.

Parameters:
socket - the socket

createRunnable

protected Runnable createRunnable(Socket socket)
Create Runnable to perform the request.

Parameters:
socket - the socket to handle
Returns:
thee runnable

getThreadName

protected String getThreadName(Socket socket)
Return the name should be set for current thread.

Parameters:
socket - the socket being handled in thread
Returns:
the thread name.

errorHandlingConnection

protected void errorHandlingConnection(Socket socket,
                                       Throwable t)
Notify handler of an error handling socket.

Parameters:
socket - the socket
t - the error

errorClosingConnection

protected void errorClosingConnection(Socket socket,
                                      Throwable t)
Notify handler of an error closing socket.

Parameters:
socket - the socket
t - the error


Copyright © 1999-2004 Codehaus. All Rights Reserved.