|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SK.gnome.dwarf.GenericService SK.gnome.dwarf.thread.ThreadService SK.gnome.dwarf.thread.Handler SK.gnome.dwarf.tcpip.TCPHandler SK.gnome.dwarf.sample.QuoteHandler
Handles the Quote of the Day Service (RFC 865) protocol.
Field Summary |
Fields inherited from class SK.gnome.dwarf.thread.ThreadService |
daemon, thread |
Fields inherited from class SK.gnome.dwarf.GenericService |
initParameters, parent |
Fields inherited from interface SK.gnome.dwarf.Service |
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED |
Constructor Summary | |
QuoteHandler(java.lang.String name)
Creates a new QuoteHandler. |
Method Summary | |
protected void |
handle(java.net.Socket socket)
Handles the client connection. |
void |
init(Server parent)
Initializes the service. |
java.lang.String |
report()
Returns the service report. |
Methods inherited from class SK.gnome.dwarf.tcpip.TCPHandler |
handle |
Methods inherited from class SK.gnome.dwarf.thread.Handler |
enableThread, loop, start |
Methods inherited from class SK.gnome.dwarf.thread.ThreadService |
finish, run, setDaemon, shutdown, stop |
Methods inherited from class SK.gnome.dwarf.GenericService |
getAuthenticator, getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getLogger, getName, getParameters, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public QuoteHandler(java.lang.String name)
Method Detail |
public void init(Server parent) throws ServiceException
It forces the parent server to be an instance of the QuoteServer
class.
Since we need to call the server's QuoteServer.getQuote()
method to obtain the
quote strings, the initialization process must interrupt if the parent server is not an
instance of the QuoteServer
class. In order to do it we throw a
IllegalServiceClassException
to indicate the incompatible container type.
init
in interface Service
init
in class Handler
ServiceException
protected void handle(java.net.Socket socket)
This method does the actual Quote of the Day protocol handling.
The quote string is sent to the client via the socket output stream, followed by the
CRLF character sequence. The quote string is obtained from the QuoteServer
via
its QuoteServer.getQuote()
method.
handle
in class TCPHandler
public java.lang.String report()
It returns the string representation of a socket beeing currently handled, or a string with single underscore character, if no socket is handled currently. If the handler is stopped at this time, it returns the "x" string instead.
report
in interface Reportable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |